Search in sources :

Example 16 with IProfile

use of com.archimatetool.model.IProfile in project archi-modelrepository-plugin by archi-contribs.

the class GraficoModelImporter method resolveProxies.

/**
 * Iterate through all model objects, and resolve proxies on known classes
 */
private void resolveProxies() {
    fUnresolvedObjects = null;
    for (Iterator<EObject> iter = fModel.eAllContents(); iter.hasNext(); ) {
        EObject eObject = iter.next();
        if (eObject instanceof IArchimateConcept) {
            // Resolve proxies for profiles
            IArchimateConcept concept = (IArchimateConcept) eObject;
            EList<IProfile> profiles = concept.getProfiles();
            // Assumption: most concepts don't have profiles so checking for empty has a positive impact on performance
            if (!profiles.isEmpty()) {
                ListIterator<IProfile> iterator = profiles.listIterator();
                while (iterator.hasNext()) {
                    IProfile profile = iterator.next();
                    iterator.set((IProfile) resolve(profile, concept));
                }
            }
        }
        if (eObject instanceof IArchimateRelationship) {
            // Resolve proxies for Relations
            IArchimateRelationship relation = (IArchimateRelationship) eObject;
            relation.setSource((IArchimateConcept) resolve(relation.getSource(), relation));
            relation.setTarget((IArchimateConcept) resolve(relation.getTarget(), relation));
        } else if (eObject instanceof IDiagramModelArchimateObject) {
            // Resolve proxies for Elements
            IDiagramModelArchimateObject element = (IDiagramModelArchimateObject) eObject;
            element.setArchimateElement((IArchimateElement) resolve(element.getArchimateElement(), element));
        } else if (eObject instanceof IDiagramModelArchimateConnection) {
            // Resolve proxies for Connections
            IDiagramModelArchimateConnection archiConnection = (IDiagramModelArchimateConnection) eObject;
            archiConnection.setArchimateRelationship((IArchimateRelationship) resolve(archiConnection.getArchimateRelationship(), archiConnection));
        } else if (eObject instanceof IDiagramModelReference) {
            // Resolve proxies for Model References
            IDiagramModelReference element = (IDiagramModelReference) eObject;
            element.setReferencedModel((IDiagramModel) resolve(element.getReferencedModel(), element));
        }
    }
}
Also used : IDiagramModelReference(com.archimatetool.model.IDiagramModelReference) IDiagramModel(com.archimatetool.model.IDiagramModel) EObject(org.eclipse.emf.ecore.EObject) IDiagramModelArchimateConnection(com.archimatetool.model.IDiagramModelArchimateConnection) IArchimateConcept(com.archimatetool.model.IArchimateConcept) IArchimateElement(com.archimatetool.model.IArchimateElement) IArchimateRelationship(com.archimatetool.model.IArchimateRelationship) IDiagramModelArchimateObject(com.archimatetool.model.IDiagramModelArchimateObject) IProfile(com.archimatetool.model.IProfile)

Example 17 with IProfile

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

the class CSVImporter method updateProfileForConcept.

/**
 * Update a profile for an existing concept
 */
private void updateProfileForConcept(IArchimateConcept concept, String specializationName) {
    // If there is a specialization name
    if (StringUtils.isSet(specializationName)) {
        // If the concept doesn't have this Profile by name and type...
        if (!ArchimateModelUtils.hasProfileByNameAndType(concept.getProfiles(), specializationName, concept.eClass().getName())) {
            // See if there is a matching Profile in the model or lookup list
            IProfile profile = findModelProfile(specializationName, concept.eClass().getName());
            // No, so create a new Profile and add it to the lookup list
            if (profile == null) {
                profile = createNewProfile(specializationName, concept.eClass().getName());
            }
            // Store the concept in the list of updated profiles
            updatedProfiles.put(concept, profile);
        }
    } else // If there is no specialization name then remove concept's existing Profile if present
    if (concept.getPrimaryProfile() != null) {
        // Store null value in updated element
        updatedProfiles.put(concept, null);
    }
}
Also used : IProfile(com.archimatetool.model.IProfile)

Example 18 with IProfile

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

the class CSVImporter method createNewProfile.

/**
 * Create a new profile and add it to the lookup list
 */
private IProfile createNewProfile(String specializationName, String conceptType) {
    IProfile profile = IArchimateFactory.eINSTANCE.createProfile();
    profile.setName(specializationName);
    profile.setConceptType(conceptType);
    // Add it to the lookup list
    newProfiles.add(profile);
    return profile;
}
Also used : IProfile(com.archimatetool.model.IProfile)

Example 19 with IProfile

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

the class CSVExporter method createRelationshipRow.

/**
 * Create a String Row for a Relationship
 */
String createRelationshipRow(IArchimateRelationship relationship) {
    StringBuffer sb = new StringBuffer();
    // ID
    String id = relationship.getId();
    sb.append(surroundWithQuotes(id));
    sb.append(fDelimiter);
    // Class
    sb.append(surroundWithQuotes(relationship.eClass().getName()));
    sb.append(fDelimiter);
    // Name
    String name = normalise(relationship.getName());
    sb.append(surroundWithQuotes(name));
    sb.append(fDelimiter);
    // Documentation
    String documentation = normalise(relationship.getDocumentation());
    sb.append(surroundWithQuotes(documentation));
    sb.append(fDelimiter);
    // Source
    if (relationship.getSource() != null) {
        String sourceID = relationship.getSource().getId();
        sb.append(surroundWithQuotes(sourceID));
    } else {
        // $NON-NLS-1$
        sb.append("\"\"");
    }
    sb.append(fDelimiter);
    // Target
    if (relationship.getTarget() != null) {
        String targetID = relationship.getTarget().getId();
        sb.append(surroundWithQuotes(targetID));
    } else {
        // $NON-NLS-1$
        sb.append("\"\"");
    }
    sb.append(fDelimiter);
    // Specialization
    IProfile profile = relationship.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)

Example 20 with IProfile

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

the class SpecializationRenderer method render.

@Override
public String render(IArchimateModelObject object, String text) {
    Matcher matcher = NAME_PATTERN.matcher(text);
    while (matcher.find()) {
        String prefix = matcher.group(1);
        String replacement = "";
        IArchimateModelObject refObject = getObjectFromPrefix(object, prefix);
        if (refObject instanceof IProfiles) {
            IProfile profile = ((IProfiles) refObject).getPrimaryProfile();
            if (profile != null) {
                replacement = profile.getName();
            }
        }
        text = text.replace(matcher.group(), replacement);
    }
    return text;
}
Also used : IArchimateModelObject(com.archimatetool.model.IArchimateModelObject) IProfiles(com.archimatetool.model.IProfiles) Matcher(java.util.regex.Matcher) 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