use of org.palladiosimulator.pcm.repository.RepositoryComponent in project iobserve-analysis by research-iobserve.
the class RepositoryModelProviderTest method createThenUpdateThenReadUpdated.
@Override
@Test
public void createThenUpdateThenReadUpdated() {
final ModelProvider<Repository> modelProvider = new ModelProvider<>(RepositoryModelProviderTest.graph);
final TestModelBuilder testModelBuilder = new TestModelBuilder();
final Repository writtenModel = testModelBuilder.getRepository();
final Interface payInterface = testModelBuilder.getPayInterface();
final RepositoryComponent paymentComponent = testModelBuilder.getPaymentComponent();
final Repository readModel;
modelProvider.createComponent(writtenModel);
// Update the model by renaming and replacing the payment method
writtenModel.setEntityName("MyVideoOnDemandService");
final OperationProvidedRole providedPayOperation = RepositoryFactory.eINSTANCE.createOperationProvidedRole();
providedPayOperation.setEntityName("payPalPayment");
providedPayOperation.setProvidedInterface__OperationProvidedRole((OperationInterface) payInterface);
paymentComponent.getProvidedRoles_InterfaceProvidingEntity().clear();
paymentComponent.getProvidedRoles_InterfaceProvidingEntity().add(providedPayOperation);
modelProvider.updateComponent(Repository.class, writtenModel);
readModel = modelProvider.readOnlyRootComponent(Repository.class);
Assert.assertTrue(this.equalityHelper.equals(writtenModel, readModel));
}
use of org.palladiosimulator.pcm.repository.RepositoryComponent in project iobserve-analysis by research-iobserve.
the class RepositoryModelHandler method loadData.
/**
* Loading and initializing the maps for data access.
*
* @param model
* repository model
* @deprecated this functionality now resides in {@link RepositoryLookupModelProvier}
*/
@Deprecated
public void loadData(final Repository model) {
this.opInfToProvInfMap = new HashMap<>();
this.opProvidedRoleMap = new HashMap<>();
this.operationInterfaceMap = new HashMap<>();
this.operationSignatureMap = new HashMap<>();
// loading OperationProvidedRoles and OperationInterfaces in dedicated maps
for (final RepositoryComponent nextRepoCmp : model.getComponents__Repository()) {
if (nextRepoCmp instanceof BasicComponent) {
final BasicComponent basicCmp = (BasicComponent) nextRepoCmp;
for (final ProvidedRole providedRole : basicCmp.getProvidedRoles_InterfaceProvidingEntity()) {
if (providedRole instanceof OperationProvidedRole) {
final OperationProvidedRole opProvRole = (OperationProvidedRole) providedRole;
final OperationInterface opInterface = opProvRole.getProvidedInterface__OperationProvidedRole();
this.opInfToProvInfMap.put(opInterface.getId(), opProvRole.getId());
this.opProvidedRoleMap.put(opProvRole.getId(), opProvRole);
}
}
}
}
// loading OperationInterfaces and OperationSignatures in dedicated maps
for (final Interface nextInterface : model.getInterfaces__Repository()) {
if (nextInterface instanceof OperationInterface) {
final OperationInterface opInf = (OperationInterface) nextInterface;
this.operationInterfaceMap.put(opInf.getId(), opInf);
for (final OperationSignature opSig : opInf.getSignatures__OperationInterface()) {
this.operationSignatureMap.put(opSig.getId(), opSig);
}
}
}
}
use of org.palladiosimulator.pcm.repository.RepositoryComponent in project iobserve-analysis by research-iobserve.
the class SystemGeneration method initInterfaceMaps.
private void initInterfaceMaps() {
this.openRequiredInterfaces = new HashMap<>();
this.openProvidedInterfaces = new HashMap<>();
this.connectedProvidedInterfaces = new HashMap<>();
this.unconnectedAssemblyContextes = new HashSet<>();
for (final RepositoryComponent component : this.components) {
for (final ProvidedRole provRole : component.getProvidedRoles_InterfaceProvidingEntity()) {
if (!(provRole instanceof OperationProvidedRole)) {
continue;
}
final OperationProvidedRole provInterface = (OperationProvidedRole) provRole;
final String interfaceID = provInterface.getProvidedInterface__OperationProvidedRole().getId();
if (!this.openProvidedInterfaces.containsKey(interfaceID)) {
this.openProvidedInterfaces.put(interfaceID, new LinkedList<AssemblyContext>());
this.openRequiredInterfaces.put(interfaceID, new LinkedList<AssemblyContext>());
this.connectedProvidedInterfaces.put(interfaceID, new LinkedList<AssemblyContext>());
}
}
for (final RequiredRole requRole : component.getRequiredRoles_InterfaceRequiringEntity()) {
if (!(requRole instanceof OperationRequiredRole)) {
continue;
}
final OperationRequiredRole reqInterface = (OperationRequiredRole) requRole;
final String interfaceID = reqInterface.getRequiredInterface__OperationRequiredRole().getId();
if (!this.openProvidedInterfaces.containsKey(interfaceID)) {
this.openProvidedInterfaces.put(interfaceID, new LinkedList<AssemblyContext>());
this.openRequiredInterfaces.put(interfaceID, new LinkedList<AssemblyContext>());
this.connectedProvidedInterfaces.put(interfaceID, new LinkedList<AssemblyContext>());
}
}
}
}
use of org.palladiosimulator.pcm.repository.RepositoryComponent in project iobserve-analysis by research-iobserve.
the class SystemModification method initDuplicateRepo.
/*
* Calculates all duplicated Repositories.
*/
private void initDuplicateRepo(final RepositoryComponent[] comps) {
SystemModification.LOGGER.info("Calculating euql Repository Components ...");
final Map<String, RepositoryComponent> existingInterfaceSig = new HashMap<>();
for (final RepositoryComponent comp : comps) {
// Calc Sig
final String interfaceSignature = this.caluclateInterfaceSignature(comp);
if (existingInterfaceSig.containsKey(interfaceSignature)) {
// Sig already exists
if (this.duplicateRepositoryComponents.containsKey(interfaceSignature)) {
// Already 2+ equal sig exist
this.duplicateRepositoryComponents.get(interfaceSignature).add(comp);
} else {
// First duplicate with this sig found
final List<RepositoryComponent> duplicates = new ArrayList<>();
duplicates.add(existingInterfaceSig.get(interfaceSignature));
duplicates.add(comp);
this.duplicateRepositoryComponents.put(interfaceSignature, duplicates);
}
} else {
// No equal sig found
existingInterfaceSig.put(interfaceSignature, comp);
}
}
SystemModification.LOGGER.info("Duplicate Interfacestructures found:\t {}", this.duplicateRepositoryComponents.keySet().size());
}
use of org.palladiosimulator.pcm.repository.RepositoryComponent in project iobserve-analysis by research-iobserve.
the class RepositoryModelProviderTest method createThenUpdateThenReadUpdated.
@Override
@Test
public void createThenUpdateThenReadUpdated() throws NodeLookupException, DBException {
final Neo4JModelResource<Repository> resource = ModelProviderTestUtils.prepareResource("createThenUpdateThenReadUpdated", this.prefix, this.ePackage);
final Interface payInterface = RepositoryModelDataFactory.findInterfaceByName(this.repository, RepositoryModelDataFactory.PAYMENT_INTERFACE);
final RepositoryComponent paymentComponent = RepositoryModelDataFactory.findComponentByName(this.repository, RepositoryModelDataFactory.PAYMENT_COMPONENT);
resource.storeModelPartition(this.testModel);
// Update the model by renaming and replacing the payment method
this.testModel.setEntityName("MyVideoOnDemandService");
final OperationProvidedRole providedPayOperation = ((RepositoryFactory) this.ePackage.getEFactoryInstance()).createOperationProvidedRole();
providedPayOperation.setEntityName("payPalPayment");
providedPayOperation.setProvidedInterface__OperationProvidedRole((OperationInterface) payInterface);
paymentComponent.getProvidedRoles_InterfaceProvidingEntity().clear();
paymentComponent.getProvidedRoles_InterfaceProvidingEntity().add(providedPayOperation);
resource.updatePartition(this.testModel);
final Repository readModel = resource.getModelRootNode(Repository.class, RepositoryPackage.Literals.REPOSITORY);
Assert.assertTrue(this.equalityHelper.comparePartition(this.testModel, readModel, readModel.eClass()));
resource.getGraphDatabaseService().shutdown();
}
Aggregations