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