Search in sources :

Example 1 with TdResourceModel

use of org.talend.dataprofiler.core.model.TdResourceModel in project tdq-studio-se by Talend.

the class TdAddTaskAction method run.

@Override
public void run() {
    try {
        TdTaskPropertiesDialog dialog = new TdTaskPropertiesDialog(shell);
        ModelElement modelElement = null;
        if (navObj instanceof RepositoryNode) {
            RepositoryNode node = (RepositoryNode) navObj;
            modelElement = RepositoryNodeHelper.getModelElementFromRepositoryNode(node);
        } else {
            modelElement = (ModelElement) navObj;
        }
        modelElement = (ModelElement) EObjectHelper.resolveObject(modelElement);
        if (modelElement == null || modelElement.eResource() == null || modelElement.getName() == null) {
            // $NON-NLS-1$
            String fileName = "";
            if (navObj instanceof RepositoryNode) {
                Item item = ((RepositoryNode) navObj).getObject().getProperty().getItem();
                if (item instanceof TDQItem) {
                    fileName = ((TDQItem) item).getFilename();
                }
            }
            throw ExceptionFactory.getInstance().createBusinessException(fileName);
        }
        IFile file = WorkspaceUtils.getModelElementResource(modelElement);
        TdResourceModel tdResModel = new TdResourceModel(file.getFullPath(), (Workspace) file.getWorkspace(), modelElement);
        dialog.setResource(tdResModel);
        Map<String, Object> attMap = new HashMap<String, Object>();
        attMap.put(MarkerViewUtil.NAME_ATTRIBUTE, modelElement.getName());
        attMap.put(IMarker.LOCATION, file.getRawLocation().toString());
        attMap.put(IMarker.LINE_NUMBER, file.getRawLocation().toString());
        dialog.setInitialAttributes(attMap);
        dialog.open();
    } catch (BusinessException e) {
        ExceptionHandler.process(e, Level.FATAL);
    } catch (Exception e1) {
        log.error(e1, e1);
    }
}
Also used : IFile(org.eclipse.core.resources.IFile) HashMap(java.util.HashMap) RepositoryNode(org.talend.repository.model.RepositoryNode) BusinessException(org.talend.commons.exception.BusinessException) TdResourceModel(org.talend.dataprofiler.core.model.TdResourceModel) ModelElement(orgomg.cwm.objectmodel.core.ModelElement) Item(org.talend.core.model.properties.Item) TDQItem(org.talend.core.model.properties.TDQItem) BusinessException(org.talend.commons.exception.BusinessException) TdTaskPropertiesDialog(org.talend.dataprofiler.core.ui.dialog.TdTaskPropertiesDialog) TDQItem(org.talend.core.model.properties.TDQItem)

Aggregations

HashMap (java.util.HashMap)1 IFile (org.eclipse.core.resources.IFile)1 BusinessException (org.talend.commons.exception.BusinessException)1 Item (org.talend.core.model.properties.Item)1 TDQItem (org.talend.core.model.properties.TDQItem)1 TdResourceModel (org.talend.dataprofiler.core.model.TdResourceModel)1 TdTaskPropertiesDialog (org.talend.dataprofiler.core.ui.dialog.TdTaskPropertiesDialog)1 RepositoryNode (org.talend.repository.model.RepositoryNode)1 ModelElement (orgomg.cwm.objectmodel.core.ModelElement)1