use of org.talend.core.model.metadata.builder.connection.DatabaseConnection in project tdq-studio-se by Talend.
the class AnalysisSubFolderRepNode method getCount.
public String getCount() {
IRepositoryViewObject anaViewObject = this.getParent().getObject();
if (anaViewObject.getProperty() != null) {
TDQAnalysisItem item = (TDQAnalysisItem) anaViewObject.getProperty().getItem();
Analysis analysis = item.getAnalysis();
AnalysisContext context = analysis.getContext();
EList<ModelElement> analysedElements = context.getAnalysedElements();
if (analysedElements.size() == 1) {
ModelElement modelElement = analysedElements.get(0);
if (modelElement instanceof DatabaseConnection) {
EList<Package> dataPackage = ((DatabaseConnection) modelElement).getDataPackage();
// $NON-NLS-1$ //$NON-NLS-2$
return "(" + dataPackage.size() + ")";
}
}
// $NON-NLS-1$ //$NON-NLS-2$
return "(" + analysedElements.size() + ")";
}
// $NON-NLS-1$
return "(0)";
}
use of org.talend.core.model.metadata.builder.connection.DatabaseConnection in project tdq-studio-se by Talend.
the class DBSybaseCatalogRepNode method fillSchemaToCatalog.
/**
* fill schemas on the catalog
*
* @return if fill action is success
*/
private boolean fillSchemaToCatalog(Item databaseItem) {
DatabaseConnection connection = (DatabaseConnection) ((DatabaseConnectionItem) databaseItem).getConnection();
TypedReturnCode<Connection> rcConn = MetadataConnectionUtils.createConnection(connection);
if (!rcConn.isOk()) {
log.error(rcConn.getMessage());
return false;
}
java.sql.Connection sqlConnection = rcConn.getObject();
try {
DatabaseMetaData dbJDBCMetadata = ExtractMetaDataUtils.getInstance().getDatabaseMetaData(sqlConnection, connection, false);
EDatabaseTypeName currentEDatabaseType = EDatabaseTypeName.getTypeFromDbType(connection.getDatabaseType());
List<Schema> schemaList = null;
if (currentEDatabaseType != null) {
schemaList = MetadataFillFactory.getDBInstance(currentEDatabaseType).fillSchemaToCatalog(connection, dbJDBCMetadata, this.getCatalog(), null);
}
if (schemaList != null && schemaList.size() > 0) {
CatalogHelper.addSchemas(schemaList, this.getCatalog());
}
} finally {
if (sqlConnection != null) {
ConnectionUtils.closeConnection(sqlConnection);
}
}
return true;
}
use of org.talend.core.model.metadata.builder.connection.DatabaseConnection in project tdq-studio-se by Talend.
the class DQRepNodeCreateFactory method createDBCatalogRepNode.
/**
* this method is used to create a DBCatalogRepNode. And Sybase is a specal case because we don't create schema
* level when the version of stdio is lower than 5.0.0.So we will create DBSybaseCatalogRepNode to deal with this
* special case
*
* @param viewObject
* @param parent parent of repositoryNode
* @param type
* @return
*/
public static RepositoryNode createDBCatalogRepNode(IRepositoryViewObject viewObject, RepositoryNode parent, ENodeType type, org.talend.core.model.general.Project inWhichProject) {
Item databaseItem = viewObject.getProperty().getItem();
DatabaseConnection dbConnection = (DatabaseConnection) ((DatabaseConnectionItem) databaseItem).getConnection();
SupportDBUrlType dbTypeByKey = SupportDBUrlType.getDBTypeByKey(dbConnection.getDatabaseType());
switch(dbTypeByKey == null ? SupportDBUrlType.MYSQLDEFAULTURL : dbTypeByKey) {
case SYBASEDEFAULTURL:
return new DBSybaseCatalogRepNode(viewObject, parent, type, inWhichProject);
default:
return new DBCatalogRepNode(viewObject, parent, type, inWhichProject);
}
}
use of org.talend.core.model.metadata.builder.connection.DatabaseConnection in project tdq-studio-se by Talend.
the class SoftwareSystemUpdateEventReceiver method handle.
/*
* (non-Javadoc)
*
* @see org.talend.dataprofiler.core.ui.events.EventReceiver#handle(java.lang.Object)
*/
@Override
public boolean handle(Object data) {
Boolean isSuccess = Boolean.FALSE;
try {
if (data instanceof DatabaseConnection) {
DatabaseConnection databaseConnection = (DatabaseConnection) data;
SoftwareSystemManager.getInstance().updateSoftwareSystem(databaseConnection);
isSuccess = Boolean.TRUE;
}
} catch (Exception e) {
log.error(e.getMessage(), e);
isSuccess = Boolean.FALSE;
}
return isSuccess;
}
use of org.talend.core.model.metadata.builder.connection.DatabaseConnection in project tdq-studio-se by Talend.
the class AElementPersistance method createItem.
/**
* DOC bZhou Comment method "createItem".
*
* @param element
* @return
*/
public Item createItem(ModelElement element) {
Item item = null;
// MOD mzhao feature 13114, 2010-05-19 distinguish tdq items.
if (ModelElementIdentifier.isAnalysis(element)) {
item = PropertiesFactory.eINSTANCE.createTDQAnalysisItem();
((TDQAnalysisItem) item).setAnalysis((Analysis) element);
} else if (ModelElementIdentifier.isDQRule(element)) {
item = PropertiesFactory.eINSTANCE.createTDQBusinessRuleItem();
((TDQBusinessRuleItem) item).setDqrule((DQRule) element);
} else if (ModelElementIdentifier.isDataProvider(element)) {
if (element instanceof DatabaseConnection) {
item = org.talend.core.model.properties.PropertiesFactory.eINSTANCE.createDatabaseConnectionItem();
((ConnectionItem) item).setConnection((DatabaseConnection) element);
}
((ConnectionItem) item).setConnection((Connection) element);
} else if (ModelElementIdentifier.isMatchRule(element)) {
// this Condition must before the IndicatorDefinition one because MatchRule instance of it.
item = PropertiesFactory.eINSTANCE.createTDQMatchRuleItem();
((TDQMatchRuleItem) item).setMatchRule((MatchRuleDefinition) element);
} else if (ModelElementIdentifier.isID(element)) {
item = PropertiesFactory.eINSTANCE.createTDQIndicatorDefinitionItem();
((TDQIndicatorDefinitionItem) item).setIndicatorDefinition((IndicatorDefinition) element);
} else if (ModelElementIdentifier.isPattern(element)) {
item = PropertiesFactory.eINSTANCE.createTDQPatternItem();
((TDQPatternItem) item).setPattern((Pattern) element);
} else if (ModelElementIdentifier.isReport(element)) {
item = PropertiesFactory.eINSTANCE.createTDQReportItem();
((TDQReportItem) item).setReport((Report) element);
} else {
item = org.talend.core.model.properties.PropertiesFactory.eINSTANCE.createTDQItem();
}
ItemState itemState = org.talend.core.model.properties.PropertiesFactory.eINSTANCE.createItemState();
itemState.setDeleted(false);
item.setState(itemState);
if (item instanceof TDQItem) {
setTDQItemFileName(element, item);
}
Resource eResource = element.eResource();
if (eResource != null) {
URI uri = eResource.getURI();
if (uri.isPlatform()) {
IPath elementPath = new Path(uri.toPlatformString(true)).removeLastSegments(1);
IPath typedPath = ResourceManager.getRootProject().getFullPath().append(PropertyHelper.getItemTypedPath(item));
IPath statePath = elementPath.makeRelativeTo(typedPath);
itemState.setPath(statePath.toString());
}
}
return item;
}
Aggregations