use of org.talend.repository.model.json.JSONFileConnectionItem 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