Search in sources :

Example 1 with TalendException

use of org.talend.utils.exceptions.TalendException in project tdq-studio-se by Talend.

the class SoftwareSystemManager method updateSoftwareSystem.

/**
 * Update the software systems given the database connection instance.<br>
 *
 * @param database connection (Talend type)
 * @return
 * @throws SQLException
 */
public void updateSoftwareSystem(DatabaseConnection databaseConnection) throws SQLException {
    if (databaseConnection == null) {
        return;
    }
    Resource softwareSystemResource = EMFSharedResources.getInstance().getSoftwareDeploymentResource();
    List<EObject> softwareSystems = softwareSystemResource.getContents();
    Boolean isExisted = Boolean.FALSE;
    try {
        isExisted = isExistedInSoftwareSystem(databaseConnection, softwareSystems);
    } catch (TalendException e) {
        log.debug(e.getMessage());
        return;
    }
    if (!isExisted) {
        update(databaseConnection, softwareSystems, softwareSystemResource);
    }
}
Also used : EObject(org.eclipse.emf.ecore.EObject) Resource(org.eclipse.emf.ecore.resource.Resource) TalendException(org.talend.utils.exceptions.TalendException)

Example 2 with TalendException

use of org.talend.utils.exceptions.TalendException in project tdq-studio-se by Talend.

the class SoftwareSystemManager method isExistedInSoftwareSystem.

/**
 * DOC zhao Comment method "isExistedInSoftwareSystem".
 *
 * @param databaseConnection
 * @return
 */
private Boolean isExistedInSoftwareSystem(DatabaseConnection databaseConnection, List<EObject> softwareSystems) throws TalendException {
    String databaseType = TaggedValueHelper.getValueString(TaggedValueHelper.DB_PRODUCT_NAME, databaseConnection);
    if (StringUtils.isEmpty(databaseType)) {
        // $NON-NLS-1$
        throw new TalendException(Messages.getString("SoftwareSystemManager_NULL_DB_TYPE") + databaseConnection.getName());
    }
    String productVersion = TaggedValueHelper.getValueString(TaggedValueHelper.DB_PRODUCT_VERSION, databaseConnection);
    for (EObject system : softwareSystems) {
        if (system instanceof TdSoftwareSystem) {
            if (StringUtils.equalsIgnoreCase(((TdSoftwareSystem) system).getSubtype(), databaseType) && StringUtils.endsWithIgnoreCase(((TdSoftwareSystem) system).getVersion(), productVersion)) {
                // Found the software system given the database type and version.
                return Boolean.TRUE;
            }
        }
    }
    return Boolean.FALSE;
}
Also used : EObject(org.eclipse.emf.ecore.EObject) TdSoftwareSystem(org.talend.cwm.softwaredeployment.TdSoftwareSystem) TalendException(org.talend.utils.exceptions.TalendException)

Aggregations

EObject (org.eclipse.emf.ecore.EObject)2 TalendException (org.talend.utils.exceptions.TalendException)2 Resource (org.eclipse.emf.ecore.resource.Resource)1 TdSoftwareSystem (org.talend.cwm.softwaredeployment.TdSoftwareSystem)1