use of org.palladiosimulator.pcm.core.composition.AssemblyContext in project iobserve-analysis by research-iobserve.
the class AssemblyContextActionFactory method setSourceAssemblyContext.
private static AssemblyContextAction setSourceAssemblyContext(final AssemblyContextAction action, final String assemblyContextID) {
final org.palladiosimulator.pcm.system.System systemModel = ActionFactory.getRuntimeModels().getSystemModel();
final AssemblyContext assemblyContext = ActionFactory.getAssemblyContext(assemblyContextID, systemModel);
action.setSourceAssemblyContext(assemblyContext);
return action;
}
use of org.palladiosimulator.pcm.core.composition.AssemblyContext in project iobserve-analysis by research-iobserve.
the class AllocationModification method initResContainer2AllocationContext.
private void initResContainer2AllocationContext() {
this.resContainer2AllocationContext = new HashMap<>();
this.assemblyCon2AllocationContext = new HashMap<>();
for (final AllocationContext ac : this.allocationModel.getAllocationContexts_Allocation()) {
final ResourceContainer resCon = ac.getResourceContainer_AllocationContext();
if (!this.resContainer2AllocationContext.containsKey(resCon.getId())) {
this.resContainer2AllocationContext.put(resCon.getId(), new LinkedList<AllocationContext>());
}
this.resContainer2AllocationContext.get(resCon.getId()).add(ac);
final AssemblyContext assemblyCon = ac.getAssemblyContext_AllocationContext();
if (!this.assemblyCon2AllocationContext.containsKey(assemblyCon.getId())) {
this.assemblyCon2AllocationContext.put(assemblyCon.getId(), ac);
} else {
throw new RuntimeException("An assembly context was found twice during assembly context analysis!");
}
}
}
use of org.palladiosimulator.pcm.core.composition.AssemblyContext in project iobserve-analysis by research-iobserve.
the class SystemGeneration method createAssemblyConnector.
/*
* This method creates an assembly connector between the given AssemblyContextes for the given
* interface.
*/
private AssemblyConnector createAssemblyConnector(final AssemblyContext requiringAC, final AssemblyContext providingAC, final String interfaceID) {
final AssemblyConnectorPrivacy connector = SystemGeneration.COMPOSITION_PRIVACY_FACTORY.createAssemblyConnectorPrivacy();
connector.setEntityName(requiringAC.getEntityName() + " -> " + providingAC.getEntityName());
final java.util.Optional<ProvidedRole> providedRole = providingAC.getEncapsulatedComponent__AssemblyContext().getProvidedRoles_InterfaceProvidingEntity().stream().filter(s -> this.matchingInterface(s, interfaceID)).findFirst();
final java.util.Optional<RequiredRole> requiredRole = requiringAC.getEncapsulatedComponent__AssemblyContext().getRequiredRoles_InterfaceRequiringEntity().stream().filter(s -> this.matchingInterface(s, interfaceID)).findFirst();
connector.setProvidingAssemblyContext_AssemblyConnector(providingAC);
connector.setRequiringAssemblyContext_AssemblyConnector(requiringAC);
connector.setProvidedRole_AssemblyConnector((OperationProvidedRole) providedRole.get());
connector.setRequiredRole_AssemblyConnector((OperationRequiredRole) requiredRole.get());
final float randFloat = ThreadLocalRandom.current().nextFloat();
if (randFloat < 0.15) {
connector.setPrivacyLevel(DataPrivacyLvl.PERSONAL);
} else if (randFloat < 0.50) {
connector.setPrivacyLevel(DataPrivacyLvl.DEPERSONALIZED);
} else {
connector.setPrivacyLevel(DataPrivacyLvl.ANONYMIZED);
}
this.system.getConnectors__ComposedStructure().add(connector);
this.unconnectedAssemblyContextes.remove(requiringAC);
this.unconnectedAssemblyContextes.remove(providingAC);
return connector;
}
use of org.palladiosimulator.pcm.core.composition.AssemblyContext in project iobserve-analysis by research-iobserve.
the class SystemGeneration method addAssemblyContexts.
/**
* @param assemblyContextCount
* @param prefix
* @return
*/
public List<AssemblyContext> addAssemblyContexts(final int assemblyContextCount, final String prefix) {
final List<AssemblyContext> newACs = new ArrayList<>();
for (int i = 0; i < assemblyContextCount; i++) {
final String namePrefix = Integer.toString(i) + "_" + prefix;
final AssemblyContext newAC = this.generateNewAC(namePrefix);
newACs.add(newAC);
SystemGeneration.LOGGER.info("CREATING: \tAssemblyContext: \t {}", newAC.getId());
}
this.finalizeModelGeneration();
return newACs;
}
use of org.palladiosimulator.pcm.core.composition.AssemblyContext in project iobserve-analysis by research-iobserve.
the class SystemGeneration method generateNewAC.
/*
*
*/
private AssemblyContext generateNewAC(final String namePrefix) {
final int randomInt = ThreadLocalRandom.current().nextInt(this.components.length);
final RepositoryComponent randComponent = this.components[randomInt];
final AssemblyContext newAC = SystemGeneration.COMPOSITION_PRIVACY_FACTORY.createAssemblyContextPrivacy();
newAC.setEntityName(namePrefix + "_AC_" + randComponent.getEntityName());
newAC.setEncapsulatedComponent__AssemblyContext(randComponent);
newAC.setParentStructure__AssemblyContext(this.system);
this.system.getAssemblyContexts__ComposedStructure().add(newAC);
this.unconnectedAssemblyContextes.add(newAC);
final EList<ProvidedRole> provRoles = randComponent.getProvidedRoles_InterfaceProvidingEntity();
this.connectProvidedInterfaces(newAC, provRoles);
final EList<RequiredRole> requRoles = randComponent.getRequiredRoles_InterfaceRequiringEntity();
this.connectRequiredInterfaces(newAC, requRoles);
return newAC;
}
Aggregations