use of org.talend.repository.generic.model.genericMetadata.GenericConnection in project tdi-studio-se by Talend.
the class GenericDragAndDropHandler method getCorrespondingComponentName.
@Override
public IComponentName getCorrespondingComponentName(Item item, ERepositoryObjectType type) {
RepositoryComponentSetting setting = null;
List<Class<Item>> list = new ArrayList<Class<Item>>();
if (item instanceof GenericConnectionItem) {
GenericConnection connection = (GenericConnection) ((GenericConnectionItem) item).getConnection();
setting = new RepositoryComponentSetting();
setting.setWithSchema(true);
String componentMainName = getComponentMainName(connection);
setting.setInputComponent(getInputComponentName(componentMainName));
setting.setOutputComponent(getOutputComponentName(componentMainName));
Class clazz = null;
try {
clazz = Class.forName(GenericConnectionItem.class.getName());
} catch (ClassNotFoundException e) {
ExceptionHandler.process(e);
}
list.add(clazz);
setting.setClasses(list.toArray(new Class[0]));
}
return setting;
}
use of org.talend.repository.generic.model.genericMetadata.GenericConnection in project tdi-studio-se by Talend.
the class GenericDragAndDropHandler method isValid.
private boolean isValid(RepositoryNode seletetedNode, IComponent component) {
// TUP-4151
IRepositoryViewObject object = seletetedNode.getObject();
if (component == null || object == null) {
return false;
}
ComponentProperties currentComponentProperties = null;
if (object instanceof RepositoryViewObject) {
RepositoryViewObject repositoryViewObj = (RepositoryViewObject) object;
Connection connection = ((ConnectionItem) repositoryViewObj.getProperty().getItem()).getConnection();
if (canHandle(connection)) {
GenericConnection genericConnection = (GenericConnection) connection;
currentComponentProperties = ComponentsUtils.getComponentPropertiesFromSerialized(genericConnection.getCompProperties(), connection);
}
} else if (object instanceof MetadataTableRepositoryObject) {
MetadataTableRepositoryObject metaTableRepObj = (MetadataTableRepositoryObject) object;
currentComponentProperties = SchemaUtils.getCurrentComponentProperties(metaTableRepObj);
} else if (object instanceof MetadataColumnRepositoryObject) {
MetadataColumnRepositoryObject metaColumnRepObj = (MetadataColumnRepositoryObject) object;
ModelElement element = metaColumnRepObj.getTdColumn();
if (element != null && element.eContainer() instanceof MetadataTable) {
MetadataTable metadataTable = (MetadataTable) element.eContainer();
IMetadataTable newTable = MetadataToolHelper.convert(metadataTable);
currentComponentProperties = SchemaUtils.getCurrentComponentProperties(newTable);
}
}
if (currentComponentProperties != null) {
try {
List<ComponentDefinition> possibleComponents = ComponentsUtils.getComponentService().getPossibleComponents(currentComponentProperties);
if (component instanceof Component) {
ComponentDefinition componentDefinition = ((Component) component).getComponentDefinition();
return possibleComponents.contains(componentDefinition);
}
} catch (Throwable e) {
e.printStackTrace();
}
}
return false;
}
use of org.talend.repository.generic.model.genericMetadata.GenericConnection in project tdi-studio-se by Talend.
the class GenericWizardService method getConnectionProperties.
@Override
public String getConnectionProperties(Connection connection) {
if (isGenericConnection(connection)) {
GenericConnection genericConnection = (GenericConnection) connection;
String compProperties = genericConnection.getCompProperties();
return compProperties;
}
return null;
}
use of org.talend.repository.generic.model.genericMetadata.GenericConnection 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;
}
use of org.talend.repository.generic.model.genericMetadata.GenericConnection in project tdi-studio-se by Talend.
the class GenericConnectionUtil method synNamePropertyWithItem.
/**
* Syncronize the value of <code>name</code> property between component properties and connection item.
*
* @param item the item which name property belong to.
* @return return true if property is updated, otherwise return false;
*/
public static boolean synNamePropertyWithItem(GenericConnectionItem item) {
GenericConnection connection = (GenericConnection) item.getConnection();
String compPropertiesStr = connection.getCompProperties();
if (compPropertiesStr == null) {
return false;
}
ComponentProperties componentProperties = ComponentsUtils.getComponentPropertiesFromSerialized(compPropertiesStr, connection);
if (componentProperties == null) {
return false;
}
Property nameProperty = (Property) componentProperties.getProperty(IGenericConstants.NAME_PROPERTY);
if (nameProperty == null) {
return false;
}
Object namePropertyVal = nameProperty.getValue();
String newName = item.getProperty().getLabel();
if (newName != null && !newName.equals(namePropertyVal)) {
nameProperty.setValue(newName);
connection.setCompProperties(componentProperties.toSerialized());
return true;
}
return false;
}
Aggregations