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();
}
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;
}
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;
}
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;
}
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);
}
Aggregations