Search in sources :

Example 1 with RecordFile

use of orgomg.cwm.resource.record.RecordFile in project tdi-studio-se by Talend.

the class JSONFileOutputStep1Form method updateConnection.

private void updateConnection(String text) {
    if (text == null || "".equals(text)) {
        return;
    }
    List<FOXTreeNode> rootFoxTreeNodes = null;
    if (JSONFileOutputStep1Form.this.tempPath == null) {
        JSONFileOutputStep1Form.this.tempPath = JSONUtil.changeJsonToXml(text);
    }
    if (treeNode == null) {
        rootFoxTreeNodes = TreeUtil.getFoxTreeNodes(JSONFileOutputStep1Form.this.tempPath);
    } else {
        rootFoxTreeNodes = getCorrespondingFoxTreeNodes(treeNode, true);
    }
    if (rootFoxTreeNodes.size() == 0) {
        return;
    }
    if (ConnectionHelper.getTables(getConnection()).isEmpty()) {
        MetadataTable table = ConnectionFactory.eINSTANCE.createMetadataTable();
        RecordFile record = (RecordFile) ConnectionHelper.getPackage(getConnection().getName(), getConnection(), RecordFile.class);
        if (record != null) {
            // hywang
            PackageHelper.addMetadataTable(table, record);
        } else {
            RecordFile newrecord = RecordFactory.eINSTANCE.createRecordFile();
            newrecord.setName(connection.getName());
            ConnectionHelper.addPackage(newrecord, connection);
            PackageHelper.addMetadataTable(table, newrecord);
        }
    }
    EList schemaMetadataColumn = ConnectionHelper.getTables(getConnection()).toArray(new MetadataTable[0])[0].getColumns();
    schemaMetadataColumn.clear();
    initMetadataTable(rootFoxTreeNodes, schemaMetadataColumn);
    updateConnectionProperties(rootFoxTreeNodes.get(0));
}
Also used : FOXTreeNode(org.talend.metadata.managment.ui.wizard.metadata.xml.node.FOXTreeNode) EList(org.eclipse.emf.common.util.EList) RecordFile(orgomg.cwm.resource.record.RecordFile) MetadataTable(org.talend.core.model.metadata.builder.connection.MetadataTable)

Example 2 with RecordFile

use of orgomg.cwm.resource.record.RecordFile in project tdq-studio-se by Talend.

the class UnitTestBuildHelper method initFileConnection.

/**
 * create a real file connection witl file url
 *
 * @param fileUrl
 * @param delimitedFileconnection
 * @return
 */
public MetadataTable initFileConnection(URL fileUrl, DelimitedFileConnection delimitedFileconnection) {
    try {
        delimitedFileconnection.setFilePath(FileLocator.toFileURL(fileUrl).toURI().getPath().toString());
        // $NON-NLS-1$
        delimitedFileconnection.setRowSeparatorValue("\n");
        // $NON-NLS-1$
        delimitedFileconnection.setEncoding("UTF-8");
        // $NON-NLS-1$
        delimitedFileconnection.setFieldSeparatorValue(",");
        delimitedFileconnection.setName(ERepositoryObjectType.METADATA_FILE_DELIMITED.getKey());
        MetadataTable metadataTable = ConnectionFactory.eINSTANCE.createMetadataTable();
        // IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
        // metadataTable.setId(factory.getNextId());
        RecordFile record = (RecordFile) ConnectionHelper.getPackage(delimitedFileconnection.getName(), delimitedFileconnection, RecordFile.class);
        if (record != null) {
            // hywang
            PackageHelper.addMetadataTable(metadataTable, record);
        } else {
            RecordFile newrecord = RecordFactory.eINSTANCE.createRecordFile();
            newrecord.setName(delimitedFileconnection.getName());
            ConnectionHelper.addPackage(newrecord, delimitedFileconnection);
            PackageHelper.addMetadataTable(metadataTable, newrecord);
        }
        return metadataTable;
    } catch (Exception e) {
        e.printStackTrace();
    }
    return null;
}
Also used : RecordFile(orgomg.cwm.resource.record.RecordFile) MetadataTable(org.talend.core.model.metadata.builder.connection.MetadataTable) CoreException(org.eclipse.core.runtime.CoreException) SQLException(java.sql.SQLException) IOException(java.io.IOException) PersistenceException(org.talend.commons.exception.PersistenceException)

Example 3 with RecordFile

use of orgomg.cwm.resource.record.RecordFile in project tdq-studio-se by Talend.

the class UnitTestBuildHelper method initFileConnection.

/**
 * create a real file connection witl file url
 *
 * @param fileUrl
 * @param delimitedFileconnection
 * @return
 */
public static MetadataTable initFileConnection(URL fileUrl, DelimitedFileConnection delimitedFileconnection) {
    try {
        delimitedFileconnection.setFilePath(FileLocator.toFileURL(fileUrl).toURI().getPath().toString());
        delimitedFileconnection.setRowSeparatorValue("\n");
        delimitedFileconnection.setEncoding("UTF-8");
        delimitedFileconnection.setFieldSeparatorValue(",");
        delimitedFileconnection.setName(ERepositoryObjectType.METADATA_FILE_DELIMITED.getKey());
        MetadataTable metadataTable = ConnectionFactory.eINSTANCE.createMetadataTable();
        IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
        metadataTable.setId(factory.getNextId());
        RecordFile record = (RecordFile) ConnectionHelper.getPackage(delimitedFileconnection.getName(), delimitedFileconnection, RecordFile.class);
        if (record != null) {
            // hywang
            PackageHelper.addMetadataTable(metadataTable, record);
        } else {
            RecordFile newrecord = RecordFactory.eINSTANCE.createRecordFile();
            newrecord.setName(delimitedFileconnection.getName());
            ConnectionHelper.addPackage(newrecord, delimitedFileconnection);
            PackageHelper.addMetadataTable(metadataTable, newrecord);
        }
        return metadataTable;
    } catch (Exception e) {
        e.printStackTrace();
    }
    return null;
}
Also used : RecordFile(orgomg.cwm.resource.record.RecordFile) MetadataTable(org.talend.core.model.metadata.builder.connection.MetadataTable) IProxyRepositoryFactory(org.talend.repository.model.IProxyRepositoryFactory) CoreException(org.eclipse.core.runtime.CoreException) SQLException(java.sql.SQLException) PersistenceException(org.talend.commons.exception.PersistenceException)

Example 4 with RecordFile

use of orgomg.cwm.resource.record.RecordFile in project tdq-studio-se by Talend.

the class UnitTestBuildHelper method initFileConnection.

/**
 * create a real file connection witl file url
 *
 * @param fileUrl
 * @param delimitedFileconnection
 * @return
 */
public MetadataTable initFileConnection(URL fileUrl, DelimitedFileConnection delimitedFileconnection) {
    try {
        delimitedFileconnection.setFilePath(FileLocator.toFileURL(fileUrl).toURI().getPath().toString());
        // $NON-NLS-1$
        delimitedFileconnection.setRowSeparatorValue("\n");
        // $NON-NLS-1$
        delimitedFileconnection.setEncoding("UTF-8");
        // $NON-NLS-1$
        delimitedFileconnection.setFieldSeparatorValue(",");
        delimitedFileconnection.setName(ERepositoryObjectType.METADATA_FILE_DELIMITED.getKey());
        MetadataTable metadataTable = ConnectionFactory.eINSTANCE.createMetadataTable();
        // IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
        // metadataTable.setId(factory.getNextId());
        RecordFile record = (RecordFile) ConnectionHelper.getPackage(delimitedFileconnection.getName(), delimitedFileconnection, RecordFile.class);
        if (record != null) {
            // hywang
            PackageHelper.addMetadataTable(metadataTable, record);
        } else {
            RecordFile newrecord = RecordFactory.eINSTANCE.createRecordFile();
            newrecord.setName(delimitedFileconnection.getName());
            ConnectionHelper.addPackage(newrecord, delimitedFileconnection);
            PackageHelper.addMetadataTable(metadataTable, newrecord);
        }
        return metadataTable;
    } catch (Exception e) {
        e.printStackTrace();
    }
    return null;
}
Also used : RecordFile(orgomg.cwm.resource.record.RecordFile) MetadataTable(org.talend.core.model.metadata.builder.connection.MetadataTable) CoreException(org.eclipse.core.runtime.CoreException) IOException(java.io.IOException) PersistenceException(org.talend.commons.exception.PersistenceException)

Example 5 with RecordFile

use of orgomg.cwm.resource.record.RecordFile in project tdi-studio-se by Talend.

the class CreateJSONSchemaAction method doRun.

@Override
protected void doRun() {
    if (repositoryNode == null) {
        repositoryNode = getCurrentRepositoryNode();
    }
    JSONFileConnection connection = null;
    MetadataTable metadataTable = null;
    boolean creation = false;
    if (repositoryNode.getType() == ENodeType.REPOSITORY_ELEMENT) {
        ERepositoryObjectType nodeType = (ERepositoryObjectType) repositoryNode.getProperties(EProperties.CONTENT_TYPE);
        String metadataTableLabel = (String) repositoryNode.getProperties(EProperties.LABEL);
        JSONFileConnectionItem item = null;
        if (nodeType == ERepositoryObjectType.METADATA_CON_TABLE) {
            item = (JSONFileConnectionItem) repositoryNode.getObject().getProperty().getItem();
            connection = (JSONFileConnection) item.getConnection();
            metadataTable = TableHelper.findByLabel(connection, metadataTableLabel);
            creation = false;
        } else if (nodeType == JSONRepositoryNodeType.JSON) {
            item = (JSONFileConnectionItem) repositoryNode.getObject().getProperty().getItem();
            connection = (JSONFileConnection) item.getConnection();
            metadataTable = ConnectionFactory.eINSTANCE.createMetadataTable();
            String nextId = ProxyRepositoryFactory.getInstance().getNextId();
            metadataTable.setId(nextId);
            metadataTable.setLabel(getStringIndexed(metadataTable.getLabel()));
            RecordFile record = (RecordFile) ConnectionHelper.getPackage(connection.getName(), connection, RecordFile.class);
            if (record != null) {
                // hywang
                PackageHelper.addMetadataTable(metadataTable, record);
            } else {
                RecordFile newrecord = RecordFactory.eINSTANCE.createRecordFile();
                ConnectionHelper.addPackage(newrecord, connection);
                PackageHelper.addMetadataTable(metadataTable, newrecord);
            }
            creation = true;
        } else {
            return;
        }
        initContextMode(item);
        openJSONSchemaWizard(item, metadataTable, false, creation);
    }
}
Also used : JSONFileConnection(org.talend.repository.model.json.JSONFileConnection) RecordFile(orgomg.cwm.resource.record.RecordFile) MetadataTable(org.talend.core.model.metadata.builder.connection.MetadataTable) JSONFileConnectionItem(org.talend.repository.model.json.JSONFileConnectionItem) ERepositoryObjectType(org.talend.core.model.repository.ERepositoryObjectType)

Aggregations

RecordFile (orgomg.cwm.resource.record.RecordFile)8 MetadataTable (org.talend.core.model.metadata.builder.connection.MetadataTable)6 CoreException (org.eclipse.core.runtime.CoreException)3 PersistenceException (org.talend.commons.exception.PersistenceException)3 IOException (java.io.IOException)2 SQLException (java.sql.SQLException)2 IProxyRepositoryFactory (org.talend.repository.model.IProxyRepositoryFactory)2 Path (org.eclipse.core.runtime.Path)1 EList (org.eclipse.emf.common.util.EList)1 Connection (org.talend.core.model.metadata.builder.connection.Connection)1 DatabaseConnection (org.talend.core.model.metadata.builder.connection.DatabaseConnection)1 SalesforceModuleUnit (org.talend.core.model.metadata.builder.connection.SalesforceModuleUnit)1 SalesforceSchemaConnection (org.talend.core.model.metadata.builder.connection.SalesforceSchemaConnection)1 ConnectionItem (org.talend.core.model.properties.ConnectionItem)1 ItemState (org.talend.core.model.properties.ItemState)1 Property (org.talend.core.model.properties.Property)1 SalesforceSchemaConnectionItem (org.talend.core.model.properties.SalesforceSchemaConnectionItem)1 ERepositoryObjectType (org.talend.core.model.repository.ERepositoryObjectType)1 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)1 ProxyRepositoryFactory (org.talend.core.repository.model.ProxyRepositoryFactory)1