use of org.talend.core.model.metadata.builder.connection.MetadataColumn in project tdi-studio-se by Talend.
the class MetadataColumnComparator method isDiff.
/**
* dev Comment method "isDiff".
*
* @param node
* @return
*/
@SuppressWarnings("unchecked")
public boolean[] isDiff(RepositoryNode node) {
boolean isDiffDivergency = false;
boolean isDiffSyschronize = false;
boolean isDiffGray = false;
Object type = node.getProperties(EProperties.CONTENT_TYPE);
if (type.equals(RepositoryNodeType.DATABASE)) {
DatabaseConnection connection = (DatabaseConnection) getItem(node).getConnection();
Set<MetadataTable> tables = ConnectionHelper.getTables(connection);
for (MetadataTable table : tables) {
List<MetadataColumn> columns = table.getColumns();
for (MetadataColumn column : columns) {
if (column.isDivergency()) {
isDiffDivergency = true;
}
if (column.isSynchronised()) {
isDiffSyschronize = true;
}
if (column.getLabel() == null || "".equals(column.getLabel())) {
//$NON-NLS-1$
isDiffGray = true;
}
}
if (table.isDivergency()) {
isDiffDivergency = true;
}
if (table.getLabel() == null || "".equals(table.getLabel())) {
//$NON-NLS-1$
isDiffGray = true;
}
}
} else if (type.equals(RepositoryNodeType.TABLE)) {
MetadataTableRepositoryObject object = (MetadataTableRepositoryObject) node.getObject();
MetadataTable table = object.getTable();
List<MetadataColumn> columns = table.getColumns();
for (MetadataColumn column : columns) {
if (column.isDivergency()) {
isDiffDivergency = true;
}
if (column.isSynchronised()) {
isDiffSyschronize = true;
}
if (column.getLabel() == null || "".equals(column.getLabel())) {
//$NON-NLS-1$
isDiffGray = true;
}
}
if (table.isDivergency()) {
isDiffDivergency = true;
}
}
return new boolean[] { isDiffGray, isDiffDivergency, isDiffSyschronize };
}
use of org.talend.core.model.metadata.builder.connection.MetadataColumn in project tdi-studio-se by Talend.
the class MetadataColumnComparator method modifyOldOneColumnFromEMF.
/**
* dev Comment method "modifyOldOneColumnFromEMF".
*
* @param cloumnsFromEMF
* @param db
*/
private void modifyOldOneColumnFromEMF(List<MetadataColumn> cloumnsFromEMF, MetadataColumn db) {
boolean flag = true;
for (MetadataColumn emf : cloumnsFromEMF) {
if (db.getOriginalField().equals(emf.getOriginalField())) {
flag = false;
break;
}
}
if (flag) {
MetadataColumn column = ConnectionFactory.eINSTANCE.createMetadataColumn();
column.setOriginalField(db.getOriginalField());
//$NON-NLS-1$
column.setLabel("");
cloumnsFromEMF.add(column);
}
}
use of org.talend.core.model.metadata.builder.connection.MetadataColumn in project tdi-studio-se by Talend.
the class MetadataColumnComparator method modifyOldOneColumnFromDB.
/**
* dev Comment method "modifyOldOneColumnFromDB".
*
* @param columnsFromDB
* @param connAndTableLabel
* @param emf
*/
private void modifyOldOneColumnFromDB(List<MetadataColumn> columnsFromDB, MetadataColumn emf) {
boolean flag = true;
for (MetadataColumn db : columnsFromDB) {
if (db.getOriginalField().equals(emf.getOriginalField())) {
flag = false;
if (emf.getLabel().length() != 0) {
boolean is = !isEquivalent(db, emf);
emf.setDivergency(is);
emf.setSynchronised(is);
}
}
}
if (flag) {
//$NON-NLS-1$
emf.setOriginalField(" ");
emf.setDivergency(true);
emf.setSynchronised(false);
}
}
use of org.talend.core.model.metadata.builder.connection.MetadataColumn 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 org.talend.core.model.metadata.builder.connection.MetadataColumn in project tdi-studio-se by Talend.
the class ImportTreeFromRepository method isMappedChild.
private boolean isMappedChild(String tempXpath) {
if (targetAbsolutePath == null) {
targetAbsolutePath = new HashMap<String, String>();
targetDatePattern = new HashMap<String, String>();
targetAbsolutePath.put(absoluteXPathQuery, null);
Pattern regex = Pattern.compile(RELATIVE_PATH_PATTERN, Pattern.CANON_EQ | Pattern.CASE_INSENSITIVE | Pattern.MULTILINE);
for (int n = 0; n < schemaTargets.size(); n++) {
Object obj = schemaTargets.get(n);
String relativeXPathQuery = "";
if (obj instanceof SchemaTarget) {
relativeXPathQuery = ((SchemaTarget) obj).getRelativeXPathQuery();
} else if (obj instanceof ConceptTarget) {
relativeXPathQuery = ((ConceptTarget) obj).getRelativeLoopExpression();
}
StringBuffer tempAbsolute = new StringBuffer();
tempAbsolute.append(absoluteXPathQuery);
tempAbsolute.append(XmlMapUtil.XPATH_SEPARATOR);
tempAbsolute.append(relativeXPathQuery);
if (relativeXPathQuery.startsWith(RELATIVE_PATH)) {
Matcher regexMatcher = regex.matcher(relativeXPathQuery);
int relativeLength = 0;
while (regexMatcher.find()) {
relativeLength++;
}
if (relativeLength > 0) {
String subRelativeQuery = relativeXPathQuery.substring(relativeLength * RELATIVE_PATH.length(), relativeXPathQuery.length());
String[] absoluteSplit = absoluteXPathQuery.split(XmlMapUtil.XPATH_SEPARATOR);
if (absoluteSplit.length > relativeLength) {
tempAbsolute = new StringBuffer();
for (int i = 0; i < absoluteSplit.length - relativeLength; i++) {
tempAbsolute.append(absoluteSplit[i]);
tempAbsolute.append(XmlMapUtil.XPATH_SEPARATOR);
}
tempAbsolute.append(subRelativeQuery);
}
}
}
if (metadataTable != null && n < metadataTable.getColumns().size()) {
MetadataColumn column = metadataTable.getColumns().get(n);
targetAbsolutePath.put(tempAbsolute.toString(), column.getTalendType());
targetDatePattern.put(tempAbsolute.toString(), column.getPattern());
} else {
targetAbsolutePath.put(tempAbsolute.toString(), null);
targetDatePattern.put(tempAbsolute.toString(), null);
}
}
}
for (String absTarget : targetAbsolutePath.keySet()) {
if (absTarget.startsWith(tempXpath)) {
return true;
}
}
return false;
}
Aggregations