use of com.archimatetool.model.IArchimateConcept in project archi by archimatetool.
the class CSVExporter method writeElementsInFolder.
/**
* Write all elements in a given folder and its child folders to Writer
*/
private void writeElementsInFolder(Writer writer, IFolder folder) throws IOException {
if (folder == null) {
return;
}
List<IArchimateConcept> concepts = getConcepts(folder);
sort(concepts);
for (IArchimateConcept concept : concepts) {
if (concept instanceof IArchimateElement) {
writer.write(CRLF);
writer.write(createElementRow((IArchimateElement) concept));
}
}
}
use of com.archimatetool.model.IArchimateConcept in project archi by archimatetool.
the class CSVExporter method writeProperties.
/**
* Write All Properties
*/
private void writeProperties(File file) throws IOException {
// Are there any to write?
if (!fWriteEmptyFile && !hasProperties()) {
return;
}
Writer writer = createOutputStreamWriter(file);
// Write BOM
writeBOM(writer);
// Write Header
String header = createHeader(PROPERTIES_HEADER);
writer.write(header);
// Write Model Properties
for (IProperty property : fModel.getProperties()) {
writer.write(CRLF);
writer.write(createPropertyRow(fModel.getId(), property));
}
// Write Element and Relationship Properties
for (Iterator<EObject> iter = fModel.eAllContents(); iter.hasNext(); ) {
EObject eObject = iter.next();
if (eObject instanceof IArchimateConcept) {
IArchimateConcept concept = (IArchimateConcept) eObject;
for (IProperty property : concept.getProperties()) {
writer.write(CRLF);
writer.write(createPropertyRow(concept.getId(), property));
}
// Write special attributes as properties
writeSpecialProperties(writer, concept);
}
}
writer.close();
}
use of com.archimatetool.model.IArchimateConcept in project archi by archimatetool.
the class CSVExporter method writeRelationships.
/**
* Write All Relationships
*/
private void writeRelationships(File file) throws IOException {
List<IArchimateConcept> concepts = getConcepts(fModel.getFolder(FolderType.RELATIONS));
sort(concepts);
// Are there any to write?
if (!fWriteEmptyFile && concepts.isEmpty()) {
return;
}
Writer writer = createOutputStreamWriter(file);
// Write BOM
writeBOM(writer);
// Write Header
String header = createHeader(RELATIONSHIPS_HEADER);
writer.write(header);
// Write Relationships
for (IArchimateConcept concept : concepts) {
if (concept instanceof IArchimateRelationship) {
writer.write(CRLF);
writer.write(createRelationshipRow((IArchimateRelationship) concept));
}
}
writer.close();
}
use of com.archimatetool.model.IArchimateConcept in project archi by archimatetool.
the class CSVImporter method createPropertyFromRecord.
/**
* Create a Property from a given CSVRecord
*/
private void createPropertyFromRecord(CSVRecord csvRecord) throws CSVParseException {
// ID
String id = csvRecord.get(0);
if (!StringUtils.isSet(id)) {
throw new CSVParseException(Messages.CSVImporter_6);
} else {
checkIDForInvalidCharacters(id);
}
// Find referenced concept in newly created list
IProperties propertiesObject = newConcepts.get(id);
// Not found, check if it's referencing an existing element in the model
if (propertiesObject == null) {
EObject eObject = ArchimateModelUtils.getObjectByID(fModel, id);
if (eObject instanceof IProperties) {
propertiesObject = (IProperties) eObject;
}
}
// Not found, check if it's referencing the model
if (propertiesObject == null && id.equals(modelID)) {
propertiesObject = fModel;
}
// Not found at all
if (propertiesObject == null) {
throw new CSVParseException(Messages.CSVImporter_7 + id);
}
String key = normalise(csvRecord.get(1));
String value = normalise(csvRecord.get(2));
// Special properties for relationship attributes
if (INFLUENCE_STRENGTH.equals(key) && propertiesObject instanceof IInfluenceRelationship) {
storeUpdatedConceptFeature((IArchimateConcept) propertiesObject, IArchimatePackage.Literals.INFLUENCE_RELATIONSHIP__STRENGTH, value);
return;
} else if (ACCESS_TYPE.equals(key) && propertiesObject instanceof IAccessRelationship) {
int newvalue = ACCESS_TYPES.indexOf(value);
storeUpdatedConceptFeature((IArchimateConcept) propertiesObject, IArchimatePackage.Literals.ACCESS_RELATIONSHIP__ACCESS_TYPE, newvalue);
return;
}
// Is there already a property with this key?
IProperty property = getProperty(propertiesObject, key);
if (property != null) {
updatedProperties.put(property, value);
} else // No, create new one
{
property = IArchimateFactory.eINSTANCE.createProperty();
property.setKey(key);
property.setValue(value);
newProperties.put(property, propertiesObject);
}
}
use of com.archimatetool.model.IArchimateConcept in project archi by archimatetool.
the class MagicConnectionCreationTool method addElementActions.
private void addElementActions(Menu menu, String menuText, IDiagramModelArchimateComponent sourceDiagramModelComponent, EClass[] list) {
MenuItem item = new MenuItem(menu, SWT.CASCADE);
item.setText(menuText);
Menu subMenu = new Menu(item);
item.setMenu(subMenu);
IArchimateConcept sourceConcept = sourceDiagramModelComponent.getArchimateConcept();
for (EClass type : list) {
// Check if allowed by Viewpoint
if (!isAllowedTargetTypeInViewpoint(sourceDiagramModelComponent, type)) {
continue;
}
MenuItem subItem = addElementAction(subMenu, type);
Menu childSubMenu = new Menu(subItem);
subItem.setMenu(childSubMenu);
for (EClass typeRel : ArchimateModelUtils.getRelationsClasses()) {
if (ArchimateModelUtils.isValidRelationship(sourceConcept.eClass(), type, typeRel)) {
addConnectionAction(childSubMenu, typeRel, false);
}
}
if (childSubMenu.getItemCount() == 0) {
// Nothing there
subItem.dispose();
}
}
if (subMenu.getItemCount() == 0) {
// Nothing there
item.dispose();
}
}
Aggregations