use of org.talend.resource.EResourceConstant in project tdq-studio-se by Talend.
the class UpdateAfterMergeTosApiTask method updateConnectionFile.
/**
* DOC bZhou Comment method "addConnectionFileToUpdate".
*/
private void updateConnectionFile() {
File rawDir = getWorkspacePath().append(EResourceConstant.METADATA.getPath()).toFile();
ArrayList<File> fileList = new ArrayList<File>();
if (rawDir.exists()) {
getAllFilesFromFolder(rawDir, fileList, new FilenameFilter() {
public boolean accept(File dir, String name) {
return name.endsWith(FactoriesUtil.ITEM_EXTENSION);
}
});
}
for (File file : fileList) {
IFile iFile = WorkspaceUtils.fileToIFile(file);
Property property = PropertyHelper.getProperty(iFile);
if (property != null) {
Item item = property.getItem();
EResourceConstant type = EResourceConstant.getTypedConstant(item);
if (type == EResourceConstant.DB_CONNECTIONS) {
DatabaseConnectionItem dbItem = (DatabaseConnectionItem) item;
DatabaseConnection connection = (DatabaseConnection) dbItem.getConnection();
String otherParameter = ConnectionHelper.getOtherParameter(connection);
if (!StringUtils.isBlank(otherParameter)) {
connection.setUiSchema(otherParameter);
EMFSharedResources.getInstance().saveResource(connection.eResource());
}
}
}
}
}
use of org.talend.resource.EResourceConstant in project tdq-studio-se by Talend.
the class ResourceViewContentProvider method getRepositoryNodeChildren.
/**
* DOC talend Comment method "getRepositoryNodeChildren".
*
* @param element
* @param instance
* @return
* @throws PersistenceException
* @throws CoreException
*/
private Object[] getRepositoryNodeChildren(Object element) throws PersistenceException, CoreException {
final DQRepositoryNode node = (DQRepositoryNode) element;
// MOD gdbu 2011-7-20 bug : 23220
DQRepositoryNode.setIsReturnAllNodesWhenFiltering(false);
List<IRepositoryNode> children = node.getChildren();
DQRepositoryNode.setIsReturnAllNodesWhenFiltering(true);
if ((node instanceof DBTableFolderRepNode || node instanceof DBViewFolderRepNode || node instanceof DBColumnFolderRepNode) && !DQRepositoryNode.isOnFilterring()) {
if (0 < children.size()) {
try {
StructuredSelection structSel = new StructuredSelection(node);
if (null != treeViewer) {
ISelection tempSelection = treeViewer.getSelection();
treeViewer.setSelection(structSel);
TreeItem[] selectionItems = treeViewer.getTree().getSelection();
if (0 != selectionItems.length) {
selectionItems[0].setText(node.getLabel());
treeViewer.setSelection(tempSelection);
}
} else {
ISelection dqTreeSelection = RepositoryNodeHelper.getDQCommonViewer().getSelection();
RepositoryNodeHelper.getDQCommonViewer().setSelection(structSel);
TreeItem[] selections = RepositoryNodeHelper.getDQCommonViewer().getTree().getSelection();
if (0 != selections.length) {
selections[0].setText(node.getLabel());
}
RepositoryNodeHelper.getDQCommonViewer().setSelection(dqTreeSelection);
}
} catch (Exception e) {
log.error(e.toString());
}
}
}
if (children.size() <= 0) {
// ~23220
List<EResourceConstant> resContants = new ArrayList<EResourceConstant>();
IRepositoryViewObject viewObject = node.getObject();
String label = viewObject == null ? null : viewObject.getLabel();
if (EResourceConstant.DATA_PROFILING.getName().equals(label)) {
resContants.add(EResourceConstant.ANALYSIS);
if (PluginChecker.isTDQLoaded()) {
resContants.add(EResourceConstant.REPORTS);
}
} else if (EResourceConstant.LIBRARIES.getName().equals(label)) {
// MOD TDQ-10933 msjian 20150915: Hide the Exchange node
if (!TalendPropertiesUtil.isHideExchange()) {
resContants.add(EResourceConstant.EXCHANGE);
}
// TDQ-10933~
resContants.add(EResourceConstant.INDICATORS);
if (PluginChecker.isTDQLoaded()) {
resContants.add(EResourceConstant.JRXML_TEMPLATE);
}
resContants.add(EResourceConstant.PATTERNS);
resContants.add(EResourceConstant.RULES);
resContants.add(EResourceConstant.SOURCE_FILES);
} else if (EResourceConstant.METADATA.getName().equals(label)) {
resContants.add(EResourceConstant.DB_CONNECTIONS);
resContants.add(EResourceConstant.FILEDELIMITED);
if (PluginChecker.isTDQLoaded() && HadoopClusterUtils.getDefault().isServiceInstalled()) {
resContants.add(EResourceConstant.HADOOP_CLUSTER);
}
}
if (resContants.size() > 0) {
RepositoryNodeBuilder.getInstance().createRepositoryNodeSystemFolders(node, resContants, node.getProject());
}
} else {
// to avoid can not get reference project nodes when open the select udi/pattern/rule dialog
if (EResourceConstant.REFERENCED_PROJECT.getName().equals(node.getProperties(EProperties.LABEL))) {
if (!ProxyRepositoryManager.getInstance().isMergeRefProject()) {
for (IRepositoryNode refProjectNode : node.getChildren()) {
for (IRepositoryNode refProjectItemNode : refProjectNode.getChildren()) {
getRepositoryNodeChildren(refProjectItemNode);
}
}
}
}
}
if (node instanceof ContextFolderRepNode) {
children = ((ContextFolderRepNode) node).getChildren();
}
return sortRepositoryNode(children.toArray());
}
use of org.talend.resource.EResourceConstant in project tdq-studio-se by Talend.
the class ResourceDropAdapterAssistant method allowDND.
/**
* DOC bZhou Comment method "allowDND".
*
* @param sourceFile
* @param targetFolder
* @return
*/
private boolean allowDND(IFile sourceFile, IFolder targetFolder) {
ModelElement modelElement = ModelElementFileFactory.getModelElement(sourceFile);
EResourceConstant typedConstant = EResourceConstant.getTypedConstant(modelElement);
if (typedConstant != null) {
IFolder oneFolder = ResourceManager.getOneFolder(typedConstant);
return oneFolder == null ? false : ResourceService.isSubFolder(oneFolder, targetFolder);
}
return false;
}
use of org.talend.resource.EResourceConstant in project tdq-studio-se by Talend.
the class ImportRemotePatternAction method doImportAfterDownload.
private void doImportAfterDownload(IJobChangeEvent event) {
final List<ReturnCode> information = new ArrayList<ReturnCode>();
setEnabled(true);
if (fExtensionDownloaded > 0) {
// $NON-NLS-1$
String csvFormat = System.getProperty("talend.exchange.csv");
if ("true".equals(csvFormat)) {
// $NON-NLS-1$
for (IEcosComponent componet : fInstalledComponents) {
List<ImportObject> validImportObject = ImportObject.extractImportObject(componet, information);
if (!validImportObject.isEmpty()) {
String categoryName = componet.getCategry().getName();
EEcosCategory ecosCategory = EEcosCategory.getEcosCategory(categoryName);
if (ecosCategory != null) {
EResourceConstant resourceType = ecosCategory.getResource();
for (ImportObject importObject : validImportObject) {
information.addAll(ImportFactory.doImport(resourceType, importObject, componet.getName()));
}
}
}
}
// MOD qiongli 2011-11-28 TDQ-4038,give the message when there is nothing to import.
if (information.isEmpty()) {
information.add(new ReturnCode(DefaultMessagesImpl.getString("ImportRemotePatternAction.NothingImport"), // $NON-NLS-1$
false));
}
ImportInfoDialog.openImportInformation(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), DefaultMessagesImpl.getString("ImportRemotePatternAction.ImportFinish"), // $NON-NLS-1$
information.toArray(new ReturnCode[0]));
CorePlugin.getDefault().refreshDQView();
} else {
Display.getDefault().asyncExec(new Runnable() {
public void run() {
for (IEcosComponent componet : fInstalledComponents) {
try {
ImportFactory.importFromExchange(componet);
} catch (Exception e) {
ExceptionHandler.process(e);
}
}
}
});
}
}
}
use of org.talend.resource.EResourceConstant in project tdq-studio-se by Talend.
the class PropertyHelper method computePath.
/**
* DOC bZhou Comment method "computePath".
*
* @param property
* @param file
* @return
*/
public static String computePath(Property property, File file) {
IPath filePath = new Path(file.getAbsolutePath()).setDevice(null);
boolean isConnFromOld = file.getAbsolutePath().contains(EResourceConstant.OLD_METADATA.getName());
int flag = 0;
EResourceConstant typedConstant = EResourceConstant.getTypedConstant(property.getItem());
if (typedConstant != null && !isConnFromOld) {
String typedName = typedConstant.getName();
for (int i = 0; i < filePath.segmentCount(); i++) {
String seg = filePath.segment(i);
if (seg.equals(typedName)) {
flag = i + 1;
break;
}
}
} else {
List<EResourceConstant> typedConstantList = EResourceConstant.getTypedConstantList();
typedConstantList.add(EResourceConstant.OLD_DB_CONNECTIONS);
typedConstantList.add(EResourceConstant.OLD_MDM_CONNECTIONS);
for (int i = 0; i < filePath.segmentCount() && flag == 0; i++) {
String seg = filePath.segment(i);
for (EResourceConstant constant : typedConstantList) {
if (seg.equals(constant.getName())) {
flag = i + 1;
break;
}
}
}
}
IPath statPath = filePath.removeFirstSegments(flag).removeLastSegments(1);
return statPath.toString();
}
Aggregations