use of org.talend.repository.model.IRepositoryNode in project tesb-studio-se by Talend.
the class EditRouteResourcePropertiesAction method init.
public void init(TreeViewer viewer, IStructuredSelection selection) {
boolean canWork = selection.size() == 1;
if (canWork) {
Object o = ((IStructuredSelection) selection).getFirstElement();
if (o instanceof IRepositoryNode) {
final IRepositoryNode node = (IRepositoryNode) o;
canWork = node.getType() == ENodeType.REPOSITORY_ELEMENT && node.getObjectType() == CamelRepositoryNodeType.repositoryRouteResourceType && node.getObject().getRepositoryStatus() != ERepositoryStatus.DELETED && isLastVersion(node);
}
}
setEnabled(canWork);
}
use of org.talend.repository.model.IRepositoryNode in project tesb-studio-se by Talend.
the class CamelFeatureUtil method getJobProjectName.
private static String getJobProjectName(String jobId, String jobName, String defaultProject) {
if (jobId == null || jobId.isEmpty()) {
return defaultProject;
}
if (jobName == null || jobName.isEmpty()) {
return defaultProject;
}
IRepositoryNode referencedJobNode = null;
Project referenceProject = null;
try {
List<Project> projects = ProjectManager.getInstance().getAllReferencedProjects();
if (projects == null) {
return defaultProject;
}
for (Project p : projects) {
List<IRepositoryViewObject> jobs = ProxyRepositoryFactory.getInstance().getAll(p, ERepositoryObjectType.PROCESS);
if (jobs == null) {
continue;
}
for (IRepositoryViewObject job : jobs) {
if (job.getId().equals(jobId)) {
referencedJobNode = new RepositoryNode(job, null, IRepositoryNode.ENodeType.REPOSITORY_ELEMENT);
referenceProject = p;
break;
}
}
if (referenceProject != null) {
break;
}
}
} catch (PersistenceException e) {
return defaultProject;
}
if (referencedJobNode == null) {
return defaultProject;
}
Property p = referencedJobNode.getObject().getProperty();
String jobNameFound = p.getDisplayName();
String jobLabelFound = p.getLabel();
if ((jobNameFound == null || !jobNameFound.equals(jobName)) && (jobLabelFound == null || !jobNameFound.equals(jobName))) {
return defaultProject;
}
if (referenceProject != null) {
return referenceProject.getLabel().toLowerCase();
}
return defaultProject;
}
use of org.talend.repository.model.IRepositoryNode in project tesb-studio-se by Talend.
the class CreateRouteResourceAction method doRun.
@Override
protected void doRun() {
IRepositoryNode node = null;
NewRouteResourceWizard wizard = null;
ISelection selection = getSelection();
if (selection == null) {
return;
}
Object obj = ((IStructuredSelection) selection).getFirstElement();
node = (IRepositoryNode) obj;
IRepositoryService service = DesignerPlugin.getDefault().getRepositoryService();
IPath path = service.getRepositoryPath(node);
if (RepositoryConstants.isSystemFolder(path.toString())) {
// Not allowed to create in system folder.
return;
}
wizard = new NewRouteResourceWizard(path);
WizardDialog dlg = new WizardDialog(Display.getCurrent().getActiveShell(), wizard);
int open = dlg.open();
if (open == Window.OK) {
RouteResourceItem item = wizard.getItem();
IWorkbenchPage page = getActivePage();
RouteResourceEditorUtil.openEditor(page, null, item);
}
}
use of org.talend.repository.model.IRepositoryNode in project tdi-studio-se by Talend.
the class ComponentChooseDialog method getChangeMetadataCommand.
/**
* DOC bqian Comment method "getChangeMetadataCommand".
*
* @param selectedNode
* @param node
* @param list
* @param connectionItem
*/
private void getChangeMetadataCommand(CompoundCommand cc, RepositoryNode selectedNode, Node node, ConnectionItem connectionItem) {
if (selectedNode.getProperties(EProperties.CONTENT_TYPE) == ERepositoryObjectType.METADATA_CON_COLUMN) {
RepositoryNode columnParentNode = selectedNode.getParent().getParent();
if (columnParentNode != null) {
selectedNode = columnParentNode;
}
}
if (selectedNode.getProperties(EProperties.CONTENT_TYPE) == ERepositoryObjectType.METADATA_CON_TABLE || selectedNode.getProperties(EProperties.CONTENT_TYPE) == ERepositoryObjectType.METADATA_SAP_FUNCTION || selectedNode.getProperties(EProperties.CONTENT_TYPE) == ERepositoryObjectType.METADATA_SALESFORCE_MODULE) {
String etlSchema = null;
if (connectionItem.getConnection() instanceof DatabaseConnection) {
DatabaseConnection connection = (DatabaseConnection) connectionItem.getConnection();
if (connection instanceof DatabaseConnection) {
etlSchema = connection.getUiSchema();
}
if (!"".equals(etlSchema)) {
//$NON-NLS-1$
//$NON-NLS-1$
IElementParameter e = node.getElementParameter("ELT_SCHEMA_NAME");
if (e != null) {
if (connection.isContextMode() && ContextParameterUtils.isContainContextParam(etlSchema)) {
e.setValue(etlSchema);
} else {
e.setValue(TalendTextUtils.addQuotes(etlSchema));
}
}
// node.getElementParameter("ELT_SCHEMA_NAME").setValue("\"" + etlSchema + "\"");
}
}
IRepositoryViewObject object = selectedNode.getObject();
MetadataTable table = null;
if (object instanceof MetadataTableRepositoryObject) {
table = ((MetadataTableRepositoryObject) object).getTable();
} else if (object instanceof SalesforceModuleRepositoryObject) {
table = ((SalesforceModuleRepositoryObject) object).getDefaultTable();
IRepositoryViewObject obj = null;
if (selectedNode.getChildren() != null) {
for (IRepositoryNode repositoryNode : selectedNode.getChildren()) {
obj = repositoryNode.getObject();
if (obj instanceof MetadataTableRepositoryObject) {
table = ((MetadataTableRepositoryObject) obj).getTable();
break;
}
}
}
}
// for SAP
if (PluginChecker.isSAPWizardPluginLoaded() && connectionItem instanceof SAPConnectionItem) {
getSAPCommand(cc, object, connectionItem, table, node);
return;
}
if (table != null) {
//$NON-NLS-1$
String value = connectionItem.getProperty().getId() + " - " + table.getLabel();
IElementParameter schemaParam = node.getElementParameterFromField(EParameterFieldType.SCHEMA_TYPE);
if (schemaParam == null) {
schemaParam = node.getElementParameterFromField(EParameterFieldType.SCHEMA_REFERENCE);
}
IElementParameter queryParam = node.getElementParameterFromField(EParameterFieldType.QUERYSTORE_TYPE);
if (queryParam != null) {
queryParam = queryParam.getChildParameters().get(EParameterName.QUERYSTORE_TYPE.getName());
if (queryParam != null) {
queryParam.setValue(EmfComponent.BUILTIN);
}
}
// }
if (PluginChecker.isHL7PluginLoaded() && connectionItem instanceof HL7ConnectionItem) {
Command hl7Cmd = new RepositoryChangeMetadataForHL7Command(node, IEbcdicConstant.TABLE_SCHEMAS, table.getLabel(), ConvertionHelper.convert(table));
cc.add(hl7Cmd);
return;
}
if (schemaParam == null) {
return;
}
if (node.isELTComponent()) {
//$NON-NLS-1$
node.setPropertyValue(EParameterName.LABEL.getName(), "__ELT_TABLE_NAME__");
}
schemaParam.getChildParameters().get(EParameterName.SCHEMA_TYPE.getName()).setValue(EmfComponent.REPOSITORY);
RepositoryChangeMetadataCommand command2 = new RepositoryChangeMetadataCommand(node, //$NON-NLS-1$
schemaParam.getName() + ":" + EParameterName.REPOSITORY_SCHEMA_TYPE.getName(), value, ConvertionHelper.convert(table), null, connectionItem.getConnection());
cc.add(command2);
return;
}
}
}
use of org.talend.repository.model.IRepositoryNode in project tdi-studio-se by Talend.
the class ComponentChooseDialog method handleDrop.
// private void checkRequiredModules() {
// Object newObject = ((CreateRequest) getTargetRequest()).getNewObject();
// if (newObject instanceof Node) {
// IComponent component = ((Node) newObject).getComponent();
// Shell shell = Display.getCurrent().getActiveShell();
// ModulesInstallerUtil.installModules(new Shell(shell), component);
// }
// }
/*
* (non-Javadoc)
*
* @see org.eclipse.gef.dnd.TemplateTransferDropTargetListener#handleDrop()
*/
@Override
protected void handleDrop() {
updateTargetRequest();
updateTargetEditPart();
// checkRequiredModules();
if (fromPalette && getTargetRequest() instanceof CreateRequest) {
if (selectedConnectionPart != null) {
CreateRequest req = ((CreateRequest) getTargetRequest());
Object o = req.getNewObject();
Point location = req.getLocation();
if (o instanceof Node) {
createComponentOnLink((Node) o, location);
}
// checkRequiredModules();
return;
} else if (getTargetEditPart() instanceof ProcessPart) {
// for palette dnd, feature 6457
Object newObject = ((CreateRequest) getTargetRequest()).getNewObject();
if (newObject != null) {
Command command = getCommand();
if (command != null) {
execCommandStack(command);
}
}
// checkRequiredModules();
return;
} else if (getTargetEditPart() instanceof SubjobContainerPart) {
// TDI-24985:for palette dnd.
Object newObject = ((CreateRequest) getTargetRequest()).getNewObject();
if (newObject != null) {
Command command = getCommand();
if (command != null) {
execCommandStack(command);
}
}
return;
} else if (getTargetEditPart() instanceof JobletContainerPart) {
JobletContainerPart jobletPart = (JobletContainerPart) getTargetEditPart();
if (isLock(jobletPart)) {
Shell shell = Display.getCurrent().getActiveShell();
ChooseJobletDialog dialog = new ChooseJobletDialog(new Shell(shell), getDropLocation());
if (dialog.open() == dialog.OK) {
EditPart part = getTargetEditPart();
if (dialog.addToJoblet()) {
AbstractMultiPageTalendEditor openEditor = getJobletPart((JobletContainerPart) part);
part = openEditor.getDesignerEditor().getProcessPart();
// editor = openEditor.getTalendEditor();
setTargetEditPart(part);
Object newObject = ((CreateRequest) getTargetRequest()).getNewObject();
if (newObject != null) {
Command command = getCommand();
if (command != null) {
CommandStack commandStack = (CommandStack) openEditor.getAdapter(CommandStack.class);
if (commandStack != null) {
commandStack.execute(command);
} else {
command.execute();
}
}
}
// checkRequiredModules();
return;
} else {
part = getParentPart(part);
setTargetEditPart(part);
Object newObject = ((CreateRequest) getTargetRequest()).getNewObject();
if (newObject != null) {
Command command = getCommand();
if (command != null) {
execCommandStack(command);
}
}
// checkRequiredModules();
return;
}
}
}
}
}
List<Object> sources = getSelectSource();
if (containsContextSource(sources)) {
createContext(sources);
} else {
if (!(getTargetEditPart() instanceof NodeContainerPart)) {
try {
createNewComponent(getCurrentEvent());
} catch (OperationCanceledException e) {
return;
}
} else {
if (containsSQLPatternSource(sources)) {
createSQLPattern(sources);
} else {
Object obj = getSelection().getFirstElement();
createSchema(obj, getTargetEditPart());
createQuery(obj, getTargetEditPart());
createProperty(obj, getTargetEditPart());
createChildJob(obj, getTargetEditPart());
createValidationRule(obj, getTargetEditPart());
if (obj instanceof IRepositoryNode) {
propaHadoopCfgChanges((IRepositoryNode) obj);
}
for (IExtendedNodeHandler hander : ExtendedNodeManager.getExtendedNodeHandler()) {
boolean updated = hander.updateComponent(obj, getTargetEditPart(), editor.getCommandStack());
if (updated) {
break;
}
}
}
}
}
// in case after drag/drop the editor is dirty but can not get focus
if (editor.isDirty()) {
editor.setFocus();
}
this.eraseTargetFeedback();
}
Aggregations