use of orgomg.cwm.resource.record.RecordFile in project tdi-studio-se by Talend.
the class ChangeValuesFromRepositoryTest method init.
private static void init() throws PersistenceException {
connection = ConnectionFactory.eINSTANCE.createDatabaseConnection();
connection.setName("ChangeValues");
((DatabaseConnection) connection).setDatabaseType("MySQL");
((DatabaseConnection) connection).setUsername("root");
((DatabaseConnection) connection).setRawPassword("root");
((DatabaseConnection) connection).setPort("4000");
((DatabaseConnection) connection).setDatasourceName("test");
((DatabaseConnection) connection).setServerName("localhost");
IProxyRepositoryFactory factory = CoreRuntimePlugin.getInstance().getProxyRepositoryFactory();
connection.setId(factory.getNextId());
databaseConnItem = PropertiesFactory.eINSTANCE.createDatabaseConnectionItem();
Property myProperty = PropertiesFactory.eINSTANCE.createProperty();
myProperty.setId(factory.getNextId());
myProperty.setLabel("ChangeValues");
myProperty.setVersion("0.1");
ItemState itemState = PropertiesFactory.eINSTANCE.createItemState();
itemState.setPath("");
databaseConnItem.setProperty(myProperty);
databaseConnItem.setState(itemState);
databaseConnItem.setConnection(connection);
RecordFile record = (RecordFile) ConnectionHelper.getPackage(connection.getName(), connection, RecordFile.class);
inputTable = ConnectionFactory.eINSTANCE.createMetadataTable();
inputTable.setId(factory.getNextId());
inputTable.setLabel("Input");
if (record != null) {
PackageHelper.addMetadataTable(inputTable, record);
} else {
RecordFile newrecord = RecordFactory.eINSTANCE.createRecordFile();
newrecord.setName(connection.getName());
ConnectionHelper.addPackage(newrecord, connection);
PackageHelper.addMetadataTable(inputTable, newrecord);
}
factory.create(databaseConnItem, new Path(""));
factory.save(databaseConnItem);
}
use of orgomg.cwm.resource.record.RecordFile in project tdi-studio-se by Talend.
the class SalesforceMultiSchemaMigrationTask method execute.
/*
* (non-Javadoc)
*
* @see org.talend.core.model.migration.AbstractItemMigrationTask#execute(org .talend.core.model.properties.Item)
*/
@Override
public ExecutionResult execute(Item item) {
if (item instanceof SalesforceSchemaConnectionItem) {
boolean modify = false;
SalesforceSchemaConnectionItem salesforceItem = (SalesforceSchemaConnectionItem) item;
if (salesforceItem.getConnection() instanceof SalesforceSchemaConnection) {
SalesforceSchemaConnection sfConnection = (SalesforceSchemaConnection) salesforceItem.getConnection();
SalesforceModuleUnit module = ConnectionFactory.eINSTANCE.createSalesforceModuleUnit();
module.setId(ProxyRepositoryFactory.getInstance().getNextId());
String moduleName = sfConnection.getModuleName();
if (moduleName == null || "".equals(moduleName)) {
moduleName = "Default";
}
module.setLabel(moduleName);
module.setModuleName(moduleName);
EList<orgomg.cwm.objectmodel.core.Package> originalPackages = sfConnection.getDataPackage();
for (int i = 0; i < originalPackages.size(); i++) {
MetadataTable table = (MetadataTable) originalPackages.get(i).getOwnedElement().get(0);
if (originalPackages.get(i) instanceof RecordFile) {
table.setLabel(moduleName);
}
module.getTables().add(table);
}
sfConnection.getModules().add(module);
modify = true;
}
if (modify) {
try {
ProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
factory.save(item, true);
return ExecutionResult.SUCCESS_WITH_ALERT;
} catch (Exception e) {
ExceptionHandler.process(e);
return ExecutionResult.FAILURE;
}
}
}
return ExecutionResult.NOTHING_TO_DO;
}
use of orgomg.cwm.resource.record.RecordFile in project tdq-studio-se by Talend.
the class UpdateFileConnectionTask method doExecute.
@Override
protected boolean doExecute() throws Exception {
RootContainer<String, IRepositoryViewObject> rc = ProxyRepositoryFactory.getInstance().getMetadata(ERepositoryObjectType.METADATA_FILE_DELIMITED);
for (IRepositoryViewObject repViewObj : rc.getMembers()) {
ConnectionItem item = (ConnectionItem) repViewObj.getProperty().getItem();
Connection connection = item.getConnection();
String conName = connection.getName();
if (conName == null || "".equals(conName)) {
// $NON-NLS-1$
// set connection name.
connection.setName(item.getProperty().getDisplayName());
// set RecordFile name.
EList<Package> dataPackage = connection.getDataPackage();
for (Package data : dataPackage) {
if (data instanceof RecordFile) {
RecordFile rf = (RecordFile) data;
if (rf != null) {
// $NON-NLS-1$
rf.setName("default");
}
}
}
EMFUtil.saveResource(connection.eResource());
}
}
return true;
}
Aggregations