Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add impl for composite components in deserialization #279

Merged
merged 1 commit into from
Sep 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ public final class PcmComponent {
@XMLList(name = "providedRoles_InterfaceProvidingEntity", elementType = InterfaceId.class)
private List<InterfaceId> providedInterfaceIds;

@XMLList(name = "assemblyContexts__ComposedStructure", elementType = ComponentId.class)
private List<ComponentId> innerComponents;

private List<PcmInterface> required;
private List<PcmInterface> provided;

Expand Down Expand Up @@ -63,6 +66,10 @@ public List<PcmInterface> getProvided() {
return new ArrayList<>(provided);
}

public List<ComponentId> getInnerComponents() {
return innerComponents == null ? List.of() : new ArrayList<>(innerComponents);
}

@XMLClass
static final class InterfaceId {
@XMLValue(name = "providedInterface__OperationProvidedRole", mandatory = false)
Expand All @@ -76,4 +83,14 @@ public String id() {
return provided == null ? required : provided;
}
}

@XMLClass
public static final class ComponentId {
@XMLValue(name = "encapsulatedComponent__AssemblyContext")
private String id;

public String getId() {
return id;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ private void load(InputStream repositoryStream) throws IllegalArgumentException
try (repositoryStream) {
XML2Object xml2Object = new XML2Object();
xml2Object.registerClasses(PcmRepository.class, PcmComponent.class, PcmInterface.class, PcmSignature.class, PcmComponent.InterfaceId.class,
PcmDatatype.class, PcmParameter.class);
PcmDatatype.class, PcmParameter.class, PcmComponent.ComponentId.class);
repository = xml2Object.parseXML(repositoryStream, PcmRepository.class);
repository.init();
} catch (ReflectiveOperationException | IOException | XMLException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import edu.kit.kastel.mcse.ardoco.core.api.models.Metamodel;
import edu.kit.kastel.mcse.ardoco.core.api.models.ModelInstance;
import edu.kit.kastel.mcse.ardoco.core.models.connectors.PcmXmlModelConnector;
import edu.kit.kastel.mcse.ardoco.core.models.connectors.generators.architecture.pcm.parser.PcmModel;

class PcmXmlModelConnectorTest {
private static final Logger logger = LoggerFactory.getLogger(PcmXmlModelConnectorTest.class);
Expand Down Expand Up @@ -110,4 +111,13 @@ void testLoadMediaStore() throws Exception {
Assertions.assertTrue(connector.getInstances().allSatisfy(i -> i.getFullType().equals("BasicComponent")));
}

@Test
void testCompositeComponent() throws Exception {
InputStream is = Objects.requireNonNull(PcmXmlModelConnectorTest.class.getResourceAsStream("/teammates-with-composite.repository"));
PcmModel pcmModel = new PcmModel(is);
is.close();
var component = pcmModel.getRepository().getComponents().stream().filter(it -> it.getEntityName().equals("TestComponent1")).findFirst().orElseThrow();
Assertions.assertEquals("_1lMqsKESEeu-mYqkDskRow", component.getInnerComponents().get(0).getId());
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?xml version="1.0" encoding="ASCII"?>
<repository:Repository xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:repository="http://palladiosimulator.org/PalladioComponentModel/Repository/5.2" id="_tRJJ0KESEeu-mYqkDskRow" entityName="New Repository">
<components__Repository xsi:type="repository:BasicComponent" id="_zUmhEKESEeu-mYqkDskRow" entityName="Common">
<providedRoles_InterfaceProvidingEntity xsi:type="repository:OperationProvidedRole" id="_M9u3YKETEeu-mYqkDskRow" entityName="Common.Common.OperationProvidedRole1" providedInterface__OperationProvidedRole="_ylL2UKESEeu-mYqkDskRow"/>
<requiredRoles_InterfaceRequiringEntity xsi:type="repository:OperationRequiredRole" id="_Y1qHoKETEeu-mYqkDskRow" entityName="Common.Storage.OperationRequiredRole1" requiredInterface__OperationRequiredRole="_777jQKESEeu-mYqkDskRow"/>
</components__Repository>
<components__Repository xsi:type="repository:BasicComponent" id="_1lMqsKESEeu-mYqkDskRow" entityName="UI">
<providedRoles_InterfaceProvidingEntity xsi:type="repository:OperationProvidedRole" id="_OOWxwKETEeu-mYqkDskRow" entityName="UI.UI.OperationProvidedRole1" providedInterface__OperationProvidedRole="_0kie8KESEeu-mYqkDskRow"/>
<requiredRoles_InterfaceRequiringEntity xsi:type="repository:OperationRequiredRole" id="_Va7GIKETEeu-mYqkDskRow" entityName="UI.Common.OperationRequiredRole1" requiredInterface__OperationRequiredRole="_ylL2UKESEeu-mYqkDskRow"/>
<requiredRoles_InterfaceRequiringEntity xsi:type="repository:OperationRequiredRole" id="_aOjNMKETEeu-mYqkDskRow" entityName="UI.Logic.OperationRequiredRole2" requiredInterface__OperationRequiredRole="_2dI_UKESEeu-mYqkDskRow"/>
</components__Repository>
<components__Repository xsi:type="repository:BasicComponent" id="_3LCnIKESEeu-mYqkDskRow" entityName="Logic">
<providedRoles_InterfaceProvidingEntity xsi:type="repository:OperationProvidedRole" id="_PZ4JsKETEeu-mYqkDskRow" entityName="Logic.Logic.OperationProvidedRole1" providedInterface__OperationProvidedRole="_2dI_UKESEeu-mYqkDskRow"/>
<requiredRoles_InterfaceRequiringEntity xsi:type="repository:OperationRequiredRole" id="_WUytYKETEeu-mYqkDskRow" entityName="Logic.Common.OperationRequiredRole1" requiredInterface__OperationRequiredRole="_ylL2UKESEeu-mYqkDskRow"/>
<requiredRoles_InterfaceRequiringEntity xsi:type="repository:OperationRequiredRole" id="_b_8SUKETEeu-mYqkDskRow" entityName="Logic.Storage.OperationRequiredRole2" requiredInterface__OperationRequiredRole="_777jQKESEeu-mYqkDskRow"/>
</components__Repository>
<components__Repository xsi:type="repository:BasicComponent" id="_9JlCIKESEeu-mYqkDskRow" entityName="Storage">
<providedRoles_InterfaceProvidingEntity xsi:type="repository:OperationProvidedRole" id="_Q3LOIKETEeu-mYqkDskRow" entityName="Storage.Storage.OperationProvidedRole1" providedInterface__OperationProvidedRole="_777jQKESEeu-mYqkDskRow"/>
<requiredRoles_InterfaceRequiringEntity xsi:type="repository:OperationRequiredRole" id="_XL7JsKETEeu-mYqkDskRow" entityName="Storage.Common.OperationRequiredRole1" requiredInterface__OperationRequiredRole="_ylL2UKESEeu-mYqkDskRow"/>
<requiredRoles_InterfaceRequiringEntity xsi:type="repository:OperationRequiredRole" id="_e_6DYKETEeu-mYqkDskRow" entityName="Storage.GAE Datastore.OperationRequiredRole2" requiredInterface__OperationRequiredRole="_IArukKETEeu-mYqkDskRow"/>
</components__Repository>
<components__Repository xsi:type="repository:BasicComponent" id="_Bae2oKETEeu-mYqkDskRow" entityName="Test Driver">
<providedRoles_InterfaceProvidingEntity xsi:type="repository:OperationProvidedRole" id="_RmiOgKETEeu-mYqkDskRow" entityName="Test Driver.Test Driver.OperationProvidedRole1" providedInterface__OperationProvidedRole="__RE6IKESEeu-mYqkDskRow"/>
<requiredRoles_InterfaceRequiringEntity xsi:type="repository:OperationRequiredRole" id="_kSxrMKETEeu-mYqkDskRow" entityName="Test Driver.UI.OperationRequiredRole1" requiredInterface__OperationRequiredRole="_0kie8KESEeu-mYqkDskRow"/>
</components__Repository>
<components__Repository xsi:type="repository:BasicComponent" id="_EIoe8KETEeu-mYqkDskRow" entityName="E2E">
<providedRoles_InterfaceProvidingEntity xsi:type="repository:OperationProvidedRole" id="_SNuKUKETEeu-mYqkDskRow" entityName="E2E.E2E.OperationProvidedRole1" providedInterface__OperationProvidedRole="_C6tTQKETEeu-mYqkDskRow"/>
<requiredRoles_InterfaceRequiringEntity xsi:type="repository:OperationRequiredRole" id="_iejUgKETEeu-mYqkDskRow" entityName="E2E.UI.OperationRequiredRole1" requiredInterface__OperationRequiredRole="_0kie8KESEeu-mYqkDskRow"/>
</components__Repository>
<components__Repository xsi:type="repository:BasicComponent" id="_GaP8QKETEeu-mYqkDskRow" entityName="Client">
<providedRoles_InterfaceProvidingEntity xsi:type="repository:OperationProvidedRole" id="_Stjg8KETEeu-mYqkDskRow" entityName="Client.Client.OperationProvidedRole1" providedInterface__OperationProvidedRole="_FMKYgKETEeu-mYqkDskRow"/>
<requiredRoles_InterfaceRequiringEntity xsi:type="repository:OperationRequiredRole" id="_giScIKETEeu-mYqkDskRow" entityName="Client.GAE Datastore.OperationRequiredRole1" requiredInterface__OperationRequiredRole="_IArukKETEeu-mYqkDskRow"/>
</components__Repository>
<components__Repository xsi:type="repository:BasicComponent" id="_KGVMcKETEeu-mYqkDskRow" entityName="GAE Datastore">
<providedRoles_InterfaceProvidingEntity xsi:type="repository:OperationProvidedRole" id="_TPwPEKETEeu-mYqkDskRow" entityName="GAE Datastore.GAE Datastore.OperationProvidedRole1" providedInterface__OperationProvidedRole="_IArukKETEeu-mYqkDskRow"/>
</components__Repository>
<components__Repository xsi:type="repository:CompositeComponent" id="_09MbYF7FEe6xU-Otdgrc7w" entityName="TestComponent1">
<assemblyContexts__ComposedStructure id="_P32D8F7GEe6xU-Otdgrc7w" entityName="Assembly_UI" encapsulatedComponent__AssemblyContext="_1lMqsKESEeu-mYqkDskRow"/>
<providedRoles_InterfaceProvidingEntity xsi:type="repository:OperationProvidedRole" id="_FBKOQF7GEe6xU-Otdgrc7w" entityName="Logic" providedInterface__OperationProvidedRole="_2dI_UKESEeu-mYqkDskRow"/>
</components__Repository>
<interfaces__Repository xsi:type="repository:OperationInterface" id="_ylL2UKESEeu-mYqkDskRow" entityName="Common"/>
<interfaces__Repository xsi:type="repository:OperationInterface" id="_0kie8KESEeu-mYqkDskRow" entityName="UI"/>
<interfaces__Repository xsi:type="repository:OperationInterface" id="_2dI_UKESEeu-mYqkDskRow" entityName="Logic"/>
<interfaces__Repository xsi:type="repository:OperationInterface" id="_777jQKESEeu-mYqkDskRow" entityName="Storage"/>
<interfaces__Repository xsi:type="repository:OperationInterface" id="__RE6IKESEeu-mYqkDskRow" entityName="Test Driver"/>
<interfaces__Repository xsi:type="repository:OperationInterface" id="_C6tTQKETEeu-mYqkDskRow" entityName="E2E"/>
<interfaces__Repository xsi:type="repository:OperationInterface" id="_FMKYgKETEeu-mYqkDskRow" entityName="Client"/>
<interfaces__Repository xsi:type="repository:OperationInterface" id="_IArukKETEeu-mYqkDskRow" entityName="GAE Datastore"/>
</repository:Repository>