use of org.talend.dataquality.indicators.definition.userdefine.UDIndicatorDefinition in project tdq-studio-se by Talend.
the class FileSystemImportWriter method updateAnalysisClientDependence.
/**
* remove the old client dependency add a new one in Anlaysis.
*
* @param supplierItem
* @param modelElement
* @throws PersistenceException
*/
private void updateAnalysisClientDependence(TDQItem supplierItem, Property property) throws PersistenceException {
ModelElement anaModelElement = PropertyHelper.getModelElement(property);
if (anaModelElement != null) {
Analysis analysis = (Analysis) anaModelElement;
EList<Dependency> clientDependency = anaModelElement.getClientDependency();
Iterator<Dependency> it = clientDependency.iterator();
ModelElement supplierModelElement = RepositoryNodeHelper.getResourceModelElement(supplierItem);
Resource supModeResource = supplierModelElement.eResource();
while (it.hasNext()) {
Dependency clientDep = it.next();
// systemSupplyModelElement,remove it.
if (clientDep.eResource() == null) {
URI clientDepURI = ((InternalEObject) clientDep).eProxyURI();
boolean isUDI = clientDepURI.path().contains(ResourceManager.getUDIFolder().getProjectRelativePath().toString());
boolean isPattern = clientDepURI.path().contains(ResourceManager.getPatternFolder().getProjectRelativePath().toString());
if (supModeResource != null && (isUDI || isPattern) && clientDepURI.lastSegment().equals(supModeResource.getURI().lastSegment())) {
it.remove();
break;
}
}
}
DependenciesHandler.getInstance().setUsageDependencyOn(anaModelElement, supplierModelElement);
// TDQ-8436 remove the old pattern and add the new pattern in analysis Indicator Parameters.
if (isPattern(supplierModelElement)) {
updatePatternInAnaParams(supplierModelElement, analysis);
ElementWriterFactory.getInstance().createPatternWriter().save(supplierItem, true);
}
// remove old udi and set a new one in the analysis indicators.
if (supplierModelElement instanceof UDIndicatorDefinition) {
if (analysis.getResults() != null) {
EList<Indicator> indicators = analysis.getResults().getIndicators();
Iterator<Indicator> itIndicators = indicators.iterator();
while (itIndicators.hasNext()) {
Indicator indicator = itIndicators.next();
IndicatorDefinition indicatorDefinition = indicator.getIndicatorDefinition();
if (indicatorDefinition.eResource() == null) {
URI indicatorDefURI = ((InternalEObject) indicatorDefinition).eProxyURI();
if (supModeResource != null && UDIHelper.isUDI(indicator) && indicatorDefURI.lastSegment().equals(supModeResource.getURI().lastSegment())) {
indicator.setIndicatorDefinition((UDIndicatorDefinition) supplierModelElement);
break;
}
}
}
ElementWriterFactory.getInstance().createIndicatorDefinitionWriter().save(supplierItem, true);
}
}
// only save analysis item at here.
ProxyRepositoryFactory.getInstance().save(property.getItem(), true);
}
}
use of org.talend.dataquality.indicators.definition.userdefine.UDIndicatorDefinition in project tdq-studio-se by Talend.
the class DefinitionHandler method reloadAllUDIs.
/**
* reload all user defined indicators, when some udi's name is changed, this method will be needed
*/
public void reloadAllUDIs() {
List<IndicatorDefinition> udis = new ArrayList<IndicatorDefinition>();
for (IndicatorDefinition indicatorDefinition : this.getIndicatorsDefinitions()) {
if (indicatorDefinition instanceof UDIndicatorDefinition) {
udis.add(indicatorDefinition);
}
}
// remove all udis
this.getIndicatorsDefinitions().removeAll(udis);
// reload all udis
this.getIndicatorsDefinitions().addAll(IndicatorResourceFileHelper.getInstance().getAllUDIs());
}
use of org.talend.dataquality.indicators.definition.userdefine.UDIndicatorDefinition in project tdq-studio-se by Talend.
the class IndicatorDuplicateHandle method updateUDIModel.
private void updateUDIModel(String newName, ModelElement duplicateModelElement) {
URI uri = duplicateModelElement.eResource().getURI();
IFile file = ResourceManager.getRoot().getFile(new Path(uri.toPlatformString(false)));
File ifileToFile = WorkspaceUtils.ifileToFile(file);
Map<String, String> initIndicatorReplaceMap = UpdateUDIIndicatorsWithNewModelTask.initIndicatorReplaceMap();
if (FilesUtils.migrateFile(ifileToFile, initIndicatorReplaceMap, log)) {
try {
for (IRepositoryViewObject viewObject : ProxyRepositoryFactory.getInstance().getAll(ERepositoryObjectType.TDQ_USERDEFINE_INDICATORS)) {
ProxyRepositoryFactory.getInstance().reload(viewObject.getProperty());
}
} catch (PersistenceException e) {
log.error(e);
}
ResourceService.refreshStructure();
// add templates for udi only.
List<IndicatorDefinition> indiDefinitions = DefinitionHandler.getInstance().getUserDefinedIndicatorDefinitions();
for (IndicatorDefinition indiDefinition : indiDefinitions) {
if (indiDefinition instanceof UDIndicatorDefinition) {
String name = indiDefinition.getLabel() != null ? indiDefinition.getLabel() : indiDefinition.getName();
if (name != null && name.equals(newName)) {
UDIndicatorDefinition udi = (UDIndicatorDefinition) indiDefinition;
udi = UDIUtils.createDefaultDrillDownList(udi);
ElementWriterFactory.getInstance().createIndicatorDefinitionWriter().save(udi);
break;
}
}
}
}
}
use of org.talend.dataquality.indicators.definition.userdefine.UDIndicatorDefinition in project tdq-studio-se by Talend.
the class UDIHelper method createUDI.
public static UDIndicatorDefinition createUDI(String name, String author, String description, String purpose, String status, String category, String javaClassName, String javaJarPath) {
// IndicatorDefinition id = DefinitionFactory.eINSTANCE.createIndicatorDefinition();
UDIndicatorDefinition id = UserdefineFactory.eINSTANCE.createUDIndicatorDefinition();
id.setName(name);
MetadataHelper.setAuthor(id, author == null ? PluginConstant.EMPTY_STRING : author);
MetadataHelper.setDescription(description == null ? PluginConstant.EMPTY_STRING : description, id);
MetadataHelper.setPurpose(purpose == null ? PluginConstant.EMPTY_STRING : purpose, id);
// MOD mzhao feature 7479 2009-10-16
MetadataHelper.setDevStatus(id, status == null ? PluginConstant.EMPTY_STRING : status);
TaggedValueHelper.setTaggedValue(id, TaggedValueHelper.CLASS_NAME_TEXT, javaClassName);
TaggedValueHelper.setTaggedValue(id, TaggedValueHelper.JAR_FILE_PATH, javaJarPath);
setUDICategory(id, category);
return id;
}
use of org.talend.dataquality.indicators.definition.userdefine.UDIndicatorDefinition in project tdq-studio-se by Talend.
the class FileTreeContentProvider method hideSomeItems.
/**
* hide Some Items.
*
* @param itemRecords
* @return
*/
private ItemRecord[] hideSomeItems(ItemRecord[] itemRecords) {
List<ItemRecord> result = new ArrayList<ItemRecord>();
for (ItemRecord itemRecord : itemRecords) {
if (itemRecord != null) {
// hide the Technial indicators
if (itemRecord.getElement() != null && itemRecord.getElement() instanceof IndicatorDefinition && !(itemRecord.getElement() instanceof UDIndicatorDefinition)) {
IndicatorDefinition indDef = (IndicatorDefinition) itemRecord.getElement();
String uuid = ResourceHelper.getUUID(indDef);
if (IndicatorDefinitionFileHelper.isTechnialIndicator(uuid)) {
continue;
}
}
// TDQ-10933: Hide the Exchange node TDQ-11036: always hidden
if (EResourceConstant.EXCHANGE.getName().equals(itemRecord.getName())) {
continue;
}
// TDQ-9495: Hide the Reports node when top
if (PluginChecker.isOnlyTopLoaded()) {
if (EResourceConstant.REPORTS.getName().equals(itemRecord.getName())) {
continue;
}
}
}
result.add(itemRecord);
}
return result.toArray(new ItemRecord[result.size()]);
}
Aggregations