Search in sources :

Example 81 with DatabaseConnection

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)";
}
Also used : ModelElement(orgomg.cwm.objectmodel.core.ModelElement) Analysis(org.talend.dataquality.analysis.Analysis) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) DatabaseConnection(org.talend.core.model.metadata.builder.connection.DatabaseConnection) AnalysisContext(org.talend.dataquality.analysis.AnalysisContext) Package(orgomg.cwm.objectmodel.core.Package) TDQAnalysisItem(org.talend.dataquality.properties.TDQAnalysisItem)

Example 82 with DatabaseConnection

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;
}
Also used : Connection(java.sql.Connection) Schema(orgomg.cwm.resource.relational.Schema) Connection(java.sql.Connection) DatabaseConnection(org.talend.core.model.metadata.builder.connection.DatabaseConnection) DatabaseConnection(org.talend.core.model.metadata.builder.connection.DatabaseConnection) EDatabaseTypeName(org.talend.core.database.EDatabaseTypeName) DatabaseMetaData(java.sql.DatabaseMetaData)

Example 83 with DatabaseConnection

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);
    }
}
Also used : Item(org.talend.core.model.properties.Item) DatabaseConnectionItem(org.talend.core.model.properties.DatabaseConnectionItem) DBCatalogRepNode(org.talend.dq.nodes.DBCatalogRepNode) DBSybaseCatalogRepNode(org.talend.dq.nodes.DBSybaseCatalogRepNode) DatabaseConnection(org.talend.core.model.metadata.builder.connection.DatabaseConnection) SupportDBUrlType(org.talend.core.model.metadata.builder.database.dburl.SupportDBUrlType)

Example 84 with DatabaseConnection

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;
}
Also used : DatabaseConnection(org.talend.core.model.metadata.builder.connection.DatabaseConnection)

Example 85 with DatabaseConnection

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;
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.core.runtime.Path) Pattern(org.talend.dataquality.domain.pattern.Pattern) TDQIndicatorDefinitionItem(org.talend.dataquality.properties.TDQIndicatorDefinitionItem) IPath(org.eclipse.core.runtime.IPath) ConnectionItem(org.talend.core.model.properties.ConnectionItem) Resource(org.eclipse.emf.ecore.resource.Resource) MatchRuleDefinition(org.talend.dataquality.rules.MatchRuleDefinition) URI(org.eclipse.emf.common.util.URI) DQRule(org.talend.dataquality.rules.DQRule) Item(org.talend.core.model.properties.Item) TDQIndicatorDefinitionItem(org.talend.dataquality.properties.TDQIndicatorDefinitionItem) TDQAnalysisItem(org.talend.dataquality.properties.TDQAnalysisItem) ConnectionItem(org.talend.core.model.properties.ConnectionItem) TDQItem(org.talend.core.model.properties.TDQItem) TDQPatternItem(org.talend.dataquality.properties.TDQPatternItem) TDQMatchRuleItem(org.talend.dataquality.properties.TDQMatchRuleItem) TDQBusinessRuleItem(org.talend.dataquality.properties.TDQBusinessRuleItem) TDQReportItem(org.talend.dataquality.properties.TDQReportItem) ItemState(org.talend.core.model.properties.ItemState) TDQItem(org.talend.core.model.properties.TDQItem) DatabaseConnection(org.talend.core.model.metadata.builder.connection.DatabaseConnection) TDQReportItem(org.talend.dataquality.properties.TDQReportItem) TDQAnalysisItem(org.talend.dataquality.properties.TDQAnalysisItem)

Aggregations

DatabaseConnection (org.talend.core.model.metadata.builder.connection.DatabaseConnection)211 DatabaseConnectionItem (org.talend.core.model.properties.DatabaseConnectionItem)66 Connection (org.talend.core.model.metadata.builder.connection.Connection)53 ConnectionItem (org.talend.core.model.properties.ConnectionItem)42 ArrayList (java.util.ArrayList)41 PersistenceException (org.talend.commons.exception.PersistenceException)41 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)39 Test (org.junit.Test)33 IMetadataConnection (org.talend.core.model.metadata.IMetadataConnection)30 Property (org.talend.core.model.properties.Property)30 Item (org.talend.core.model.properties.Item)26 DelimitedFileConnection (org.talend.core.model.metadata.builder.connection.DelimitedFileConnection)20 IElementParameter (org.talend.core.model.process.IElementParameter)19 IProxyRepositoryFactory (org.talend.repository.model.IProxyRepositoryFactory)18 RepositoryNode (org.talend.repository.model.RepositoryNode)18 SQLException (java.sql.SQLException)17 TdTable (org.talend.cwm.relational.TdTable)17 Catalog (orgomg.cwm.resource.relational.Catalog)17 List (java.util.List)15 ReturnCode (org.talend.utils.sugars.ReturnCode)14