use of org.talend.core.model.properties.ItemState in project tdi-studio-se by Talend.
the class CleanFoldersMigrationTask method execute.
/*
* (non-Javadoc)
*
* @see org.talend.core.model.migration.IProjectMigrationTask#execute(org.talend.core.model.general.Project)
*/
public ExecutionResult execute(Project project) {
// if (ProxyRepositoryFactory.getInstance().getRepositoryFactoryFromProvider() instanceof
// ILocalRepositoryFactory) {
project.getEmfProject().getFolders().clear();
List<EObject> toRemove = new ArrayList<EObject>();
for (EObject object : project.getEmfProject().eResource().getContents()) {
if (object instanceof ItemState || object instanceof Property) {
toRemove.add(object);
}
}
project.getEmfProject().eResource().getContents().removeAll(toRemove);
try {
ProxyRepositoryFactory.getInstance().saveProject(project);
} catch (PersistenceException e) {
ExceptionHandler.process(e);
}
return ExecutionResult.SUCCESS_NO_ALERT;
// }
// return ExecutionResult.NOTHING_TO_DO;
}
use of org.talend.core.model.properties.ItemState in project tdi-studio-se by Talend.
the class NewSqlpatternWizardPage method isValid.
@Override
public boolean isValid(String itemName) {
IPath path = getDestinationPath();
Item item = property.getItem();
if (item.getState() == null) {
ItemState itemState = PropertiesFactory.eINSTANCE.createItemState();
item.setState(itemState);
}
item.getState().setPath(path.toString());
return super.isValid(itemName);
}
use of org.talend.core.model.properties.ItemState in project tdi-studio-se by Talend.
the class AddContextCommentValueMigrationTaskTest method createTempContextItem.
private ContextItem createTempContextItem() throws PersistenceException {
ContextItem contextItem = PropertiesFactory.eINSTANCE.createContextItem();
Property myProperty = PropertiesFactory.eINSTANCE.createProperty();
myProperty.setId(ProxyRepositoryFactory.getInstance().getNextId());
ItemState itemState = PropertiesFactory.eINSTANCE.createItemState();
itemState.setDeleted(false);
itemState.setPath("");
contextItem.setState(itemState);
contextItem.setProperty(myProperty);
myProperty.setLabel("context1");
myProperty.setVersion("0.1");
ProxyRepositoryFactory.getInstance().create(contextItem, new Path(""));
return contextItem;
}
use of org.talend.core.model.properties.ItemState 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 org.talend.core.model.properties.ItemState in project tdi-studio-se by Talend.
the class MetadataColumnComparator method createNewRepositoryNode.
/**
* dev Comment method "createNewRepositoryNode".
*
* @param node
* @param parameters
* @param connection
* @param iMetadataConnection
* @return
*/
@SuppressWarnings("unchecked")
private RepositoryNode createNewRepositoryNode(RepositoryNode node, ConnectionParameters parameters, DatabaseConnection connection, IMetadataConnection iMetadataConnection) {
ManagerConnection managerConnection = new ManagerConnection();
boolean status = managerConnection.check(iMetadataConnection);
connection.setDivergency(!status);
ConnectionHelper.getTables(connection).clear();
if (status) {
// try {
// List<MetadataTable> tablesFromDB = ExtractMetaDataFromDataBase.returnMetaTablesFormConnection(
// iMetadataConnection, 500);
// ExtractMetaDataUtils.getInstance().setReconnect(false);
// for (MetadataTable table : tablesFromDB) {
// List<MetadataColumn> columnsFromDB = new ArrayList<MetadataColumn>();
// columnsFromDB.addAll(ExtractMetaDataFromDataBase.returnMetadataColumnsFormTable(iMetadataConnection,
// table.getSourceName()));
// table.getColumns().clear();
// for (MetadataColumn column : columnsFromDB) {
// column.setLabel(""); //$NON-NLS-1$
// table.getColumns().add(column);
// }
// table.setLabel(""); //$NON-NLS-1$
// ConnectionHelper.getTables(connection).add(table);
// }
// ExtractMetaDataUtils.getInstance().setReconnect(true);
// } catch (Exception e) {
// if (parameters != null) {
// parameters.setConnectionComment(e.getMessage());
// }
// return null;
// }
} else {
if (parameters != null) {
parameters.setConnectionComment(managerConnection.getMessageException() == null ? "" : //$NON-NLS-1$
managerConnection.getMessageException());
}
}
DatabaseConnectionItem item = PropertiesFactory.eINSTANCE.createDatabaseConnectionItem();
Property connectionProperty = PropertiesFactory.eINSTANCE.createProperty();
connectionProperty.setAuthor(((RepositoryContext) CorePlugin.getContext().getProperty(Context.REPOSITORY_CONTEXT_KEY)).getUser());
connectionProperty.setVersion(VersionUtils.DEFAULT_VERSION);
//$NON-NLS-1$
connectionProperty.setStatusCode("");
item.setProperty(connectionProperty);
// TDI-18665
updatePackage(iMetadataConnection);
DatabaseConnection dbConn = (DatabaseConnection) iMetadataConnection.getCurrentConnection();
item.setConnection(dbConn);
RepositoryObject object = new RepositoryObject(connectionProperty);
//$NON-NLS-1$
object.setLabel("");
ItemState state = PropertiesFactory.eINSTANCE.createItemState();
state.setDeleted(false);
item.setState(state);
if (node == null) {
node = new RepositoryNode(null, null, ENodeType.SYSTEM_FOLDER);
}
RepositoryNode newNode = new RepositoryNode(object, node, ENodeType.SYSTEM_FOLDER);
return newNode;
}
Aggregations