Search in sources :

Example 6 with ItemState

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;
}
Also used : EObject(org.eclipse.emf.ecore.EObject) ItemState(org.talend.core.model.properties.ItemState) ArrayList(java.util.ArrayList) PersistenceException(org.talend.commons.exception.PersistenceException) Property(org.talend.core.model.properties.Property)

Example 7 with ItemState

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);
}
Also used : Item(org.talend.core.model.properties.Item) IPath(org.eclipse.core.runtime.IPath) ItemState(org.talend.core.model.properties.ItemState)

Example 8 with ItemState

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;
}
Also used : Path(org.eclipse.core.runtime.Path) ContextItem(org.talend.core.model.properties.ContextItem) ItemState(org.talend.core.model.properties.ItemState) Property(org.talend.core.model.properties.Property)

Example 9 with ItemState

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);
}
Also used : Path(org.eclipse.core.runtime.Path) RecordFile(orgomg.cwm.resource.record.RecordFile) ItemState(org.talend.core.model.properties.ItemState) DatabaseConnection(org.talend.core.model.metadata.builder.connection.DatabaseConnection) Property(org.talend.core.model.properties.Property) IProxyRepositoryFactory(org.talend.repository.model.IProxyRepositoryFactory)

Example 10 with ItemState

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;
}
Also used : ManagerConnection(org.talend.metadata.managment.repository.ManagerConnection) SqlBuilderRepositoryObject(org.talend.sqlbuilder.dbstructure.SqlBuilderRepositoryObject) MetadataTableRepositoryObject(org.talend.sqlbuilder.dbstructure.DBTreeProvider.MetadataTableRepositoryObject) RepositoryObject(org.talend.core.model.repository.RepositoryObject) MetadataColumnRepositoryObject(org.talend.sqlbuilder.dbstructure.DBTreeProvider.MetadataColumnRepositoryObject) ItemState(org.talend.core.model.properties.ItemState) DatabaseConnection(org.talend.core.model.metadata.builder.connection.DatabaseConnection) RepositoryNode(org.talend.repository.model.RepositoryNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode) Property(org.talend.core.model.properties.Property) DatabaseConnectionItem(org.talend.core.model.properties.DatabaseConnectionItem)

Aggregations

ItemState (org.talend.core.model.properties.ItemState)10 Property (org.talend.core.model.properties.Property)7 Path (org.eclipse.core.runtime.Path)3 PersistenceException (org.talend.commons.exception.PersistenceException)3 Item (org.talend.core.model.properties.Item)3 DatabaseConnection (org.talend.core.model.metadata.builder.connection.DatabaseConnection)2 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 IWorkspace (org.eclipse.core.resources.IWorkspace)1 IWorkspaceRunnable (org.eclipse.core.resources.IWorkspaceRunnable)1 CoreException (org.eclipse.core.runtime.CoreException)1 IPath (org.eclipse.core.runtime.IPath)1 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)1 ISchedulingRule (org.eclipse.core.runtime.jobs.ISchedulingRule)1 EObject (org.eclipse.emf.ecore.EObject)1 ProgressMonitorDialog (org.eclipse.jface.dialogs.ProgressMonitorDialog)1 IRunnableWithProgress (org.eclipse.jface.operation.IRunnableWithProgress)1 TableItem (org.eclipse.swt.widgets.TableItem)1