use of org.talend.core.model.repository.IRepositoryViewObject in project tdi-studio-se by Talend.
the class DynamicTabbedPropertySection method updateProcessList.
/**
* ftang Comment method "updateProcessList".
*/
private void updateProcessList() {
List<String> processNameList = new ArrayList<String>();
List<String> processValueList = new ArrayList<String>();
processMap = new HashMap<String, IRepositoryViewObject>();
IProxyRepositoryFactory factory = DesignerPlugin.getDefault().getProxyRepositoryFactory();
try {
RootContainer<String, IRepositoryViewObject> processContainer = factory.getMetadata(ERepositoryObjectType.PROCESS);
ContentList<String, IRepositoryViewObject> processAbsoluteMembers = processContainer.getAbsoluteMembers();
String currentProcess = part.getTalendEditor().getProcess().getLabel();
for (Content<String, IRepositoryViewObject> object : processAbsoluteMembers.values()) {
IRepositoryViewObject process = object.getContent();
if (factory.getStatus(process) != ERepositoryStatus.DELETED && !currentProcess.equals(process.getLabel())) {
String path = object.getParent().getPath().toString();
String name;
if (path.equals("")) {
//$NON-NLS-1$
name = IPath.SEPARATOR + process.getLabel();
} else {
name = IPath.SEPARATOR + path + IPath.SEPARATOR + process.getLabel();
}
processNameList.add(name);
processMap.put(name, process);
}
}
} catch (PersistenceException e) {
// e.printStackTrace();
ExceptionHandler.process(e);
}
List<String> tempFolderList = new ArrayList<String>();
List<String> tempProcessNameList = new ArrayList<String>();
tempProcessNameList.addAll(processNameList);
for (String string : tempProcessNameList) {
// Put jobs which in a folder into a new list.s
if (string.lastIndexOf("/") != 0) {
//$NON-NLS-1$
tempFolderList.add(string);
processNameList.remove(string);
}
}
sortList(processNameList);
sortList(tempFolderList);
// Always put the jobs which in a folder on the top of the job list
tempFolderList.addAll(processNameList);
processNameList = tempFolderList;
for (String name : processNameList) {
IRepositoryViewObject process = processMap.get(name);
processValueList.add(process.getLabel());
}
String[] processTableNameList = processNameList.toArray(new String[0]);
String[] processTableValueList = processValueList.toArray(new String[0]);
for (int i = 0; i < elem.getElementParameters().size(); i++) {
IElementParameter param = elem.getElementParameters().get(i);
if (param.getName().equals(EParameterName.PROCESS_TYPE_PROCESS.getName())) {
param.setListItemsDisplayName(processTableNameList);
param.setListItemsValue(processTableValueList);
if (elem instanceof Node) {
((Node) elem).checkAndRefreshNode();
}
}
}
}
use of org.talend.core.model.repository.IRepositoryViewObject in project tdi-studio-se by Talend.
the class DynamicTabbedPropertySection method updateContextList.
/**
* ftang Comment method "updateContextList".
*/
private void updateContextList() {
List<String> contextNameList = new ArrayList<String>();
List<String> contextValueList = new ArrayList<String>();
IProxyRepositoryFactory factory = DesignerPlugin.getDefault().getProxyRepositoryFactory();
String selectedProcess = null;
for (int i = 0; (i < elem.getElementParameters().size()) && (selectedProcess == null); i++) {
IElementParameter param = elem.getElementParameters().get(i);
if (param.getName().equals(EParameterName.PROCESS_TYPE_PROCESS.getName())) {
selectedProcess = (String) param.getValue();
}
}
if (selectedProcess == null) {
return;
}
try {
List<IRepositoryViewObject> list = factory.getAll(ERepositoryObjectType.PROCESS);
for (IRepositoryViewObject process : list) {
String id = process.getLabel();
if (selectedProcess.equals(id)) {
if (process.getProperty().getItem() instanceof ProcessItem) {
ProcessItem processItem = (ProcessItem) process.getProperty().getItem();
for (Object o : processItem.getProcess().getContext()) {
if (o instanceof ContextType) {
ContextType context = (ContextType) o;
contextNameList.add(context.getName());
contextValueList.add(context.getName());
}
}
}
}
}
} catch (PersistenceException e) {
ExceptionHandler.process(e);
}
String[] contextTableNameList = contextNameList.toArray(new String[0]);
String[] contextTableValueList = contextValueList.toArray(new String[0]);
for (int i = 0; i < elem.getElementParameters().size(); i++) {
IElementParameter param = elem.getElementParameters().get(i);
if (param.getName().equals(EParameterName.PROCESS_TYPE_CONTEXT.getName())) {
param.setListItemsDisplayName(contextTableNameList);
param.setListItemsValue(contextTableValueList);
if (!contextValueList.contains(param.getValue())) {
if (contextTableNameList.length > 0) {
elem.setPropertyValue(EParameterName.PROCESS_TYPE_CONTEXT.getName(), contextTableValueList[0]);
}
} else {
// force to store the value again to activate the code
// generation in Node.setPropertyValue
elem.setPropertyValue(EParameterName.PROCESS_TYPE_CONTEXT.getName(), param.getValue());
}
}
}
}
use of org.talend.core.model.repository.IRepositoryViewObject in project tdi-studio-se by Talend.
the class StatsAndLogsHelper method changeRepositoryConnection.
static void changeRepositoryConnection(Element process, StatsAndLogsComposite statsComposite) {
String propertyType = (String) ElementParameter2ParameterType.getParameterValue(process, EParameterName.PROPERTY_TYPE.getName());
String id = (String) (ElementParameter2ParameterType.getParameterValue(process, EParameterName.PROPERTY_TYPE.getName()));
Connection repositoryConnection = null;
/* 16969 */
IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
Item item = null;
try {
IRepositoryViewObject repobj = factory.getLastVersion(id);
if (repobj != null) {
Property tmpproperty = repobj.getProperty();
if (tmpproperty != null) {
item = tmpproperty.getItem();
}
}
} catch (PersistenceException e) {
ExceptionHandler.process(e);
}
if (item != null && item instanceof ConnectionItem) {
repositoryConnection = ((ConnectionItem) item).getConnection();
} else {
repositoryConnection = null;
}
ChangeValuesFromRepository cmd1 = new ChangeValuesFromRepository(process, repositoryConnection, ImplicitContextLoadHelper.getExtraParameterName(EParameterName.PROPERTY_TYPE) + ":" + EParameterName.PROPERTY_TYPE.getName(), //$NON-NLS-1$
propertyType);
ChangeValuesFromRepository cmd2 = new ChangeValuesFromRepository(process, repositoryConnection, ImplicitContextLoadHelper.getExtraParameterName(EParameterName.PROPERTY_TYPE) + ":" + EParameterName.REPOSITORY_PROPERTY_TYPE.getName(), //$NON-NLS-1$
id);
AbstractMultiPageTalendEditor part = (AbstractMultiPageTalendEditor) ((IProcess2) process).getEditor();
if (part instanceof AbstractMultiPageTalendEditor) {
Object adapter = (part).getTalendEditor().getAdapter(CommandStack.class);
if (adapter != null) {
CommandStack commandStack = ((CommandStack) adapter);
commandStack.execute(cmd1);
commandStack.execute(cmd2);
}
}
}
use of org.talend.core.model.repository.IRepositoryViewObject in project tdi-studio-se by Talend.
the class ProjectSettingManager method changeImplicitContextRepositoryItem.
static void changeImplicitContextRepositoryItem(Element process, ExtraComposite extraComposite) {
// change repository item
String propertyType = (String) ElementParameter2ParameterType.getParameterValue(process, JobSettingsConstants.getExtraParameterName(EParameterName.PROPERTY_TYPE.getName()));
String id = (String) (ElementParameter2ParameterType.getParameterValue(process, EParameterName.PROPERTY_TYPE.getName()));
Connection repositoryConnection = null;
/* 16969 */
IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
Item item = null;
try {
IRepositoryViewObject repobj = factory.getLastVersion(id);
if (repobj != null) {
Property tmpproperty = repobj.getProperty();
if (tmpproperty != null) {
item = tmpproperty.getItem();
}
}
} catch (PersistenceException e) {
ExceptionHandler.process(e);
}
if (item != null && item instanceof ConnectionItem) {
repositoryConnection = ((ConnectionItem) item).getConnection();
} else {
repositoryConnection = null;
}
ChangeValuesFromRepository cmd1 = new ChangeValuesFromRepository(process, repositoryConnection, ImplicitContextLoadHelper.getExtraParameterName(EParameterName.PROPERTY_TYPE) + ":" + EParameterName.PROPERTY_TYPE.getName(), //$NON-NLS-1$
propertyType);
ChangeValuesFromRepository cmd2 = new ChangeValuesFromRepository(process, repositoryConnection, ImplicitContextLoadHelper.getExtraParameterName(EParameterName.PROPERTY_TYPE) + ":" + EParameterName.REPOSITORY_PROPERTY_TYPE.getName(), //$NON-NLS-1$
id);
AbstractMultiPageTalendEditor part = (AbstractMultiPageTalendEditor) ((IProcess2) process).getEditor();
if (part instanceof AbstractMultiPageTalendEditor) {
Object adapter = (part).getTalendEditor().getAdapter(CommandStack.class);
if (adapter != null) {
CommandStack commandStack = ((CommandStack) adapter);
commandStack.execute(cmd1);
commandStack.execute(cmd2);
}
}
}
use of org.talend.core.model.repository.IRepositoryViewObject in project tdi-studio-se by Talend.
the class NewProcessWizardPage method loadRepViewObjectWithOtherTypes.
@Override
protected List<IRepositoryViewObject> loadRepViewObjectWithOtherTypes() throws PersistenceException {
List<IRepositoryViewObject> list = new ArrayList<IRepositoryViewObject>();
// List for all other processes
List<IRepositoryViewObject> processList = getAllProcessTypeObjectsWithoutCurrentType();
if (processList != null && !processList.isEmpty()) {
list.addAll(processList);
}
// List for routine
if (ERepositoryObjectType.ROUTINES != null) {
if (GlobalServiceRegister.getDefault().isServiceRegistered(IProxyRepositoryService.class)) {
IProxyRepositoryService service = (IProxyRepositoryService) GlobalServiceRegister.getDefault().getService(IProxyRepositoryService.class);
List<IRepositoryViewObject> mrList = service.getProxyRepositoryFactory().getAll(ERepositoryObjectType.ROUTINES, true, false);
if (mrList != null && mrList.size() > 0) {
list.addAll(mrList);
}
}
}
return list;
}
Aggregations