use of orgomg.cwm.resource.record.RecordFile in project tdi-studio-se by Talend.
the class JSONFileOutputStep1Form method updateConnection.
private void updateConnection(String text) {
if (text == null || "".equals(text)) {
return;
}
List<FOXTreeNode> rootFoxTreeNodes = null;
if (JSONFileOutputStep1Form.this.tempPath == null) {
JSONFileOutputStep1Form.this.tempPath = JSONUtil.changeJsonToXml(text);
}
if (treeNode == null) {
rootFoxTreeNodes = TreeUtil.getFoxTreeNodes(JSONFileOutputStep1Form.this.tempPath);
} else {
rootFoxTreeNodes = getCorrespondingFoxTreeNodes(treeNode, true);
}
if (rootFoxTreeNodes.size() == 0) {
return;
}
if (ConnectionHelper.getTables(getConnection()).isEmpty()) {
MetadataTable table = ConnectionFactory.eINSTANCE.createMetadataTable();
RecordFile record = (RecordFile) ConnectionHelper.getPackage(getConnection().getName(), getConnection(), RecordFile.class);
if (record != null) {
// hywang
PackageHelper.addMetadataTable(table, record);
} else {
RecordFile newrecord = RecordFactory.eINSTANCE.createRecordFile();
newrecord.setName(connection.getName());
ConnectionHelper.addPackage(newrecord, connection);
PackageHelper.addMetadataTable(table, newrecord);
}
}
EList schemaMetadataColumn = ConnectionHelper.getTables(getConnection()).toArray(new MetadataTable[0])[0].getColumns();
schemaMetadataColumn.clear();
initMetadataTable(rootFoxTreeNodes, schemaMetadataColumn);
updateConnectionProperties(rootFoxTreeNodes.get(0));
}
use of orgomg.cwm.resource.record.RecordFile in project tdq-studio-se by Talend.
the class UnitTestBuildHelper method initFileConnection.
/**
* create a real file connection witl file url
*
* @param fileUrl
* @param delimitedFileconnection
* @return
*/
public MetadataTable initFileConnection(URL fileUrl, DelimitedFileConnection delimitedFileconnection) {
try {
delimitedFileconnection.setFilePath(FileLocator.toFileURL(fileUrl).toURI().getPath().toString());
// $NON-NLS-1$
delimitedFileconnection.setRowSeparatorValue("\n");
// $NON-NLS-1$
delimitedFileconnection.setEncoding("UTF-8");
// $NON-NLS-1$
delimitedFileconnection.setFieldSeparatorValue(",");
delimitedFileconnection.setName(ERepositoryObjectType.METADATA_FILE_DELIMITED.getKey());
MetadataTable metadataTable = ConnectionFactory.eINSTANCE.createMetadataTable();
// IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
// metadataTable.setId(factory.getNextId());
RecordFile record = (RecordFile) ConnectionHelper.getPackage(delimitedFileconnection.getName(), delimitedFileconnection, RecordFile.class);
if (record != null) {
// hywang
PackageHelper.addMetadataTable(metadataTable, record);
} else {
RecordFile newrecord = RecordFactory.eINSTANCE.createRecordFile();
newrecord.setName(delimitedFileconnection.getName());
ConnectionHelper.addPackage(newrecord, delimitedFileconnection);
PackageHelper.addMetadataTable(metadataTable, newrecord);
}
return metadataTable;
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
use of orgomg.cwm.resource.record.RecordFile in project tdq-studio-se by Talend.
the class UnitTestBuildHelper method initFileConnection.
/**
* create a real file connection witl file url
*
* @param fileUrl
* @param delimitedFileconnection
* @return
*/
public static MetadataTable initFileConnection(URL fileUrl, DelimitedFileConnection delimitedFileconnection) {
try {
delimitedFileconnection.setFilePath(FileLocator.toFileURL(fileUrl).toURI().getPath().toString());
delimitedFileconnection.setRowSeparatorValue("\n");
delimitedFileconnection.setEncoding("UTF-8");
delimitedFileconnection.setFieldSeparatorValue(",");
delimitedFileconnection.setName(ERepositoryObjectType.METADATA_FILE_DELIMITED.getKey());
MetadataTable metadataTable = ConnectionFactory.eINSTANCE.createMetadataTable();
IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
metadataTable.setId(factory.getNextId());
RecordFile record = (RecordFile) ConnectionHelper.getPackage(delimitedFileconnection.getName(), delimitedFileconnection, RecordFile.class);
if (record != null) {
// hywang
PackageHelper.addMetadataTable(metadataTable, record);
} else {
RecordFile newrecord = RecordFactory.eINSTANCE.createRecordFile();
newrecord.setName(delimitedFileconnection.getName());
ConnectionHelper.addPackage(newrecord, delimitedFileconnection);
PackageHelper.addMetadataTable(metadataTable, newrecord);
}
return metadataTable;
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
use of orgomg.cwm.resource.record.RecordFile in project tdq-studio-se by Talend.
the class UnitTestBuildHelper method initFileConnection.
/**
* create a real file connection witl file url
*
* @param fileUrl
* @param delimitedFileconnection
* @return
*/
public MetadataTable initFileConnection(URL fileUrl, DelimitedFileConnection delimitedFileconnection) {
try {
delimitedFileconnection.setFilePath(FileLocator.toFileURL(fileUrl).toURI().getPath().toString());
// $NON-NLS-1$
delimitedFileconnection.setRowSeparatorValue("\n");
// $NON-NLS-1$
delimitedFileconnection.setEncoding("UTF-8");
// $NON-NLS-1$
delimitedFileconnection.setFieldSeparatorValue(",");
delimitedFileconnection.setName(ERepositoryObjectType.METADATA_FILE_DELIMITED.getKey());
MetadataTable metadataTable = ConnectionFactory.eINSTANCE.createMetadataTable();
// IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
// metadataTable.setId(factory.getNextId());
RecordFile record = (RecordFile) ConnectionHelper.getPackage(delimitedFileconnection.getName(), delimitedFileconnection, RecordFile.class);
if (record != null) {
// hywang
PackageHelper.addMetadataTable(metadataTable, record);
} else {
RecordFile newrecord = RecordFactory.eINSTANCE.createRecordFile();
newrecord.setName(delimitedFileconnection.getName());
ConnectionHelper.addPackage(newrecord, delimitedFileconnection);
PackageHelper.addMetadataTable(metadataTable, newrecord);
}
return metadataTable;
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
use of orgomg.cwm.resource.record.RecordFile in project tdi-studio-se by Talend.
the class CreateJSONSchemaAction method doRun.
@Override
protected void doRun() {
if (repositoryNode == null) {
repositoryNode = getCurrentRepositoryNode();
}
JSONFileConnection connection = null;
MetadataTable metadataTable = null;
boolean creation = false;
if (repositoryNode.getType() == ENodeType.REPOSITORY_ELEMENT) {
ERepositoryObjectType nodeType = (ERepositoryObjectType) repositoryNode.getProperties(EProperties.CONTENT_TYPE);
String metadataTableLabel = (String) repositoryNode.getProperties(EProperties.LABEL);
JSONFileConnectionItem item = null;
if (nodeType == ERepositoryObjectType.METADATA_CON_TABLE) {
item = (JSONFileConnectionItem) repositoryNode.getObject().getProperty().getItem();
connection = (JSONFileConnection) item.getConnection();
metadataTable = TableHelper.findByLabel(connection, metadataTableLabel);
creation = false;
} else if (nodeType == JSONRepositoryNodeType.JSON) {
item = (JSONFileConnectionItem) repositoryNode.getObject().getProperty().getItem();
connection = (JSONFileConnection) item.getConnection();
metadataTable = ConnectionFactory.eINSTANCE.createMetadataTable();
String nextId = ProxyRepositoryFactory.getInstance().getNextId();
metadataTable.setId(nextId);
metadataTable.setLabel(getStringIndexed(metadataTable.getLabel()));
RecordFile record = (RecordFile) ConnectionHelper.getPackage(connection.getName(), connection, RecordFile.class);
if (record != null) {
// hywang
PackageHelper.addMetadataTable(metadataTable, record);
} else {
RecordFile newrecord = RecordFactory.eINSTANCE.createRecordFile();
ConnectionHelper.addPackage(newrecord, connection);
PackageHelper.addMetadataTable(metadataTable, newrecord);
}
creation = true;
} else {
return;
}
initContextMode(item);
openJSONSchemaWizard(item, metadataTable, false, creation);
}
}
Aggregations