use of org.palladiosimulator.pcm.repository.RepositoryComponent in project iobserve-analysis by research-iobserve.
the class RepositoryLookupModelProvider method initializeLookupMaps.
/**
* Initializing the maps for data access.
*/
private void initializeLookupMaps() {
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 : this.repositoryModel.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 : this.repositoryModel.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 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;
}
use of org.palladiosimulator.pcm.repository.RepositoryComponent in project iobserve-analysis by research-iobserve.
the class SystemModification method modifySystemChangeComp.
public int modifySystemChangeComp(final int changes) {
int madeChanges = 0;
// Copy the assembly context list
final EList<AssemblyContext> assemblyContextsList = this.systemModel.getAssemblyContexts__ComposedStructure();
final List<AssemblyContext> assemblyContexts = assemblyContextsList.stream().collect(Collectors.toList());
// Randomize the list!
Collections.shuffle(assemblyContexts);
// Iterate over random list
for (final AssemblyContext assemblyContext : assemblyContexts) {
final String interfaceSignature = this.caluclateInterfaceSignature(assemblyContext.getEncapsulatedComponent__AssemblyContext());
if (this.duplicateRepositoryComponents.containsKey(interfaceSignature)) {
// Duplicate to containing comp is available!
final List<RepositoryComponent> equalComponents = this.duplicateRepositoryComponents.get(interfaceSignature);
// Find non-self replacement
RepositoryComponent newRepoComp = null;
for (int j = 0; newRepoComp != null && j < equalComponents.size() * 10; j++) {
final int randomIndex = ThreadLocalRandom.current().nextInt(equalComponents.size());
final RepositoryComponent candidate = equalComponents.get(randomIndex);
if (!assemblyContext.getEncapsulatedComponent__AssemblyContext().getId().equals(candidate.getId())) {
newRepoComp = candidate;
}
}
if (newRepoComp != null) {
// Exchange containing comp
assemblyContext.setEncapsulatedComponent__AssemblyContext(newRepoComp);
madeChanges++;
if (madeChanges == changes) {
break;
}
}
}
}
return madeChanges;
}
use of org.palladiosimulator.pcm.repository.RepositoryComponent in project Palladio-Editors-Sirius by PalladioSimulator.
the class AddAssemblyContext method execute.
@Override
public void execute(final Collection<? extends EObject> selections, final Map<String, Object> parameters) {
final Object parameter = parameters.get(NEW_ASSEMBLY_CONTEXT);
if (parameter == null || !(parameter instanceof AssemblyContext)) {
return;
}
final AssemblyContext assemblyContext = (AssemblyContext) parameter;
final RepositoryComponent repositoryComponent = getRepositoryComponent(assemblyContext);
if (repositoryComponent != null) {
assemblyContext.setEncapsulatedComponent__AssemblyContext(repositoryComponent);
assemblyContext.setEntityName("Assembly_" + repositoryComponent.getEntityName());
}
}
use of org.palladiosimulator.pcm.repository.RepositoryComponent in project iobserve-analysis by research-iobserve.
the class ComponentEntryImpl method setComponent.
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setComponent(RepositoryComponent newComponent) {
RepositoryComponent oldComponent = component;
component = newComponent;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, CorrespondencePackage.COMPONENT_ENTRY__COMPONENT, oldComponent, component));
}
Aggregations