@Test public void testCustomonnectorMigrationWithGetterCustom() throws Exception { final URL url = TestCustomConnectorMigrationUseCase.class.getResource("fab--1.0.bar"); final File migratedProc = BarImporterTestUtil.migrateBar(url); assertNotNull("Fail to migrate bar file", migratedProc); assertNotNull("Fail to migrate bar file", migratedProc.exists()); final Resource resource = BarImporterTestUtil.assertIsLoadable(migratedProc); final MainProcess mainProc = BarImporterTestUtil.getMainProcess(resource); final ConnectorDefRepositoryStore defStore = (ConnectorDefRepositoryStore) RepositoryManager.getInstance().getRepositoryStore(ConnectorDefRepositoryStore.class); assertNotNull(defStore.getDefinition("fabulous_connector", "1.0.0")); final ConnectorImplRepositoryStore implStore = (ConnectorImplRepositoryStore) RepositoryManager.getInstance().getRepositoryStore(ConnectorImplRepositoryStore.class); ConnectorImplementation implementation = implStore.getImplementation("fabulous_connector-impl", "1.0.0"); assertNotNull(implementation); final ConnectorSourceRepositoryStore sourceStore = (ConnectorSourceRepositoryStore) RepositoryManager.getInstance() .getRepositoryStore(ConnectorSourceRepositoryStore.class); assertNotNull(sourceStore.getChild(implementation.getImplementationClassname())); final List<Connector> connectors = ModelHelper.getAllItemsOfType(mainProc, ProcessPackage.Literals.CONNECTOR); assertEquals("Invalid number of connector", 1, connectors.size()); }
private String generateDataName() { return Messages.Data + (ModelHelper.getAllItemsOfType( ModelHelper.getParentProcess(element), SimulationPackage.eINSTANCE.getSimulationData()) .size() + 1); }
@Override protected List<Connector> getExistingConnectors(AbstractProcess process) { List<Connector> connectors = ModelHelper.getAllItemsOfType(process, ProcessPackage.Literals.CONNECTOR); Set<Connector> toRemove = new HashSet<Connector>(); for (Connector c : connectors) { if (c instanceof ActorFilter) { toRemove.add(c); } if (c.eContainer() instanceof Expression) { Expression exp = (Expression) c.eContainer(); if (!ExpressionConstants.CONNECTOR_TYPE.equals(exp.getType())) { toRemove.add(c); } } } connectors.removeAll(toRemove); return connectors; }
private void addNewKPIConnectorDefinition( Configuration configuration, AbstractProcess process, CompoundCommand cc, EditingDomain editingDomain) { List<DatabaseKPIBinding> kpiBindings = ModelHelper.getAllItemsOfType(process, KpiPackage.Literals.DATABASE_KPI_BINDING); if (!kpiBindings.isEmpty()) { String defId = DB_CONNECTOR_FOR_KPI_ID; String defVersion = DB_CONNECTOR_VERSION; boolean exists = false; for (DefinitionMapping association : configuration.getDefinitionMappings()) { if (FragmentTypes.CONNECTOR.equals(association.getType()) && association.getDefinitionId().equals(defId) && association.getDefinitionVersion().equals(defVersion)) { exists = true; updateAssociation(configuration, association, cc, editingDomain); break; } } if (!exists) { DefinitionMapping newAssociation = ConfigurationFactory.eINSTANCE.createDefinitionMapping(); newAssociation.setDefinitionId(defId); newAssociation.setDefinitionVersion(defVersion); newAssociation.setType(getFragmentContainerId()); editingDomain .getCommandStack() .execute( AddCommand.create( editingDomain, configuration, ConfigurationPackage.Literals.CONFIGURATION__DEFINITION_MAPPINGS, newAssociation)); updateAssociation(configuration, newAssociation, cc, editingDomain); } } }