Search in sources :

Example 1 with IProfiles

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

the class ModelChecker method checkAll.

/**
 * @return True if OK, false if not OK
 */
public boolean checkAll() {
    fErrorMessages = new ArrayList<String>();
    // Don't model check
    if (NO_MODELCHECK) {
        return true;
    }
    // Instance count map
    Map<IArchimateConcept, Integer> dmcMap = new HashMap<IArchimateConcept, Integer>();
    // Iterate through all objects in the model...
    for (Iterator<EObject> iter = fModel.eAllContents(); iter.hasNext(); ) {
        EObject eObject = iter.next();
        // Identifier
        if (eObject instanceof IIdentifier) {
            fErrorMessages.addAll(checkHasIdentifier((IIdentifier) eObject));
        }
        // Relation
        if (eObject instanceof IArchimateRelationship) {
            fErrorMessages.addAll(checkRelationship((IArchimateRelationship) eObject));
        }
        // Diagram Model Object
        if (eObject instanceof IDiagramModelArchimateObject) {
            fErrorMessages.addAll(checkDiagramModelArchimateObject((IDiagramModelArchimateObject) eObject));
            incrementInstanceCount((IDiagramModelArchimateComponent) eObject, dmcMap);
        }
        // Diagram Model Connection
        if (eObject instanceof IDiagramModelArchimateConnection) {
            fErrorMessages.addAll(checkDiagramModelArchimateConnection((IDiagramModelArchimateConnection) eObject));
            incrementInstanceCount((IDiagramModelArchimateConnection) eObject, dmcMap);
        }
        // Folder
        if (eObject instanceof IFolder) {
            fErrorMessages.addAll(checkFolder((IFolder) eObject));
        }
        // Profiles
        if (eObject instanceof IProfiles) {
            fErrorMessages.addAll(checkProfiles((IProfiles) eObject));
        }
    }
    // Now check Diagram Model Object reference count
    fErrorMessages.addAll(checkDiagramComponentInstanceCount(dmcMap));
    return fErrorMessages.isEmpty();
}
Also used : IIdentifier(com.archimatetool.model.IIdentifier) HashMap(java.util.HashMap) IDiagramModelArchimateConnection(com.archimatetool.model.IDiagramModelArchimateConnection) IProfiles(com.archimatetool.model.IProfiles) EObject(org.eclipse.emf.ecore.EObject) IArchimateConcept(com.archimatetool.model.IArchimateConcept) IArchimateRelationship(com.archimatetool.model.IArchimateRelationship) IDiagramModelArchimateObject(com.archimatetool.model.IDiagramModelArchimateObject) IFolder(com.archimatetool.model.IFolder)

Example 2 with IProfiles

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

the class ArchimateModelUtils method findProfilesUsage.

/**
 * @return A map of all references of all Profiles in the given model.
 *         This method is many times faster than calling findProfileUsage(IProfile) repeatedly
 */
public static Map<IProfile, List<IProfiles>> findProfilesUsage(IArchimateModel model) {
    Map<IProfile, List<IProfiles>> map = new HashMap<>();
    // Iterate through all model contents
    for (Iterator<EObject> iter = model.eAllContents(); iter.hasNext(); ) {
        EObject eObject = iter.next();
        // This is a concept potentially containing profile references
        if (eObject instanceof IProfiles) {
            // Iterate through the profiles
            for (IProfile profile : ((IProfiles) eObject).getProfiles()) {
                // Get the list from the map
                List<IProfiles> list = map.get(profile);
                // Create and add a new list if needed
                if (list == null) {
                    list = new ArrayList<>();
                    map.put(profile, list);
                }
                // Add the concept to the list
                list.add((IProfiles) eObject);
            }
        }
    }
    return map;
}
Also used : IProfiles(com.archimatetool.model.IProfiles) HashMap(java.util.HashMap) EObject(org.eclipse.emf.ecore.EObject) ArrayList(java.util.ArrayList) List(java.util.List) IProfile(com.archimatetool.model.IProfile)

Example 3 with IProfiles

use of com.archimatetool.model.IProfiles 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)

Example 4 with IProfiles

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

the class FieldDataFactory method getFieldValue.

public static Object getFieldValue(Object dataElement, String fieldName) {
    if (THIS.equals(fieldName)) {
        return dataElement;
    }
    if (ID.equals(fieldName) && dataElement instanceof IIdentifier) {
        return ((IIdentifier) dataElement).getId();
    }
    if (NAME.equals(fieldName) && dataElement instanceof INameable) {
        String name = ((INameable) dataElement).getName();
        if (name == null || "".equals(name)) {
            name = ArchiLabelProvider.INSTANCE.getDefaultName(((EObject) dataElement).eClass());
        }
        return name;
    }
    if (TYPE.equals(fieldName) && dataElement instanceof EObject) {
        // Class name
        String value = ArchiLabelProvider.INSTANCE.getDefaultName(((EObject) dataElement).eClass());
        // Profile Name
        if (dataElement instanceof IProfiles && ((IProfiles) dataElement).getPrimaryProfile() != null) {
            value += " (" + ((IProfiles) dataElement).getPrimaryProfile().getName() + ")";
        }
        return value;
    }
    if (DOCUMENTATION.equals(fieldName) && dataElement instanceof IDocumentable) {
        String s = ((IDocumentable) dataElement).getDocumentation();
        return StringUtils.isSet(s) ? s : null;
    }
    if (PURPOSE.equals(fieldName) && dataElement instanceof IArchimateModel) {
        String s = ((IArchimateModel) dataElement).getPurpose();
        return StringUtils.isSet(s) ? s : null;
    }
    if (RELATION_SOURCE.equals(fieldName) && dataElement instanceof IArchimateRelationship) {
        IArchimateRelationship relation = (IArchimateRelationship) dataElement;
        IArchimateConcept source = relation.getSource();
        String s = source.getName();
        return StringUtils.isSet(s) ? s : null;
    }
    if (RELATION_TARGET.equals(fieldName) && dataElement instanceof IArchimateRelationship) {
        IArchimateRelationship relation = (IArchimateRelationship) dataElement;
        IArchimateConcept target = relation.getTarget();
        String s = target.getName();
        return StringUtils.isSet(s) ? s : null;
    }
    if (INFLUENCE_STRENGTH.equals(fieldName) && dataElement instanceof IInfluenceRelationship) {
        String s = ((IInfluenceRelationship) dataElement).getStrength();
        return StringUtils.isSet(s) ? s : null;
    }
    if (ACCESS_TYPE.equals(fieldName) && dataElement instanceof IAccessRelationship) {
        return ((IAccessRelationship) dataElement).getAccessType();
    }
    return null;
}
Also used : IDocumentable(com.archimatetool.model.IDocumentable) IInfluenceRelationship(com.archimatetool.model.IInfluenceRelationship) IIdentifier(com.archimatetool.model.IIdentifier) IProfiles(com.archimatetool.model.IProfiles) INameable(com.archimatetool.model.INameable) EObject(org.eclipse.emf.ecore.EObject) IArchimateConcept(com.archimatetool.model.IArchimateConcept) IArchimateRelationship(com.archimatetool.model.IArchimateRelationship) IArchimateModel(com.archimatetool.model.IArchimateModel) IAccessRelationship(com.archimatetool.model.IAccessRelationship)

Example 5 with IProfiles

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

the class ProfilesManagerDialog method okPressed.

/**
 * OK was pressed, so see what was added, changed or deleted and execute the Commands
 */
@Override
protected void okPressed() {
    super.okPressed();
    CompoundCommand compoundCmd = new CompoundCommand(Messages.ProfilesManagerDialog_16);
    // Iterate thru our temp list of Profiles
    for (IProfile profile : fProfilesTemp.values()) {
        // Is this a copy of the original?
        if (fProfilesModel.containsKey(profile.getId())) {
            IProfile profileOriginal = fProfilesModel.get(profile.getId());
            // The Profile has been edited
            if (!EcoreUtil.equals(profileOriginal, profile)) {
                List<IProfiles> usages = fProfilesUsage.get(profileOriginal.getId());
                compoundCmd.add(new ChangeProfileCommand(profileOriginal, profile, usages));
            }
        } else // A new Profile was added
        {
            compoundCmd.add(new AddListMemberCommand<IProfile>(fArchimateModel.getProfiles(), profile));
        }
    }
    // Iterate thru model's Profiles and compare with our temp list to see if any Profiles were deleted
    for (IProfile profile : fArchimateModel.getProfiles()) {
        if (!fProfilesTemp.containsKey(profile.getId())) {
            List<IProfiles> usages = fProfilesUsage.get(profile.getId());
            compoundCmd.add(new DeleteProfileCommand(profile, usages));
        }
    }
    // Execute the Commands
    CommandStack stack = (CommandStack) fArchimateModel.getAdapter(CommandStack.class);
    stack.execute(compoundCmd);
}
Also used : CommandStack(org.eclipse.gef.commands.CommandStack) IProfiles(com.archimatetool.model.IProfiles) IProfile(com.archimatetool.model.IProfile) CompoundCommand(org.eclipse.gef.commands.CompoundCommand)

Aggregations

IProfiles (com.archimatetool.model.IProfiles)5 IProfile (com.archimatetool.model.IProfile)3 EObject (org.eclipse.emf.ecore.EObject)3 IArchimateConcept (com.archimatetool.model.IArchimateConcept)2 IArchimateRelationship (com.archimatetool.model.IArchimateRelationship)2 IIdentifier (com.archimatetool.model.IIdentifier)2 HashMap (java.util.HashMap)2 IAccessRelationship (com.archimatetool.model.IAccessRelationship)1 IArchimateModel (com.archimatetool.model.IArchimateModel)1 IArchimateModelObject (com.archimatetool.model.IArchimateModelObject)1 IDiagramModelArchimateConnection (com.archimatetool.model.IDiagramModelArchimateConnection)1 IDiagramModelArchimateObject (com.archimatetool.model.IDiagramModelArchimateObject)1 IDocumentable (com.archimatetool.model.IDocumentable)1 IFolder (com.archimatetool.model.IFolder)1 IInfluenceRelationship (com.archimatetool.model.IInfluenceRelationship)1 INameable (com.archimatetool.model.INameable)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Matcher (java.util.regex.Matcher)1 CommandStack (org.eclipse.gef.commands.CommandStack)1