use of com.archimatetool.model.IProperty in project archi by archimatetool.
the class XMLModelExporter method writeProperties.
/**
* Write all property values for a given element
* @param properties
* @param parentElement
* @return The Element or null
*/
Element writeProperties(IProperties properties, Element parentElement) {
Element propertiesElement = new Element(ELEMENT_PROPERTIES, ARCHIMATE3_NAMESPACE);
for (IProperty property : properties.getProperties()) {
String name = property.getKey();
String value = property.getValue();
if (hasSomeText(name)) {
String propertyRefID = fPropertyDefsList.get(name);
if (propertyRefID != null) {
writePropertyValue(propertiesElement, propertyRefID, value);
}
}
}
if (propertiesElement.getChildren().size() > 0) {
parentElement.addContent(propertiesElement);
}
return propertiesElement;
}
use of com.archimatetool.model.IProperty in project archi by archimatetool.
the class XMLModelImporter method addProperties.
// ========================================= Properties ======================================
private void addProperties(IProperties propertiesModel, Element parentElement) {
Element propertiesElement = parentElement.getChild(ELEMENT_PROPERTIES, ARCHIMATE3_NAMESPACE);
if (propertiesElement != null) {
for (Element propertyElement : propertiesElement.getChildren(ELEMENT_PROPERTY, ARCHIMATE3_NAMESPACE)) {
String idref = propertyElement.getAttributeValue(ATTRIBUTE_PROPERTY_IDENTIFIERREF);
if (idref != null) {
String propertyName = fPropertyDefinitionsList.get(idref);
if (propertyName != null) {
String propertyValue = getChildElementText(propertyElement, ELEMENT_VALUE, true);
IProperty property = IArchimateFactory.eINSTANCE.createProperty();
property.setKey(propertyName);
property.setValue(propertyValue);
propertiesModel.getProperties().add(property);
}
}
}
}
}
use of com.archimatetool.model.IProperty in project archi by archimatetool.
the class CSVImporterTests method testDoImportWithUpdatedElements.
@Test
public void testDoImportWithUpdatedElements() throws Exception {
// Set up with original data
importer.doImport(elements1File);
testDoImportPart1();
// Import data that is edited
importer = new CSVImporter(model);
importer.doImport(elements2File);
// Ensure new concepts is empty
assertTrue(importer.newConcepts.isEmpty());
// Ensure new properties is empty
assertTrue(importer.newProperties.isEmpty());
// Model information
assertEquals("Test Model changed", model.getName());
assertEquals("Model Documentation Changed", model.getPurpose());
assertEquals(2, model.getProperties().size());
IArchimateElement element = (IArchimateElement) ArchimateModelUtils.getObjectByID(model, "f00aa5b4");
assertEquals(IArchimatePackage.eINSTANCE.getBusinessActor(), element.eClass());
assertEquals("Name changed", element.getName());
assertEquals("This is the Business Actor\r\nDocumentation\r\nHere \"\"\r\n", element.getDocumentation());
assertEquals(4, element.getProperties().size());
element = (IArchimateElement) ArchimateModelUtils.getObjectByID(model, "d9fe8c17");
assertEquals(IArchimatePackage.eINSTANCE.getBusinessInterface(), element.eClass());
assertEquals("Business Interface", element.getName());
assertEquals("", element.getDocumentation());
assertEquals(0, element.getProperties().size());
IArchimateRelationship relation = (IArchimateRelationship) ArchimateModelUtils.getObjectByID(model, "cdbfc933");
assertEquals(IArchimatePackage.eINSTANCE.getAssignmentRelationship(), relation.eClass());
assertEquals("Assignment relation changed", relation.getName());
assertEquals("Assignment documentation changed", relation.getDocumentation());
assertEquals(0, relation.getProperties().size());
relation = (IArchimateRelationship) ArchimateModelUtils.getObjectByID(model, "5854f8a3");
assertEquals(IArchimatePackage.eINSTANCE.getCompositionRelationship(), relation.eClass());
assertEquals("5854f8a3", relation.getId());
assertEquals("Compo", relation.getName());
assertEquals("Here it is\r\nagain\r\n\r\n\r\n", relation.getDocumentation());
assertEquals(1, relation.getProperties().size());
IProperty property = relation.getProperties().get(0);
assertEquals("This", property.getKey());
assertEquals("value changes", property.getValue());
}
use of com.archimatetool.model.IProperty in project archi by archimatetool.
the class CSVExporterTests method testCreatePropertyRow_Property.
@Test
public void testCreatePropertyRow_Property() {
IArchimateElement element = IArchimateFactory.eINSTANCE.createBusinessActor();
element.setId("1234567a");
IProperty property = IArchimateFactory.eINSTANCE.createProperty();
property.setKey("Some key");
property.setValue("Some value");
element.getProperties().add(property);
assertEquals("\"1234567a\",\"Some key\",\"Some value\"", exporter.createPropertyRow(element.getId(), property));
}
use of com.archimatetool.model.IProperty in project archi by archimatetool.
the class TextRendererTests method addProperty.
static IProperty addProperty(IProperties object, String key, String value) {
IProperty property = IArchimateFactory.eINSTANCE.createProperty(key, value);
object.getProperties().add(property);
return property;
}
Aggregations