Search in sources :

Example 1 with TDQIndicatorDefinitionItemImpl

use of org.talend.dataquality.properties.impl.TDQIndicatorDefinitionItemImpl in project tdq-studio-se by Talend.

the class DependenciesHandler method getIndicatorDependency.

/**
 * get Indicator Dependency.
 *
 * @return get the list for analysis which use parameter to be a Indicator
 */
public List<IRepositoryViewObject> getIndicatorDependency(IRepositoryViewObject viewObject) {
    Item item = viewObject.getProperty().getItem();
    List<IRepositoryViewObject> listAnalysisViewObject = new ArrayList<IRepositoryViewObject>();
    if (item instanceof TDQIndicatorDefinitionItemImpl) {
        TDQIndicatorDefinitionItemImpl tdqIndicatorItem = (TDQIndicatorDefinitionItemImpl) item;
        IndicatorDefinition newIndicatorDefinition = tdqIndicatorItem.getIndicatorDefinition();
        List<IRepositoryViewObject> allAnaList = new ArrayList<IRepositoryViewObject>();
        try {
            allAnaList.addAll(ProxyRepositoryFactory.getInstance().getAll(ERepositoryObjectType.TDQ_ANALYSIS_ELEMENT, true));
        } catch (PersistenceException e) {
            log.error(e, e);
        }
        for (IRepositoryViewObject theAna : allAnaList) {
            List<Indicator> indicators = IndicatorHelper.getIndicators(((TDQAnalysisItem) theAna.getProperty().getItem()).getAnalysis().getResults());
            for (Indicator indicator : indicators) {
                IndicatorDefinition oldIndicatorDefinition = indicator.getIndicatorDefinition();
                if (ModelElementHelper.compareUUID(oldIndicatorDefinition, newIndicatorDefinition)) {
                    listAnalysisViewObject.add(theAna);
                    break;
                }
            }
        }
    }
    return listAnalysisViewObject;
}
Also used : TDQAnalysisItem(org.talend.dataquality.properties.TDQAnalysisItem) Item(org.talend.core.model.properties.Item) TDQSourceFileItem(org.talend.dataquality.properties.TDQSourceFileItem) TDQFileItem(org.talend.dataquality.properties.TDQFileItem) TDQIndicatorDefinitionItemImpl(org.talend.dataquality.properties.impl.TDQIndicatorDefinitionItemImpl) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) ArrayList(java.util.ArrayList) PersistenceException(org.talend.commons.exception.PersistenceException) IndicatorDefinition(org.talend.dataquality.indicators.definition.IndicatorDefinition) Indicator(org.talend.dataquality.indicators.Indicator) TDQAnalysisItem(org.talend.dataquality.properties.TDQAnalysisItem)

Example 2 with TDQIndicatorDefinitionItemImpl

use of org.talend.dataquality.properties.impl.TDQIndicatorDefinitionItemImpl in project tdq-studio-se by Talend.

the class DependenciesHandler method getAnaDependency.

/**
 * get Analysis Dependency (for indicator only).
 *
 * @return get the list of indicator which in use by the analysis
 */
public List<Property> getAnaDependency(Property property) {
    Item item = property.getItem();
    List<Property> listProperty = new ArrayList<Property>();
    if (item instanceof TDQAnalysisItemImpl) {
        TDQAnalysisItemImpl tdqAnaItem = (TDQAnalysisItemImpl) item;
        Analysis anaElement = tdqAnaItem.getAnalysis();
        List<Indicator> indicators = IndicatorHelper.getIndicators(anaElement.getResults());
        for (Indicator indicator : indicators) {
            boolean isContain = false;
            IndicatorDefinition newIndicatorDefinition = indicator.getIndicatorDefinition();
            // MOD qiongli 2012-5-11 TDQ-5256
            if (newIndicatorDefinition == null) {
                continue;
            }
            for (Property containViewObject : listProperty) {
                Item item2 = containViewObject.getItem();
                if (item2 instanceof TDQIndicatorDefinitionItemImpl) {
                    IndicatorDefinition oldIndicatorDefinition = ((TDQIndicatorDefinitionItemImpl) item2).getIndicatorDefinition();
                    if (ModelElementHelper.compareUUID(oldIndicatorDefinition, newIndicatorDefinition)) {
                        isContain = true;
                        break;
                    }
                }
            }
            if (!isContain) {
                Property iniProperty = PropertyHelper.getProperty(indicator.getIndicatorDefinition());
                if (iniProperty != null) {
                    listProperty.add(iniProperty);
                }
            }
        }
    }
    return listProperty;
}
Also used : TDQAnalysisItem(org.talend.dataquality.properties.TDQAnalysisItem) Item(org.talend.core.model.properties.Item) TDQSourceFileItem(org.talend.dataquality.properties.TDQSourceFileItem) TDQFileItem(org.talend.dataquality.properties.TDQFileItem) TDQIndicatorDefinitionItemImpl(org.talend.dataquality.properties.impl.TDQIndicatorDefinitionItemImpl) Analysis(org.talend.dataquality.analysis.Analysis) ArrayList(java.util.ArrayList) Property(org.talend.core.model.properties.Property) IndicatorDefinition(org.talend.dataquality.indicators.definition.IndicatorDefinition) TDQAnalysisItemImpl(org.talend.dataquality.properties.impl.TDQAnalysisItemImpl) Indicator(org.talend.dataquality.indicators.Indicator)

Example 3 with TDQIndicatorDefinitionItemImpl

use of org.talend.dataquality.properties.impl.TDQIndicatorDefinitionItemImpl in project tdq-studio-se by Talend.

the class UpdateJUDITask method handleUDIFile.

/**
 * DOC zshen Comment method "handleUDIFile".
 *
 * @param listFiles
 */
private boolean handleUDIFile(File[] listFiles) {
    boolean returnCode = true;
    File jarFile = null;
    if (listFiles == null) {
        returnCode |= false;
        return returnCode;
    }
    for (File udiFile : listFiles) {
        if (udiFile == null) {
            continue;
        }
        if (udiFile.isDirectory()) {
            returnCode |= handleUDIFile(udiFile.listFiles());
        } else {
            // there only use old path to find jar. After that we can try to open a dialog to let user provider it.
            if (!udiFile.getName().endsWith(FactoriesUtil.PROPERTIES_EXTENSION)) {
                continue;
            }
            Resource propResource = getResource(udiFile.getAbsolutePath());
            Property newProperty = (Property) EcoreUtil.getObjectByType(propResource.getContents(), PropertiesPackage.eINSTANCE.getProperty());
            try {
                newProperty = ProxyRepositoryFactory.getInstance().getLastVersion(newProperty.getId()).getProperty();
            } catch (PersistenceException e) {
                log.error(e, e);
            }
            IndicatorDefinition uDIindicatorDefinition = ((TDQIndicatorDefinitionItemImpl) newProperty.getItem()).getIndicatorDefinition();
            EList<TaggedValue> taggedValues = uDIindicatorDefinition.getTaggedValue();
            String jarPath = null;
            for (TaggedValue tv : taggedValues) {
                if (tv.getTag().equals(TaggedValueHelper.CLASS_NAME_TEXT)) {
                    returnCode ^= false;
                    continue;
                }
                if (tv.getTag().equals(TaggedValueHelper.JAR_FILE_PATH)) {
                    jarPath = tv.getValue();
                    tv.setValue(new Path(jarPath).lastSegment());
                    ((TDQIndicatorDefinitionItemImpl) newProperty.getItem()).setIndicatorDefinition(uDIindicatorDefinition);
                    Resource itemResource = getResource(new Path(udiFile.getAbsolutePath()).removeFileExtension().addFileExtension(FactoriesUtil.DEFINITION).toOSString());
                    EMFUtil.saveResource(itemResource);
                    newProperty.setItem(newProperty.getItem());
                    newProperty.getItem().setProperty(newProperty);
                    propResource.getContents().clear();
                    propResource.getContents().add(newProperty);
                    propResource.getContents().add(newProperty.getItem());
                    propResource.getContents().add(newProperty.getItem().getState());
                    EMFUtil.saveResource(propResource);
                    returnCode ^= false;
                }
            }
            if (jarPath != null) {
                File jarPathFile = new File(jarPath);
                if (jarPathFile.exists()) {
                    try {
                        jarFile = ResourceManager.getUDIJarFolder().getLocation().append(jarPathFile.getName()).toFile();
                        FilesUtils.copyFile(jarPathFile, jarFile);
                    } catch (IOException e) {
                        log.error(e, e);
                    }
                }
                if (jarFile == null || !jarFile.exists()) {
                    // $NON-NLS-1$
                    log.error(DefaultMessagesImpl.getString("UpdateJUDITask_CanNotFoundJarFile", jarPath));
                }
            }
        }
    }
    return returnCode;
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.core.runtime.Path) TDQIndicatorDefinitionItemImpl(org.talend.dataquality.properties.impl.TDQIndicatorDefinitionItemImpl) TaggedValue(orgomg.cwm.objectmodel.core.TaggedValue) Resource(org.eclipse.emf.ecore.resource.Resource) PersistenceException(org.talend.commons.exception.PersistenceException) IOException(java.io.IOException) File(java.io.File) Property(org.talend.core.model.properties.Property) IndicatorDefinition(org.talend.dataquality.indicators.definition.IndicatorDefinition)

Aggregations

IndicatorDefinition (org.talend.dataquality.indicators.definition.IndicatorDefinition)3 TDQIndicatorDefinitionItemImpl (org.talend.dataquality.properties.impl.TDQIndicatorDefinitionItemImpl)3 ArrayList (java.util.ArrayList)2 PersistenceException (org.talend.commons.exception.PersistenceException)2 Item (org.talend.core.model.properties.Item)2 Property (org.talend.core.model.properties.Property)2 Indicator (org.talend.dataquality.indicators.Indicator)2 TDQAnalysisItem (org.talend.dataquality.properties.TDQAnalysisItem)2 TDQFileItem (org.talend.dataquality.properties.TDQFileItem)2 TDQSourceFileItem (org.talend.dataquality.properties.TDQSourceFileItem)2 File (java.io.File)1 IOException (java.io.IOException)1 IPath (org.eclipse.core.runtime.IPath)1 Path (org.eclipse.core.runtime.Path)1 Resource (org.eclipse.emf.ecore.resource.Resource)1 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)1 Analysis (org.talend.dataquality.analysis.Analysis)1 TDQAnalysisItemImpl (org.talend.dataquality.properties.impl.TDQAnalysisItemImpl)1 TaggedValue (orgomg.cwm.objectmodel.core.TaggedValue)1