Search in sources :

Example 1 with TalendFileFactory

use of org.talend.designer.core.model.utils.emf.talendfile.TalendFileFactory in project tdi-studio-se by Talend.

the class ReplaceMultiFlowBytReplicateMigrationTask method addtReplicateComponent.

/**
     * DOC nrousseau Comment method "addtReplicateComponent".
     * 
     * @param processType
     * @param replicatePos
     * @param connections
     */
private void addtReplicateComponent(ProcessType processType, Point replicatePos, NodeType nodeTypeSource, String sourceName, INodeConnector nodeConnector, List<ConnectionType> connections) {
    TalendFileFactory fileFact = TalendFileFactory.eINSTANCE;
    // create the node
    String uniqueName = createNodeType(processType, replicatePos, nodeTypeSource, sourceName, nodeConnector, connections, fileFact);
    // create the connection from source component to tReplicate
    createConnectionType(processType, sourceName, nodeConnector, fileFact, uniqueName);
}
Also used : TalendFileFactory(org.talend.designer.core.model.utils.emf.talendfile.TalendFileFactory)

Example 2 with TalendFileFactory

use of org.talend.designer.core.model.utils.emf.talendfile.TalendFileFactory in project tdi-studio-se by Talend.

the class ElementParameter2ParameterType method loadElementParameters.

/**
     *
     * load project settings to no-opened process
     *
     * @param elemParam
     * @param projectPaType
     */
public static void loadElementParameters(ParametersType processType, ParametersType projectPaType, EParameterName paramName) {
    EList listParamType = projectPaType.getElementParameter();
    for (int j = 0; j < listParamType.size(); j++) {
        ElementParameterType pType = (ElementParameterType) listParamType.get(j);
        EList processParameters = processType.getElementParameter();
        ElementParameterType processParam = null;
        for (int i = 0; i < processParameters.size(); i++) {
            ElementParameterType paramType = (ElementParameterType) processParameters.get(i);
            if (paramType.getName().equals(pType.getName()) && paramType.getField() != null && paramType.getField().equals(pType.getField())) {
                processParam = paramType;
            } else if (pType.getName().contains(":")) {
                //$NON-NLS-1$
                StringTokenizer token = new StringTokenizer(pType.getName(), ":");
                String parentId = token.nextToken();
                String childId = token.nextToken();
                String[] split = paramType.getName().split(":");
                if (split.length != 2) {
                    continue;
                }
                String complexName = paramName + ":" + childId;
                if (complexName.equals(paramType.getName())) {
                    processParam = paramType;
                }
            }
            if (processParam != null) {
                break;
            }
        }
        if (processParam != null) {
            processParam.setValue(pType.getValue());
        } else {
            TalendFileFactory fileFact = TalendFileFactory.eINSTANCE;
            ElementParameterType processTypes = fileFact.createElementParameterType();
            processTypes.setName(pType.getName());
            processTypes.setField(pType.getField());
            processTypes.setValue(pType.getValue());
            processType.getElementParameter().add(processTypes);
        }
    }
}
Also used : ElementParameterType(org.talend.designer.core.model.utils.emf.talendfile.ElementParameterType) StringTokenizer(java.util.StringTokenizer) EList(org.eclipse.emf.common.util.EList) TalendFileFactory(org.talend.designer.core.model.utils.emf.talendfile.TalendFileFactory)

Example 3 with TalendFileFactory

use of org.talend.designer.core.model.utils.emf.talendfile.TalendFileFactory in project tdi-studio-se by Talend.

the class ProjectSettingManager method loadImplicitContextLoadPreferenceToProject.

/**
     *
     * Load ImplicitContextLoad Preference setting to Project only Load Once
     *
     * @param pro
     */
private static void loadImplicitContextLoadPreferenceToProject(Project pro) {
    TalendFileFactory talendF = TalendFileFactory.eINSTANCE;
    ImplicitContextSettings implicit = PropertiesFactory.eINSTANCE.createImplicitContextSettings();
    pro.getEmfProject().setImplicitContextSettings(implicit);
    implicit.setParameters(talendF.createParametersType());
    ParametersType pType = implicit.getParameters();
    IElement elem = pro.getInitialContextLoad();
    if (elem == null) {
        elem = new ImplicitContextLoadElement();
        ProjectSettingManager.createImplicitContextLoadParameters((ImplicitContextLoadElement) elem);
        pro.setInitialContextLoad(elem);
    }
    ElementParameter2ParameterType.saveElementParameters((Element) elem, pType);
}
Also used : IElement(org.talend.core.model.process.IElement) TalendFileFactory(org.talend.designer.core.model.utils.emf.talendfile.TalendFileFactory) ParametersType(org.talend.designer.core.model.utils.emf.talendfile.ParametersType) ImplicitContextSettings(org.talend.core.model.properties.ImplicitContextSettings)

Example 4 with TalendFileFactory

use of org.talend.designer.core.model.utils.emf.talendfile.TalendFileFactory in project tdi-studio-se by Talend.

the class MetadataEmfFactory method setMetadataTable.

@SuppressWarnings("unchecked")
public void setMetadataTable(final IMetadataTable metadataTable) {
    this.metadataTable = metadataTable;
    TalendFileFactory fileFact = TalendFileFactory.eINSTANCE;
    metadataType = fileFact.createMetadataType();
    IMetadataColumn metaCol;
    ColumnType colType;
    EList listColType;
    metadataType.setComment(metadataTable.getComment());
    metadataType.setName(metadataTable.getTableName());
    metadataType.setLabel(metadataTable.getLabel());
    metadataType.setConnector(metadataTable.getAttachedConnector());
    metadataType.setType(metadataTable.getTableType());
    metadataType.getAdditionalProperties().putAll(metadataTable.getAdditionalProperties());
    listColType = metadataType.getColumn();
    if (metadataTable.getListColumns(true) != null) {
        for (int i = 0; i < metadataTable.getListColumns(true).size(); i++) {
            metaCol = metadataTable.getListColumns(true).get(i);
            colType = fileFact.createColumnType();
            colType.setComment(metaCol.getComment());
            colType.setKey(metaCol.isKey());
            colType.setNullable(metaCol.isNullable());
            if (metaCol.getLength() == null || metaCol.getLength().intValue() < 0) {
                colType.setLength(-1);
            // colType.unsetLength();
            } else {
                colType.setLength(metaCol.getLength());
            }
            if (metaCol.getOriginalLength() != null) {
                colType.setOriginalLength(metaCol.getOriginalLength());
            } else {
                colType.setOriginalLength(-1);
            }
            if (metaCol.getAdditionalField().size() > 0) {
                for (String key : metaCol.getAdditionalField().keySet()) {
                    colType.getAdditionalField().put(key, metaCol.getAdditionalField().get(key));
                }
            }
            colType.setName(metaCol.getLabel());
            if (metaCol.getPrecision() == null || metaCol.getPrecision().intValue() < 0) {
                colType.setPrecision(-1);
            // colType.unsetPrecision();
            } else {
                colType.setPrecision(metaCol.getPrecision());
            }
            if (!metaCol.getLabel().equals(metaCol.getOriginalDbColumnName())) {
                colType.setOriginalDbColumnName(metaCol.getOriginalDbColumnName());
            }
            colType.setType(metaCol.getTalendType());
            colType.setSourceType(metaCol.getType());
            colType.setPattern(metaCol.getPattern());
            colType.setDefaultValue(metaCol.getDefault());
            if (PluginChecker.isDatacertPluginLoaded()) {
                colType.setRelatedEntity(metaCol.getRelatedEntity());
                colType.setRelationshipType(metaCol.getRelationshipType());
            }
            colType.setUsefulColumn(metaCol.isUsefulColumn());
            listColType.add(colType);
        }
    }
}
Also used : ColumnType(org.talend.designer.core.model.utils.emf.talendfile.ColumnType) EList(org.eclipse.emf.common.util.EList) TalendFileFactory(org.talend.designer.core.model.utils.emf.talendfile.TalendFileFactory) IMetadataColumn(org.talend.core.model.metadata.IMetadataColumn)

Example 5 with TalendFileFactory

use of org.talend.designer.core.model.utils.emf.talendfile.TalendFileFactory in project tdi-studio-se by Talend.

the class StatsAndLogsHelper method loadPreferenceToProject.

/**
     * 
     * Load StatsAndLogs Preference setting to Project Only load Once
     * 
     * @param pro
     */
static void loadPreferenceToProject(Project pro) {
    TalendFileFactory talendF = TalendFileFactory.eINSTANCE;
    StatAndLogsSettings stats = PropertiesFactory.eINSTANCE.createStatAndLogsSettings();
    pro.getEmfProject().setStatAndLogsSettings(stats);
    stats.setParameters(talendF.createParametersType());
    ParametersType pType = stats.getParameters();
    StatsAndLogsElement elem = new StatsAndLogsElement();
    pro.setStatsAndLog(elem);
    StatsAndLogsHelper.createStatsAndLogsParameters(elem);
    ElementParameter2ParameterType.saveElementParameters(elem, pType);
}
Also used : TalendFileFactory(org.talend.designer.core.model.utils.emf.talendfile.TalendFileFactory) StatAndLogsSettings(org.talend.core.model.properties.StatAndLogsSettings) ParametersType(org.talend.designer.core.model.utils.emf.talendfile.ParametersType)

Aggregations

TalendFileFactory (org.talend.designer.core.model.utils.emf.talendfile.TalendFileFactory)8 EList (org.eclipse.emf.common.util.EList)3 ColumnType (org.talend.designer.core.model.utils.emf.talendfile.ColumnType)3 ElementParameterType (org.talend.designer.core.model.utils.emf.talendfile.ElementParameterType)3 ArrayList (java.util.ArrayList)2 ImplicitContextSettings (org.talend.core.model.properties.ImplicitContextSettings)2 StatAndLogsSettings (org.talend.core.model.properties.StatAndLogsSettings)2 MetadataType (org.talend.designer.core.model.utils.emf.talendfile.MetadataType)2 NodeType (org.talend.designer.core.model.utils.emf.talendfile.NodeType)2 ParametersType (org.talend.designer.core.model.utils.emf.talendfile.ParametersType)2 ProcessType (org.talend.designer.core.model.utils.emf.talendfile.ProcessType)2 File (java.io.File)1 List (java.util.List)1 StringTokenizer (java.util.StringTokenizer)1 DocumentBuilder (javax.xml.parsers.DocumentBuilder)1 DocumentBuilderFactory (javax.xml.parsers.DocumentBuilderFactory)1 PersistenceException (org.talend.commons.exception.PersistenceException)1 IComponentConversion (org.talend.core.model.components.conversions.IComponentConversion)1 IComponentFilter (org.talend.core.model.components.filters.IComponentFilter)1 NameComponentFilter (org.talend.core.model.components.filters.NameComponentFilter)1