Search in sources :

Example 46 with MetadataTable

use of org.talend.core.model.metadata.builder.connection.MetadataTable in project tdi-studio-se by Talend.

the class GenericWizardService method getAllComponentProperties.

@Override
public List<ComponentProperties> getAllComponentProperties(Connection connection, String tableLabel) {
    List<ComponentProperties> componentProperties = new ArrayList<>();
    if (isGenericConnection(connection)) {
        GenericConnection genericConnection = (GenericConnection) connection;
        String compProperties = genericConnection.getCompProperties();
        ComponentProperties cp = ComponentsUtils.getComponentPropertiesFromSerialized(compProperties, connection, false);
        if (cp != null) {
            componentProperties.add(cp);
        }
        List<MetadataTable> metadataTables;
        if (tableLabel == null) {
            metadataTables = SchemaUtils.getMetadataTables(genericConnection, SubContainer.class);
        } else {
            metadataTables = Arrays.asList(SchemaUtils.getMetadataTable(genericConnection, tableLabel, SubContainer.class));
        }
        for (MetadataTable metadataTable : metadataTables) {
            if (metadataTable == null) {
                continue;
            }
            for (TaggedValue taggedValue : metadataTable.getTaggedValue()) {
                if (IComponentConstants.COMPONENT_PROPERTIES_TAG.equals(taggedValue.getTag())) {
                    ComponentProperties compPros = ComponentsUtils.getComponentPropertiesFromSerialized(taggedValue.getValue(), connection, false);
                    if (compPros != null && !componentProperties.contains(compPros)) {
                        compPros.updateNestedProperties(cp);
                        componentProperties.add(compPros);
                    }
                }
            }
        }
    }
    return componentProperties;
}
Also used : ComponentProperties(org.talend.components.api.properties.ComponentProperties) TaggedValue(orgomg.cwm.objectmodel.core.TaggedValue) ArrayList(java.util.ArrayList) IMetadataTable(org.talend.core.model.metadata.IMetadataTable) MetadataTable(org.talend.core.model.metadata.builder.connection.MetadataTable) GenericConnection(org.talend.repository.generic.model.genericMetadata.GenericConnection) SubContainer(org.talend.repository.generic.model.genericMetadata.SubContainer)

Example 47 with MetadataTable

use of org.talend.core.model.metadata.builder.connection.MetadataTable in project tdi-studio-se by Talend.

the class DynamicComposite method resetParameters.

public List<ElementParameter> resetParameters() {
    final List<ElementParameter> newParameters = new ArrayList<>();
    List<ElementParameter> currentParameters = (List<ElementParameter>) element.getElementParameters();
    List<ElementParameter> parameters = new ArrayList<>();
    ComponentService componentService = internalService.getComponentService();
    Connection theConnection = null;
    if (connectionItem != null) {
        theConnection = connectionItem.getConnection();
    }
    Properties properties = null;
    PropertyValueEvaluator evaluator = null;
    if (element instanceof FakeElement) {
        properties = form.getProperties();
        evaluator = new MetadataContextPropertyValueEvaluator(theConnection);
        currentParameters.clear();
    } else {
        properties = ((INode) element).getComponentProperties();
        evaluator = new ComponentContextPropertyValueEvaluator((INode) element);
    }
    if (properties instanceof ComponentProperties) {
        if (form != null) {
            properties.setValueEvaluator(evaluator);
            properties.refreshLayout(form);
        }
        // For context display.
        properties.setValueEvaluator(null);
        boolean isInitializing = false;
        if (element instanceof INode) {
            INode node = (INode) element;
            IComponent component = node.getComponent();
            if (component instanceof AbstractBasicComponent) {
                isInitializing = ((AbstractBasicComponent) component).isInitializing();
            }
        }
        parameters = ComponentsUtils.getParametersFromForm(element, isInitializing, section, (ComponentProperties) properties, form);
        addUpdateParameterIfNotExist(parameters);
        properties.setValueEvaluator(evaluator);
    }
    for (ElementParameter parameter : parameters) {
        if (parameter instanceof GenericElementParameter) {
            GenericElementParameter genericElementParameter = (GenericElementParameter) parameter;
            genericElementParameter.setComponentService(componentService);
            genericElementParameter.setDrivedByForm(drivedByForm);
            genericElementParameter.callBeforePresent();
            genericElementParameter.removePropertyChangeListener(this);
            genericElementParameter.addPropertyChangeListener(this);
            if (wizardPropertyChangeListener != null && IGenericConstants.NAME_PROPERTY.equals(parameter.getName())) {
                genericElementParameter.addPropertyChangeListener(wizardPropertyChangeListener);
            }
            if (EParameterFieldType.SCHEMA_REFERENCE.equals(genericElementParameter.getFieldType())) {
                if (genericElementParameter.getChildParameters().size() == 0) {
                    IElementParameter schemaParameter = element.getElementParameterFromField(EParameterFieldType.SCHEMA_REFERENCE, section);
                    genericElementParameter.getChildParameters().putAll(schemaParameter.getChildParameters());
                }
            } else if (EParameterFieldType.NAME_SELECTION_AREA.equals(genericElementParameter.getFieldType()) && theConnection != null) {
                List<NamedThing> values = new ArrayList<>();
                List<MetadataTable> metadataTables = SchemaUtils.getMetadataTables(theConnection, SubContainer.class);
                List<String> tableLabels = new ArrayList<>();
                for (MetadataTable metaTable : metadataTables) {
                    tableLabels.add(metaTable.getLabel());
                }
                List<NamedThing> possibleValues = ComponentsUtils.getFormalPossibleValues(genericElementParameter);
                for (NamedThing possibleValue : possibleValues) {
                    if (tableLabels.contains(possibleValue.getName())) {
                        values.add(possibleValue);
                    }
                }
                genericElementParameter.setValue(values);
            }
            if (properties != null && isRepository(element)) {
                String repositoryValue = genericElementParameter.getRepositoryValue();
                if (genericElementParameter.isShow(currentParameters) && (repositoryValue != null) && (!genericElementParameter.getName().equals(EParameterName.PROPERTY_TYPE.getName())) && genericElementParameter.getCategory() == section) {
                    org.talend.daikon.properties.property.Property property = properties.getValuedProperty(genericElementParameter.getName());
                    if (property != null && property.getTaggedValue(IGenericConstants.REPOSITORY_VALUE) != null) {
                        genericElementParameter.setRepositoryValueUsed(true);
                        genericElementParameter.setReadOnly(true);
                    }
                }
            }
        }
    }
    boolean added = false;
    for (ElementParameter currentParameter : currentParameters) {
        if (EParameterName.UPDATE_COMPONENTS.getName().equals(currentParameter.getName())) {
            currentParameter.setValue(true);
        }
        if (currentParameter.isSerialized() && currentParameter.getCategory().equals(section)) {
            if (!added) {
                newParameters.addAll(parameters);
                added = true;
            }
            continue;
        }
        newParameters.add(currentParameter);
    }
    if (element instanceof FakeElement) {
        newParameters.addAll(reverseParameters(parameters));
    }
    element.setElementParameters(newParameters);
    return newParameters;
}
Also used : INode(org.talend.core.model.process.INode) ComponentProperties(org.talend.components.api.properties.ComponentProperties) IComponent(org.talend.core.model.components.IComponent) ArrayList(java.util.ArrayList) PropertyValueEvaluator(org.talend.daikon.properties.property.PropertyValueEvaluator) ComponentContextPropertyValueEvaluator(org.talend.designer.core.generic.context.ComponentContextPropertyValueEvaluator) MetadataContextPropertyValueEvaluator(org.talend.metadata.managment.ui.wizard.context.MetadataContextPropertyValueEvaluator) IElementParameterEventProperties(org.talend.designer.core.generic.constants.IElementParameterEventProperties) IContextEventProperties(org.talend.designer.core.generic.constants.IContextEventProperties) ComponentProperties(org.talend.components.api.properties.ComponentProperties) ComponentReferenceProperties(org.talend.components.api.properties.ComponentReferenceProperties) Properties(org.talend.daikon.properties.Properties) GenericElementParameter(org.talend.designer.core.generic.model.GenericElementParameter) IElementParameter(org.talend.core.model.process.IElementParameter) ElementParameter(org.talend.designer.core.model.components.ElementParameter) GenericElementParameter(org.talend.designer.core.generic.model.GenericElementParameter) MetadataTable(org.talend.core.model.metadata.builder.connection.MetadataTable) IElementParameter(org.talend.core.model.process.IElementParameter) List(java.util.List) ArrayList(java.util.ArrayList) ComponentService(org.talend.components.api.service.ComponentService) GenericConnection(org.talend.repository.generic.model.genericMetadata.GenericConnection) Connection(org.talend.core.model.metadata.builder.connection.Connection) MetadataContextPropertyValueEvaluator(org.talend.metadata.managment.ui.wizard.context.MetadataContextPropertyValueEvaluator) NamedThing(org.talend.daikon.NamedThing) FakeElement(org.talend.designer.core.model.FakeElement) SubContainer(org.talend.repository.generic.model.genericMetadata.SubContainer) AbstractBasicComponent(org.talend.designer.core.model.components.AbstractBasicComponent) ComponentContextPropertyValueEvaluator(org.talend.designer.core.generic.context.ComponentContextPropertyValueEvaluator)

Example 48 with MetadataTable

use of org.talend.core.model.metadata.builder.connection.MetadataTable in project tdi-studio-se by Talend.

the class GenericUpdateManager method getTableIdAndNameMap.

public static Map<String, String> getTableIdAndNameMap(ConnectionItem connItem) {
    if (connItem == null) {
        return Collections.emptyMap();
    }
    Map<String, String> idAndNameMap = new HashMap<>();
    List<MetadataTable> metadataTables = SchemaUtils.getMetadataTables(connItem.getConnection(), SubContainer.class);
    for (MetadataTable table : metadataTables) {
        idAndNameMap.put(table.getId(), table.getLabel());
    }
    return idAndNameMap;
}
Also used : HashMap(java.util.HashMap) IMetadataTable(org.talend.core.model.metadata.IMetadataTable) MetadataTable(org.talend.core.model.metadata.builder.connection.MetadataTable)

Example 49 with MetadataTable

use of org.talend.core.model.metadata.builder.connection.MetadataTable in project tdi-studio-se by Talend.

the class GenericUpdateManager method getSchemaRenamedMap.

public static Map<String, String> getSchemaRenamedMap(ConnectionItem connItem, Map<String, String> oldTableMap) {
    if (connItem == null || oldTableMap == null) {
        return Collections.emptyMap();
    }
    Map<String, String> schemaRenamedMap = new HashMap<>();
    final String prefix = connItem.getProperty().getId() + UpdatesConstants.SEGMENT_LINE;
    List<MetadataTable> metadataTables = SchemaUtils.getMetadataTables(connItem.getConnection(), SubContainer.class);
    for (MetadataTable table : metadataTables) {
        String oldName = oldTableMap.get(table.getId());
        String newName = table.getLabel();
        if (oldName != null && !oldName.equals(newName)) {
            schemaRenamedMap.put(prefix + oldName, prefix + newName);
        }
    }
    return schemaRenamedMap;
}
Also used : HashMap(java.util.HashMap) IMetadataTable(org.talend.core.model.metadata.IMetadataTable) MetadataTable(org.talend.core.model.metadata.builder.connection.MetadataTable)

Example 50 with MetadataTable

use of org.talend.core.model.metadata.builder.connection.MetadataTable in project tdi-studio-se by Talend.

the class JSONFileSchemaDialog method createDialogArea.

@Override
protected Control createDialogArea(Composite parent) {
    Composite composite = (Composite) super.createDialogArea(parent);
    composite.setLayout(new FillLayout());
    tableEditor = new MetadataEmfTableEditor("");
    MetadataTable metadataTable = form.getMetadataTable();
    tableEditor.setMetadataTable(metadataTable);
    // tableEditor.removeAll();
    List<MetadataColumn> list = (List<MetadataColumn>) form.getSchemaViewer().getInput();
    tableEditor.addAll(list);
    // if (list.size() > 0) {
    // for (MetadataColumn column : list) {
    // boolean toAdd = true;
    // for (int i = 0; i < currentColumnList.size(); i++) {
    // String label = column.getLabel();
    // String curLabel = currentColumnList.get(i).getLabel();
    // if (label.equals(curLabel)) {
    // toAdd = false;
    // break;
    // }
    // }
    // if (toAdd) {
    // tableEditor.add(column);
    // }
    // }
    // }
    tableEditorView = new MetadataEmfTableEditorView(composite, SWT.NONE);
    tableEditorView.setMetadataEditor(tableEditor);
    addListeners();
    return composite;
}
Also used : MetadataEmfTableEditorView(org.talend.core.ui.metadata.editor.MetadataEmfTableEditorView) MetadataColumn(org.talend.core.model.metadata.builder.connection.MetadataColumn) Composite(org.eclipse.swt.widgets.Composite) MetadataEmfTableEditor(org.talend.core.ui.metadata.editor.MetadataEmfTableEditor) MetadataTable(org.talend.core.model.metadata.builder.connection.MetadataTable) List(java.util.List) FillLayout(org.eclipse.swt.layout.FillLayout)

Aggregations

MetadataTable (org.talend.core.model.metadata.builder.connection.MetadataTable)76 ArrayList (java.util.ArrayList)26 IMetadataTable (org.talend.core.model.metadata.IMetadataTable)24 MetadataColumn (org.talend.core.model.metadata.builder.connection.MetadataColumn)22 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)18 List (java.util.List)14 DatabaseConnection (org.talend.core.model.metadata.builder.connection.DatabaseConnection)13 PersistenceException (org.talend.commons.exception.PersistenceException)11 ConnectionItem (org.talend.core.model.properties.ConnectionItem)10 MetadataTableRepositoryObject (org.talend.core.repository.model.repositoryObject.MetadataTableRepositoryObject)10 RepositoryNode (org.talend.repository.model.RepositoryNode)10 DatabaseConnectionItem (org.talend.core.model.properties.DatabaseConnectionItem)9 TaggedValue (orgomg.cwm.objectmodel.core.TaggedValue)9 HashMap (java.util.HashMap)8 Schema (org.apache.avro.Schema)7 ComponentProperties (org.talend.components.api.properties.ComponentProperties)7 SAPFunctionUnit (org.talend.core.model.metadata.builder.connection.SAPFunctionUnit)7 IElementParameter (org.talend.core.model.process.IElementParameter)7 Map (java.util.Map)6 IProxyRepositoryFactory (org.talend.repository.model.IProxyRepositoryFactory)6