Search in sources :

Example 26 with IProperty

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;
}
Also used : IProperty(com.archimatetool.model.IProperty) IArchimateElement(com.archimatetool.model.IArchimateElement) Element(org.jdom2.Element)

Example 27 with IProperty

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);
                }
            }
        }
    }
}
Also used : IProperty(com.archimatetool.model.IProperty) Element(org.jdom2.Element) IArchimateElement(com.archimatetool.model.IArchimateElement)

Example 28 with IProperty

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());
}
Also used : IProperty(com.archimatetool.model.IProperty) IArchimateElement(com.archimatetool.model.IArchimateElement) IArchimateRelationship(com.archimatetool.model.IArchimateRelationship) Test(org.junit.Test)

Example 29 with IProperty

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));
}
Also used : IProperty(com.archimatetool.model.IProperty) IArchimateElement(com.archimatetool.model.IArchimateElement) Test(org.junit.Test)

Example 30 with IProperty

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;
}
Also used : IProperty(com.archimatetool.model.IProperty)

Aggregations

IProperty (com.archimatetool.model.IProperty)32 EObject (org.eclipse.emf.ecore.EObject)10 Test (org.junit.Test)9 IArchimateElement (com.archimatetool.model.IArchimateElement)5 IProperties (com.archimatetool.model.IProperties)5 IArchimateModel (com.archimatetool.model.IArchimateModel)4 IArchimateModelObject (com.archimatetool.model.IArchimateModelObject)4 CompoundCommand (org.eclipse.gef.commands.CompoundCommand)4 Point (org.eclipse.swt.graphics.Point)4 HashSet (java.util.HashSet)3 Matcher (java.util.regex.Matcher)3 EObjectNonNotifyingCompoundCommand (com.archimatetool.editor.model.commands.EObjectNonNotifyingCompoundCommand)2 IArchimateConcept (com.archimatetool.model.IArchimateConcept)2 Command (org.eclipse.gef.commands.Command)2 ISelection (org.eclipse.jface.viewers.ISelection)2 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)2 Element (org.jdom2.Element)2 CSVParseException (com.archimatetool.csv.CSVParseException)1 EObjectFeatureCommand (com.archimatetool.editor.model.commands.EObjectFeatureCommand)1 IPreferenceConstants (com.archimatetool.editor.preferences.IPreferenceConstants)1