use of orgomg.cwm.objectmodel.core.TaggedValue in project tdi-studio-se by Talend.
the class RepositoryUpdateTest method prepareTableForTest.
private MetadataTable prepareTableForTest(String id) {
MetadataTable table = ConnectionFactory.eINSTANCE.createMetadataTable();
table.setLabel("myTableTest");
MetadataColumn col1 = ConnectionFactory.eINSTANCE.createMetadataColumn();
col1.setLabel("myColumn1");
col1.setTalendType(JavaTypesManager.STRING.getId());
col1.setLength(25);
table.getColumns().add(col1);
Schema avroSchema = MetadataToolAvroHelper.convertToAvro(table);
TaggedValue tv = CoreFactory.eINSTANCE.createTaggedValue();
tv.setTag(IComponentConstants.COMPONENT_PROPERTIES_TAG);
SalesforceModuleProperties smp = new SalesforceModuleProperties("test");
smp.connection.init();
// because we should get connection always from the main
smp.connection.userPassword.userId.setValue("old");
// SalesforceConnectionProperties
smp.moduleName.setStoredValue("myModule");
smp.main.schema.setStoredValue(avroSchema);
GenericRepository gr = new GenericRepository();
gr.storeProperties(smp, table.getLabel(), id + "#", "main.schema");
return table;
}
use of orgomg.cwm.objectmodel.core.TaggedValue in project tdi-studio-se by Talend.
the class NewDelimitedFileWizardMigrationTask method updateMetadataTable.
@Override
protected boolean updateMetadataTable(Connection oldConnection, Connection genericConnection, ComponentProperties componentProperties) {
boolean modified = false;
if (oldConnection == null || genericConnection == null || componentProperties == null) {
return modified;
}
Set<MetadataTable> tables = ConnectionHelper.getTables(oldConnection);
Set<MetadataTable> newTables = new HashSet<>(tables);
for (MetadataTable metaTable : newTables) {
TaggedValue serializedPropsTV = CoreFactory.eINSTANCE.createTaggedValue();
serializedPropsTV.setTag(IComponentConstants.COMPONENT_PROPERTIES_TAG);
serializedPropsTV.setValue(componentProperties.toSerialized());
metaTable.getTaggedValue().add(serializedPropsTV);
TaggedValue schemaPropertyTV = CoreFactory.eINSTANCE.createTaggedValue();
schemaPropertyTV.setTag(IComponentConstants.COMPONENT_SCHEMA_TAG);
schemaPropertyTV.setValue(SCHEMA);
metaTable.getTaggedValue().add(schemaPropertyTV);
((orgomg.cwm.objectmodel.core.Package) genericConnection).getOwnedElement().add(metaTable);
Schema schema = SchemaUtils.convertTalendSchemaIntoComponentSchema(metaTable);
componentProperties.setValue(SCHEMA, schema);
modified = true;
}
return modified;
}
use of orgomg.cwm.objectmodel.core.TaggedValue in project tdi-studio-se by Talend.
the class NewSalesforceWizardMigrationTask method updateMetadataTable.
@Override
protected boolean updateMetadataTable(Connection oldConnection, Connection genericConnection, ComponentProperties componentProperties) {
boolean modified = false;
if (oldConnection == null || genericConnection == null || componentProperties == null) {
return modified;
}
Set<MetadataTable> tables = ConnectionHelper.getTables(oldConnection);
Set<MetadataTable> newTables = new HashSet<>();
newTables.addAll(tables);
for (MetadataTable metaTable : newTables) {
try {
Object object = ReflectionUtils.newInstance(REFLECTION_SALESFORCE_MODULE_PROPERTIES, componentProperties.getClass().getClassLoader(), new Object[] { metaTable.getName() });
if (object != null && object instanceof ComponentProperties) {
ComponentProperties salesforceModuleProperties = (ComponentProperties) object;
//$NON-NLS-1$
salesforceModuleProperties.getProperties("connection").copyValuesFrom(componentProperties, true, false);
//$NON-NLS-1$
NamedThing tmp = salesforceModuleProperties.getProperty("moduleName");
//$NON-NLS-1$
((Property) tmp).setTaggedValue(IGenericConstants.REPOSITORY_VALUE, "moduleName");
((Property) tmp).setValue(metaTable.getLabel());
TaggedValue serializedPropsTV = CoreFactory.eINSTANCE.createTaggedValue();
serializedPropsTV.setTag(IComponentConstants.COMPONENT_PROPERTIES_TAG);
serializedPropsTV.setValue(salesforceModuleProperties.toSerialized());
metaTable.getTaggedValue().add(serializedPropsTV);
TaggedValue schemaPropertyTV = CoreFactory.eINSTANCE.createTaggedValue();
schemaPropertyTV.setTag(IComponentConstants.COMPONENT_SCHEMA_TAG);
schemaPropertyTV.setValue(SCHEMA_SCHEMA);
metaTable.getTaggedValue().add(schemaPropertyTV);
Schema schema = SchemaUtils.convertTalendSchemaIntoComponentSchema(metaTable);
salesforceModuleProperties.setValue(SCHEMA_SCHEMA, schema);
((orgomg.cwm.objectmodel.core.Package) genericConnection).getOwnedElement().add(metaTable);
modified = true;
}
} catch (Exception e) {
ExceptionHandler.process(e);
}
}
return modified;
}
use of orgomg.cwm.objectmodel.core.TaggedValue in project tdi-studio-se by Talend.
the class SchemaUtils method getCurrentComponentProperties.
public static ComponentProperties getCurrentComponentProperties(IMetadataTable table) {
if (table != null) {
String serializedProperties = null;
SerializerDeserializer.Deserialized<ComponentProperties> fromSerializedProperties = null;
if (table instanceof MetadataTableRepositoryObject) {
MetadataTableRepositoryObject metaTableRepObj = (MetadataTableRepositoryObject) table;
MetadataTable metadataTable = metaTableRepObj.getTable();
if (metadataTable != null && metadataTable.getTaggedValue() != null) {
for (TaggedValue serializedProps : metadataTable.getTaggedValue()) {
if (IComponentConstants.COMPONENT_PROPERTIES_TAG.equals(serializedProps.getTag())) {
serializedProperties = serializedProps.getValue();
break;
}
}
}
if (serializedProperties != null) {
Connection connection = ((ConnectionItem) metaTableRepObj.getViewObject().getProperty().getItem()).getConnection();
return ComponentsUtils.getComponentPropertiesFromSerialized(serializedProperties, connection);
}
} else if (table instanceof org.talend.core.model.metadata.MetadataTable) {
org.talend.core.model.metadata.MetadataTable metaTable = (org.talend.core.model.metadata.MetadataTable) table;
Map<String, String> additionalProperties = metaTable.getAdditionalProperties();
serializedProperties = additionalProperties.get(IComponentConstants.COMPONENT_PROPERTIES_TAG);
if (serializedProperties != null) {
fromSerializedProperties = Properties.Helper.fromSerializedPersistent(serializedProperties, ComponentProperties.class, null);
}
}
if (fromSerializedProperties != null) {
return fromSerializedProperties.object;
}
}
return null;
}
use of orgomg.cwm.objectmodel.core.TaggedValue 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;
}
Aggregations