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;
}
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;
}
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;
}
Aggregations