use of org.talend.dataprofiler.core.ui.imex.model.ItemRecord in project tdq-studio-se by Talend.
the class ExportWizardPage method getElements.
/**
* DOC bZhou Comment method "getElements".
*
* @return
*/
public ItemRecord[] getElements() {
List<ItemRecord> itemRecords = new ArrayList<ItemRecord>();
boolean sumIndicatorAdded = false;
Object[] checkedElements = repositoryTree.getCheckedElements();
for (Object obj : checkedElements) {
if (obj instanceof ItemRecord) {
ItemRecord record = (ItemRecord) obj;
// MOD qiongli 2012-4-20,add related subreport jrxml/jasper file to elements.
File file = record.getFile();
if (file.isFile()) {
itemRecords.add(record);
if (file.getName().endsWith(FactoriesUtil.JRXML)) {
addSubRepToElements(record, itemRecords);
}
// if it is Mean Indicator, add it's dependency Sum Indicator
if (!sumIndicatorAdded) {
// $NON-NLS-1$
String meanIndicatorUuid = "_ccI48RF2Ed2PKb6nEJEvhw";
// $NON-NLS-1$
String sumIndicatorLabel = "Sum";
ModelElement element = record.getElement();
if (element != null && element instanceof IndicatorDefinition && meanIndicatorUuid.equals(ResourceHelper.getUUID(element))) {
IndicatorDefinition sumIndicator = DefinitionHandler.getInstance().getIndicatorDefinition(sumIndicatorLabel);
if (sumIndicator != null) {
IFile sumIndicatorIFile = IndicatorResourceFileHelper.findCorrespondingFile(sumIndicator);
if (sumIndicatorIFile != null) {
File sumIndicatorFile = WorkspaceUtils.ifileToFile(sumIndicatorIFile);
if (sumIndicatorFile != null) {
itemRecords.add(new ItemRecord(sumIndicatorFile));
sumIndicatorAdded = true;
}
}
}
}
}
}
}
}
return itemRecords.toArray(new ItemRecord[itemRecords.size()]);
}
use of org.talend.dataprofiler.core.ui.imex.model.ItemRecord in project tdq-studio-se by Talend.
the class ExportWizardPage method checkForErrors.
/**
* this check that the folder entered in the target export location exist otherwhise set an erro message and disable
* export.
*/
protected void checkForErrors() {
List<String> errors = new ArrayList<String>();
errors.addAll(writer.check());
ItemRecord[] elements = getElements();
for (ItemRecord record : elements) {
errors.addAll(record.getErrors());
for (File depFile : record.getDependencySet()) {
// ignore it(means not export it).
if (!DqFileUtils.isLocalProjectFile(depFile)) {
continue;
}
// TDQ-12245~
ItemRecord findRecord = ItemRecord.findRecord(depFile);
if (findRecord == null || !repositoryTree.getChecked(findRecord)) {
ModelElement element = ItemRecord.getElement(depFile);
// Indicator, don't add it into errors even if it is not exist
if (element instanceof IndicatorDefinition) {
String uuid = ResourceHelper.getUUID(element);
if (IndicatorDefinitionFileHelper.isTechnialIndicator(uuid)) {
continue;
}
}
// MOD qiongli 2012-12-13 TDQ-5356 use itself file name for jrxml
boolean isJrxmlDepFile = depFile.getName().endsWith(FactoriesUtil.JRXML);
// MOD msjian TDQ-5909: modify to displayName
String dptLabel = element != null && !isJrxmlDepFile && PropertyHelper.getProperty(element) != null ? PropertyHelper.getProperty(element).getDisplayName() : depFile.getName();
// TDQ-5909~
// $NON-NLS-1$ //$NON-NLS-2$
errors.add("\"" + record.getName() + "\" miss dependency : " + dptLabel);
}
}
}
if (!errors.isEmpty()) {
setErrorMessage(errors.get(0));
} else {
setErrorMessage(null);
}
updatePageStatus();
}
use of org.talend.dataprofiler.core.ui.imex.model.ItemRecord 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()]);
}
use of org.talend.dataprofiler.core.ui.imex.model.ItemRecord in project tdq-studio-se by Talend.
the class FileTreeLabelProvider method getText.
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.viewers.LabelProvider#getText(java.lang.Object)
*/
@Override
public String getText(Object element) {
if (element instanceof ItemRecord) {
ItemRecord record = (ItemRecord) element;
String label = record.getName();
// make the display text the same as dq repository view
if (label.equals(EResourceConstant.DATA_PROFILING.getName()) || label.equals(EResourceConstant.LIBRARIES.getName())) {
return label.substring(4, label.length());
} else if (label.equals(EResourceConstant.METADATA.getName())) {
return label.substring(0, 1).toUpperCase() + label.substring(1);
}
return label;
}
return super.getText(element);
}
use of org.talend.dataprofiler.core.ui.imex.model.ItemRecord in project tdq-studio-se by Talend.
the class FileTreeLabelProvider method getImage.
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.viewers.LabelProvider#getImage(java.lang.Object)
*/
@Override
public Image getImage(Object element) {
Image image = null;
if (element instanceof ItemRecord) {
ItemRecord record = (ItemRecord) element;
File file = record.getFile();
String fileName = file.getName();
if (file.isDirectory()) {
image = ImageLib.getImage(ImageLib.FOLDERNODE_IMAGE);
EResourceConstant constant = resolveResourceConstant(fileName);
if (constant != null) {
switch(constant) {
case DATA_PROFILING:
image = ImageLib.getImage(ImageLib.DATA_PROFILING);
break;
case METADATA:
image = ImageLib.getImage(ImageLib.METADATA);
break;
case LIBRARIES:
image = ImageLib.getImage(ImageLib.LIBRARIES);
break;
case ANALYSIS:
break;
case REPORTS:
break;
case EXCHANGE:
image = ImageLib.getImage(ImageLib.EXCHANGE);
break;
case DB_CONNECTIONS:
image = ImageLib.getImage(ImageLib.CONNECTION);
break;
case FILEDELIMITED:
image = ImageLib.getImage(ImageLib.FILE_DELIMITED);
break;
case HADOOP_CLUSTER:
image = ImageLib.getImage(ImageLib.HADOOP_CLUSTER);
break;
case CONTEXT:
image = ImageLib.getImage(ImageLib.CONTEXT);
break;
default:
break;
}
}
} else {
if (fileName.endsWith(FactoriesUtil.ANA)) {
image = ImageLib.getImage(ImageLib.ANALYSIS_OBJECT);
} else if (fileName.endsWith(FactoriesUtil.REP)) {
image = ImageLib.getImage(ImageLib.REPORT_OBJECT);
} else if (fileName.endsWith(FactoriesUtil.PATTERN)) {
image = ImageLib.getImage(ImageLib.PATTERN_REG);
} else if (fileName.endsWith(FactoriesUtil.DQRULE)) {
if (record.getElement() instanceof MatchRuleDefinition) {
image = ImageLib.getImage(ImageLib.MATCH_RULE_ICON);
} else {
image = ImageLib.getImage(ImageLib.DQ_RULE);
}
} else if (fileName.endsWith(FactoriesUtil.ITEM_EXTENSION)) {
if (record.getElement() instanceof DelimitedFileConnection) {
image = ImageLib.getImage(ImageLib.FILE_DELIMITED);
} else if (record.getElement() instanceof DatabaseConnection) {
image = ImageLib.getImage(ImageLib.TD_DATAPROVIDER);
} else {
image = ImageLib.getImage(ImageLib.CONTEXT);
}
} else if (fileName.endsWith(FactoriesUtil.DEFINITION)) {
image = ImageLib.getImage(ImageLib.IND_DEFINITION);
} else if (fileName.endsWith(FactoriesUtil.SQL)) {
image = ImageLib.getImage(ImageLib.SOURCE_FILE);
} else if (fileName.endsWith(FactoriesUtil.JAR)) {
image = ImageLib.getImage(ImageLib.JAR_FILE);
} else if (fileName.endsWith(FactoriesUtil.JRXML)) {
image = ImageLib.getImage(ImageLib.JRXML_ICON);
}
}
}
return image != null ? image : super.getImage(element);
}
Aggregations