Search in sources :

Example 6 with IProfile

use of com.archimatetool.model.IProfile in project archi by archimatetool.

the class ArchimateModelUtilsTests method hasProfileByNameAndType_Model.

@Test
public void hasProfileByNameAndType_Model() {
    IArchimateModel model = IArchimateFactory.eINSTANCE.createArchimateModel();
    model.setDefaults();
    String name1 = "profile";
    String name2 = "profile2";
    String conceptType1 = IArchimatePackage.eINSTANCE.getBusinessActor().getName();
    String conceptType2 = IArchimatePackage.eINSTANCE.getBusinessRole().getName();
    assertFalse(ArchimateModelUtils.hasProfileByNameAndType(model, name1, conceptType1));
    IProfile profile = IArchimateFactory.eINSTANCE.createProfile();
    profile.setName(name1);
    profile.setConceptType(conceptType1);
    model.getProfiles().add(profile);
    assertTrue(ArchimateModelUtils.hasProfileByNameAndType(model, name1, conceptType1));
    // Check case insensitive
    assertTrue(ArchimateModelUtils.hasProfileByNameAndType(model, "ProFile", conceptType1));
    profile.setConceptType(conceptType2);
    assertFalse(ArchimateModelUtils.hasProfileByNameAndType(model, name1, conceptType1));
    // Check case insensitive
    assertFalse(ArchimateModelUtils.hasProfileByNameAndType(model, "ProFile", conceptType1));
    profile.setName(name2);
    profile.setConceptType(conceptType1);
    assertFalse(ArchimateModelUtils.hasProfileByNameAndType(model, name1, conceptType1));
}
Also used : IProfile(com.archimatetool.model.IProfile) IArchimateModel(com.archimatetool.model.IArchimateModel) Test(org.junit.Test)

Example 7 with IProfile

use of com.archimatetool.model.IProfile in project archi by archimatetool.

the class ArchimateModelUtilsTests method findProfilesForConceptType.

@Test
public void findProfilesForConceptType() {
    IArchimateModel model = IArchimateFactory.eINSTANCE.createArchimateModel();
    model.setDefaults();
    IProfile profile1 = IArchimateFactory.eINSTANCE.createProfile();
    profile1.setConceptType(IArchimatePackage.eINSTANCE.getBusinessActor().getName());
    model.getProfiles().add(profile1);
    IProfile profile2 = IArchimateFactory.eINSTANCE.createProfile();
    profile2.setConceptType(IArchimatePackage.eINSTANCE.getBusinessActor().getName());
    model.getProfiles().add(profile2);
    IProfile profile3 = IArchimateFactory.eINSTANCE.createProfile();
    profile3.setConceptType(IArchimatePackage.eINSTANCE.getBusinessRole().getName());
    model.getProfiles().add(profile3);
    List<IProfile> profiles = ArchimateModelUtils.findProfilesForConceptType(model, IArchimatePackage.eINSTANCE.getBusinessActor());
    assertEquals(2, profiles.size());
    assertSame(profile1, profiles.get(0));
    assertSame(profile2, profiles.get(1));
    profiles = ArchimateModelUtils.findProfilesForConceptType(model, IArchimatePackage.eINSTANCE.getBusinessRole());
    assertEquals(1, profiles.size());
    assertSame(profile3, profiles.get(0));
    profiles = ArchimateModelUtils.findProfilesForConceptType(model, IArchimatePackage.eINSTANCE.getBusinessEvent());
    assertEquals(0, profiles.size());
}
Also used : IProfile(com.archimatetool.model.IProfile) IArchimateModel(com.archimatetool.model.IArchimateModel) Test(org.junit.Test)

Example 8 with IProfile

use of com.archimatetool.model.IProfile in project archi by archimatetool.

the class ProfileTests method testGetCopy.

@Test
public void testGetCopy() {
    profile.setName("name");
    profile.setConceptType(IArchimatePackage.eINSTANCE.getBusinessActor().getName());
    profile.setImagePath("somePath");
    profile.setSpecialization(false);
    profile.getFeatures().add(IArchimateFactory.eINSTANCE.createFeature());
    IProfile copy = (IProfile) profile.getCopy();
    assertNotSame(profile, copy);
    assertNotNull(copy.getId());
    assertNotEquals(profile.getId(), copy.getId());
    assertEquals(profile.getName(), copy.getName());
    assertEquals(profile.getConceptType(), copy.getConceptType());
    assertEquals(profile.getImagePath(), copy.getImagePath());
    assertEquals(profile.isSpecialization(), copy.isSpecialization());
    assertNotSame(profile.getFeatures(), copy.getFeatures());
    assertEquals(profile.getFeatures().size(), copy.getFeatures().size());
}
Also used : IProfile(com.archimatetool.model.IProfile) Test(org.junit.Test)

Example 9 with IProfile

use of com.archimatetool.model.IProfile in project archi by archimatetool.

the class CSVImporter method setProfileForNewConcept.

// -------------------------------- Profile Helpers --------------------------------
/**
 * Set a profile for a newly created concept
 */
private void setProfileForNewConcept(IArchimateConcept newConcept, String specializationName) {
    // Do we have a matching Profile in the model?
    IProfile profile = findModelProfile(specializationName, newConcept.eClass().getName());
    // No, so create a new Profile and add it to the lookup list
    if (profile == null) {
        profile = createNewProfile(specializationName, newConcept.eClass().getName());
    }
    // Assign it
    newConcept.getProfiles().add(profile);
}
Also used : IProfile(com.archimatetool.model.IProfile)

Example 10 with IProfile

use of com.archimatetool.model.IProfile in project archi by archimatetool.

the class CSVExporter method createElementRow.

/**
 * Create a String Row for an Element
 */
String createElementRow(IArchimateElement element) {
    StringBuffer sb = new StringBuffer();
    // ID
    String id = element.getId();
    sb.append(surroundWithQuotes(id));
    sb.append(fDelimiter);
    // Class
    sb.append(surroundWithQuotes(element.eClass().getName()));
    sb.append(fDelimiter);
    // Name
    String name = normalise(element.getName());
    sb.append(surroundWithQuotes(name));
    sb.append(fDelimiter);
    // Documentation
    String documentation = normalise(element.getDocumentation());
    sb.append(surroundWithQuotes(documentation));
    sb.append(fDelimiter);
    // Specialization
    IProfile profile = element.getPrimaryProfile();
    // $NON-NLS-1$
    String specialization = normalise(profile != null ? profile.getName() : "");
    sb.append(surroundWithQuotes(specialization));
    return sb.toString();
}
Also used : IProfile(com.archimatetool.model.IProfile)

Aggregations

IProfile (com.archimatetool.model.IProfile)34 Test (org.junit.Test)11 IArchimateModel (com.archimatetool.model.IArchimateModel)7 IArchimateConcept (com.archimatetool.model.IArchimateConcept)6 IArchimateElement (com.archimatetool.model.IArchimateElement)6 IDiagramModel (com.archimatetool.model.IDiagramModel)4 EObject (org.eclipse.emf.ecore.EObject)4 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)4 IArchimateModelObject (com.archimatetool.model.IArchimateModelObject)3 IArchimateRelationship (com.archimatetool.model.IArchimateRelationship)3 IDiagramModelArchimateObject (com.archimatetool.model.IDiagramModelArchimateObject)3 IProfiles (com.archimatetool.model.IProfiles)3 List (java.util.List)3 IArchiveManager (com.archimatetool.editor.model.IArchiveManager)2 IDiagramModelArchimateConnection (com.archimatetool.model.IDiagramModelArchimateConnection)2 IFolder (com.archimatetool.model.IFolder)2 ArrayList (java.util.ArrayList)2 CommandStack (org.eclipse.gef.commands.CommandStack)2 CompoundCommand (org.eclipse.gef.commands.CompoundCommand)2 IStructuredContentProvider (org.eclipse.jface.viewers.IStructuredContentProvider)2