Skip to content

Commit

Permalink
Access Type of Components
Browse files Browse the repository at this point in the history
  • Loading branch information
dfuchss committed Nov 27, 2023
1 parent 22f53a0 commit 91c3f83
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,7 @@ private static ImmutableList<ModelInstance> initArchitectureInstances(Architectu
MutableList<ModelInstance> instances = Lists.mutable.empty();
for (ArchitectureItem architectureItem : architectureModel.getEndpoints()) {
switch (architectureItem) {
// TODO Use MetaModel
case ArchitectureComponent component -> instances.add(new ModelInstanceImpl(component.getName(), component.getSubcomponents().isEmpty() ?
"Component" :
"CompositeComponent", component.getId()));
case ArchitectureComponent component -> instances.add(new ModelInstanceImpl(component.getName(), component.getType(), component.getId()));
case ArchitectureInterface ignored -> logger.debug("Skipping .. ArchitectureInterface not supported yet");
case ArchitectureMethod ignored -> logger.debug("Skipping .. ArchitectureMethod not supported yet");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,15 @@ public final class ArchitectureComponent extends ArchitectureItem {
private final SortedSet<ArchitectureInterface> providedInterfaces;

private final SortedSet<ArchitectureInterface> requiredInterfaces;
private final String type;

public ArchitectureComponent(String name, String id, SortedSet<ArchitectureComponent> subcomponents, SortedSet<ArchitectureInterface> providedInterfaces,
SortedSet<ArchitectureInterface> requiredInterfaces) {
SortedSet<ArchitectureInterface> requiredInterfaces, String type) {
super(name, id);
this.subcomponents = subcomponents;
this.providedInterfaces = providedInterfaces;
this.requiredInterfaces = requiredInterfaces;
this.type = type;
}

/**
Expand Down Expand Up @@ -54,6 +56,15 @@ public SortedSet<ArchitectureInterface> getRequiredInterfaces() {
return requiredInterfaces;
}

/**
* Returns the type of this component as specified in the meta model.
*
* @return the type of this component
*/
public String getType() {
return type;
}

@Override
public String toString() {
return "Component: " + getName();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ private static List<ArchitectureComponent> extractComponents(PcmModel originalMo
requiredInterfaces.add(modelInterface);
}
ArchitectureComponent modelComponent = new ArchitectureComponent(originalComponent.getEntityName(), originalComponent.getId(), subcomponents,
providedInterfaces, requiredInterfaces);
providedInterfaces, requiredInterfaces, originalComponent.getType());
components.add(modelComponent);
}
return components;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ private static List<ArchitectureComponent> extractComponents(UmlModel originalMo
requiredInterfaces.add(modelInterface);
}
ArchitectureComponent modelComponent = new ArchitectureComponent(originalComponent.getName(), originalComponent.getId(), subcomponents,
providedInterfaces, requiredInterfaces);
providedInterfaces, requiredInterfaces, originalComponent.getType());
components.add(modelComponent);
}
return components;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@ abstract class UmlElement {

protected final String id;
protected final String name;
private final String type;

UmlElement(PackagedElement element) {
this.element = element;
this.id = element.getId();
this.name = element.getName();
this.type = element.getType();
}

public final String getId() {
Expand All @@ -23,4 +25,8 @@ public final String getId() {
public final String getName() {
return name;
}

public final String getType() {
return type;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,8 @@ public List<Reference> getInterfaceRealizations() {
public List<Reference> getUsages() {
return usages;
}

public String getType() {
return type;
}
}

0 comments on commit 91c3f83

Please sign in to comment.