use of com.archimatetool.model.IArchimateRelationship in project archi by archimatetool.
the class Validator method validate.
/**
* @return The list of Issue Categories and Issues
*/
public List<Object> validate() {
if (fModel == null) {
return null;
}
// Collect interesting objects
fElements = new ArrayList<IArchimateElement>();
fRelations = new ArrayList<IArchimateRelationship>();
fViews = new ArrayList<IArchimateDiagramModel>();
for (Iterator<EObject> iter = fModel.eAllContents(); iter.hasNext(); ) {
EObject eObject = iter.next();
if (eObject instanceof IArchimateRelationship) {
fRelations.add((IArchimateRelationship) eObject);
} else if (eObject instanceof IArchimateElement) {
fElements.add((IArchimateElement) eObject);
} else if (eObject instanceof IArchimateDiagramModel) {
fViews.add((IArchimateDiagramModel) eObject);
}
}
// Analyse
List<Object> result = new ArrayList<Object>();
fErrorList = new ArrayList<ErrorType>();
fWarningList = new ArrayList<WarningType>();
fAdviceList = new ArrayList<AdviceType>();
// ------------------ Checkers -----------------------------
IPreferenceStore store = ArchiHammerPlugin.INSTANCE.getPreferenceStore();
// Invalid Relations
if (store.getBoolean(IPreferenceConstants.PREFS_HAMMER_CHECK_INVALID_RELATIONS)) {
collectIssues(new InvalidRelationsChecker(getArchimateRelationships()));
}
// Unused Elements
if (store.getBoolean(IPreferenceConstants.PREFS_HAMMER_CHECK_UNUSED_ELEMENTS)) {
collectIssues(new UnusedElementsChecker(getArchimateElements()));
}
// Unused Relations
if (store.getBoolean(IPreferenceConstants.PREFS_HAMMER_CHECK_UNUSED_RELATIONS)) {
collectIssues(new UnusedRelationsChecker(getArchimateRelationships()));
}
// Empty Views
if (store.getBoolean(IPreferenceConstants.PREFS_HAMMER_CHECK_EMPTY_VIEWS)) {
collectIssues(new EmptyViewsChecker(getArchimateViews()));
}
// Components in wrong Viewpoints
if (store.getBoolean(IPreferenceConstants.PREFS_HAMMER_CHECK_VIEWPOINT)) {
collectIssues(new ViewpointChecker(getArchimateViews()));
}
// Nested elements
if (store.getBoolean(IPreferenceConstants.PREFS_HAMMER_CHECK_NESTING)) {
collectIssues(new NestedElementsChecker(getArchimateViews()));
}
// Possible Duplicates
if (store.getBoolean(IPreferenceConstants.PREFS_HAMMER_CHECK_DUPLICATE_ELEMENTS)) {
collectIssues(new DuplicateElementChecker(getArchimateElements()));
}
// Junctions
if (store.getBoolean(IPreferenceConstants.PREFS_HAMMER_CHECK_JUNCTIONS)) {
collectIssues(new JunctionsChecker(getArchimateElements()));
}
if (!fErrorList.isEmpty()) {
IIssueCategory category = new ErrorsCategory(fErrorList);
result.add(category);
}
if (!fWarningList.isEmpty()) {
IIssueCategory category = new WarningsCategory(fWarningList);
result.add(category);
}
if (!fAdviceList.isEmpty()) {
IIssueCategory category = new AdviceCategory(fAdviceList);
result.add(category);
}
if (result.isEmpty()) {
result.add(new OKType());
}
return result;
}
use of com.archimatetool.model.IArchimateRelationship in project archi by archimatetool.
the class JunctionsChecker method findBogusJunctions.
List<IIssue> findBogusJunctions() {
List<IIssue> issues = new ArrayList<IIssue>();
for (IArchimateElement element : fArchimateElements) {
if (element instanceof IJunction) {
IArchimateRelationship rel = null;
for (IArchimateRelationship relation : ArchimateModelUtils.getAllRelationshipsForConcept(element)) {
if (rel != null && rel.eClass() != relation.eClass()) {
String name = ArchiLabelProvider.INSTANCE.getLabel(element);
String description = NLS.bind(DESCRIPTION, name);
String explanation = NLS.bind(EXPLANATION, name);
IIssue issue = new ErrorType(NAME, description, explanation, element);
issues.add(issue);
break;
}
rel = relation;
}
}
}
return issues;
}
use of com.archimatetool.model.IArchimateRelationship in project archi by archimatetool.
the class TreeViewpointFilterProvider method getTextColor.
/**
* If the element is disallowed in a Viewpoint grey it out
* @param element
* @return Color or null
*/
Color getTextColor(Object element) {
if (isActive() && fActiveDiagramModel != null && element instanceof IArchimateConcept) {
String id = fActiveDiagramModel.getViewpoint();
IViewpoint viewpoint = ViewpointManager.INSTANCE.getViewpoint(id);
if (viewpoint != null) {
// From same model as active diagram
IArchimateModel model = ((IArchimateConcept) element).getArchimateModel();
if (model == fActiveDiagramModel.getArchimateModel()) {
if (element instanceof IArchimateRelationship) {
IArchimateConcept source = ((IArchimateRelationship) element).getSource();
IArchimateConcept target = ((IArchimateRelationship) element).getTarget();
if (!viewpoint.isAllowedConcept(source.eClass()) || !viewpoint.isAllowedConcept(target.eClass())) {
return ColorFactory.get(128, 128, 128);
}
} else if (element instanceof IArchimateElement) {
if (!viewpoint.isAllowedConcept(((IArchimateElement) element).eClass())) {
return ColorFactory.get(128, 128, 128);
}
}
}
}
}
return null;
}
use of com.archimatetool.model.IArchimateRelationship in project archi by archimatetool.
the class UnusedRelationsChecker method findUnusedRelations.
List<IIssue> findUnusedRelations() {
List<IIssue> issues = new ArrayList<IIssue>();
for (IArchimateRelationship relation : fRelations) {
if (!DiagramModelUtils.isArchimateConceptReferencedInDiagrams(relation)) {
String name = ArchiLabelProvider.INSTANCE.getLabel(relation);
String description = NLS.bind(DESCRIPTION, name);
String explanation = NLS.bind(EXPLANATION, name);
IIssue issue = new WarningType(NAME, description, explanation, relation);
issues.add(issue);
}
}
return issues;
}
use of com.archimatetool.model.IArchimateRelationship in project archi by archimatetool.
the class ArchimateModelUtilsTests method testHasDirectRelationship.
/*
* NOTE - Tests for ArchimateModelUtils.isValidRelationshipStart() and ArchimateModelUtils.isValidRelationship() are in ViewpointTests
*/
@Test
public void testHasDirectRelationship() {
IArchimateConcept sourceConcept = IArchimateFactory.eINSTANCE.createBusinessActor();
IArchimateConcept someTarget = IArchimateFactory.eINSTANCE.createBusinessRole();
IArchimateRelationship relationship = IArchimateFactory.eINSTANCE.createAssociationRelationship();
assertFalse(ArchimateModelUtils.hasDirectRelationship(sourceConcept, relationship));
assertFalse(ArchimateModelUtils.hasDirectRelationship(relationship, sourceConcept));
relationship.connect(sourceConcept, someTarget);
assertTrue(ArchimateModelUtils.hasDirectRelationship(sourceConcept, relationship));
assertTrue(ArchimateModelUtils.hasDirectRelationship(relationship, sourceConcept));
relationship.connect(someTarget, sourceConcept);
assertTrue(ArchimateModelUtils.hasDirectRelationship(sourceConcept, relationship));
assertTrue(ArchimateModelUtils.hasDirectRelationship(relationship, sourceConcept));
}
Aggregations