Skip to content

Commit

Permalink
v4.9.2
Browse files Browse the repository at this point in the history
  • Loading branch information
herve91 committed Apr 26, 2023
1 parent b4448f7 commit 727aa61
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 44 deletions.
2 changes: 1 addition & 1 deletion sources/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Database export / import plugin for Archimate Tool
Bundle-SymbolicName: org.archicontribs.database;singleton:=true
Bundle-Version: 4.9.1
Bundle-Version: 4.9.2
Bundle-Vendor: Herve Jouin
Bundle-Localization: plugin
Bundle-RequiredExecutionEnvironment: JavaSE-11
Expand Down
2 changes: 2 additions & 0 deletions sources/src/org/archicontribs/database/DBPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@
*
* v4.9.1 01/12/2021 Fix parent folder of imported components when merging models
*
* v4.9.2 01/12/2021 Fix nullPointerExceptions when model has got null properties or features
*
* -----------------------------------------------------------------------------------------
*
* TO-DO list:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2000,25 +2000,33 @@ private void exportProperties(IProperties parent) throws SQLException {
String parentId = ((IIdentifier)parent).getId();
int parentVersion = (parent instanceof DBArchimateModel) ? ((DBArchimateModel)parent).getCurrentVersion().getVersion() : DBMetadata.getDBMetadata(parent).getCurrentVersion().getVersion();

for ( int propPos = 0 ; propPos < parent.getProperties().size(); ++propPos) {
IProperty prop = parent.getProperties().get(propPos);
if ( DBPlugin.areEqual(this.databaseEntry.getDriver(), DBDatabase.NEO4J.getDriverName()) ) {
executeRequest("MATCH (parent {id:?, version:?}) CREATE (prop:property {pos:?, name:?, value:?}), (parent)-[:hasProperty]->(prop)"
,parentId
,parentVersion
,propPos
,prop.getKey()
,prop.getValue()
);
int pos = 0;
for ( int p = 0 ; p < parent.getProperties().size(); ++p) {
IProperty prop = parent.getProperties().get(p);
if ( prop != null) {
String key = prop.getKey();
String value = prop.getValue();
if ( (key != null) && (value != null) ) {
++pos;
if ( DBPlugin.areEqual(this.databaseEntry.getDriver(), DBDatabase.NEO4J.getDriverName()) ) {
executeRequest("MATCH (parent {id:?, version:?}) CREATE (prop:property {pos:?, name:?, value:?}), (parent)-[:hasProperty]->(prop)"
,parentId
,parentVersion
,pos
,key
,value
);
}
else
insert(this.schemaPrefix+"properties", propertiesColumns
,parentId
,parentVersion
,pos
,key
,value
);
}
}
else
insert(this.schemaPrefix+"properties", propertiesColumns
,parentId
,parentVersion
,propPos
,prop.getKey()
,prop.getValue()
);
}
}
}
Expand All @@ -2037,25 +2045,33 @@ private void exportFeatures(IFeatures parent) throws SQLException {
String parentId = ((IIdentifier)parent).getId();
int parentVersion = (parent instanceof DBArchimateModel) ? ((DBArchimateModel)parent).getCurrentVersion().getVersion() : DBMetadata.getDBMetadata(parent).getCurrentVersion().getVersion();

for ( int pos = 0 ; pos < parent.getFeatures().size(); ++pos) {
int pos = 0;
for ( int p = 0 ; p < parent.getFeatures().size(); ++p) {
IFeature feature = parent.getFeatures().get(pos);
if ( DBPlugin.areEqual(this.databaseEntry.getDriver(), DBDatabase.NEO4J.getDriverName()) ) {
executeRequest("MATCH (parent {id:?, version:?}) CREATE (feat:feature {pos:?, name:?, value:?}), (parent)-[:hasFeature]->(feat)"
,parentId
,parentVersion
,pos
,feature.getName()
,feature.getValue()
);
if ( feature != null ) {
String name = feature.getName();
String value = feature.getValue();
if ( (name != null) && (value != null) ) {
++pos;
if ( DBPlugin.areEqual(this.databaseEntry.getDriver(), DBDatabase.NEO4J.getDriverName()) ) {
executeRequest("MATCH (parent {id:?, version:?}) CREATE (feat:feature {pos:?, name:?, value:?}), (parent)-[:hasFeature]->(feat)"
,parentId
,parentVersion
,pos
,name
,value
);
}
else
insert(this.schemaPrefix+"features", featuresColumns
,parentId
,parentVersion
,pos
,name
,value
);
}
}
else
insert(this.schemaPrefix+"features", featuresColumns
,parentId
,parentVersion
,pos
,feature.getName()
,feature.getValue()
);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1174,10 +1174,16 @@ public void importProperties(IProperties parent, String id, int version) throws
// then, we import the properties from the database
try ( DBSelect result = new DBSelect(this.databaseEntry.getName(), this.connection,"SELECT name, value FROM "+this.schemaPrefix+"properties WHERE parent_id = ? AND parent_version = ? ORDER BY pos", id, version)) {
while ( result.next() ) {
IProperty prop = IArchimateFactory.eINSTANCE.createProperty();
prop.setKey(result.getString("name"));
prop.setValue(result.getString("value"));
parent.getProperties().add(prop);
String name = result.getString("name");
String value = result.getString("value");
if ( (name != null) && (value != null) ) {
IProperty prop = IArchimateFactory.eINSTANCE.createProperty();
prop.setKey(name);
prop.setValue(value);
parent.getProperties().add(prop);
if ( logger.isTraceEnabled() ) logger.debug(" Property added : key = \""+name+"\" value = \""+value+"\"");
} else
if ( logger.isTraceEnabled() ) logger.debug(" Property ignored : key = \""+name+"\" value = \""+value+"\"");
}
}
}
Expand All @@ -1198,10 +1204,16 @@ public void importFeatures(IFeatures parent, String id, int version) throws SQLE
// then, we import the properties from the database
try ( DBSelect result = new DBSelect(this.databaseEntry.getName(), this.connection,"SELECT name, value FROM "+this.schemaPrefix+"features WHERE parent_id = ? AND parent_version = ? ORDER BY pos", id, version)) {
while ( result.next() ) {
IFeature feature = IArchimateFactory.eINSTANCE.createFeature();
feature.setName(result.getString("name"));
feature.setValue(result.getString("value"));
parent.getFeatures().add(feature);
String name = result.getString("name");
String value = result.getString("value");
if ( (name != null) && (value != null) ) {
IFeature feature = IArchimateFactory.eINSTANCE.createFeature();
feature.setName(result.getString("name"));
feature.setValue(result.getString("value"));
parent.getFeatures().add(feature);
if ( logger.isTraceEnabled() ) logger.debug(" Feature added : key = \""+name+"\" value = \""+value+"\"");
} else
if ( logger.isTraceEnabled() ) logger.debug(" Feature ignored : key = \""+name+"\" value = \""+value+"\"");
}
}
}
Expand Down

0 comments on commit 727aa61

Please sign in to comment.