use of org.talend.repository.model.IProxyRepositoryFactory in project tdi-studio-se by Talend.
the class ControllerRepositoryValueHander method fastRepositoryUpdateSchema.
private void fastRepositoryUpdateSchema(IElementParameter param) {
if (param != null && param.getValue() != null) {
String queryIdAndName = (String) param.getValue();
//$NON-NLS-1$
String[] names = queryIdAndName.split(" - ");
if (names.length < 2) {
return;
}
String linkedRepository = names[0];
String tableName = null;
if (names.length == 2) {
tableName = names[1];
} else if (names.length > 2) {
tableName = queryIdAndName.substring(linkedRepository.length() + 3);
}
if (lastItemUsed != null) {
if (!linkedRepository.equals(lastItemUsed.getProperty().getId())) {
lastItemUsed = null;
}
}
if (lastItemUsed == null) {
IProxyRepositoryFactory factory = DesignerPlugin.getDefault().getProxyRepositoryFactory();
Item item;
try {
IRepositoryViewObject object = factory.getLastVersion(linkedRepository);
if (object == null) {
return;
}
item = object.getProperty().getItem();
Assert.isTrue(item instanceof ConnectionItem);
lastItemUsed = (ConnectionItem) item;
} catch (PersistenceException e) {
ExceptionHandler.process(e);
}
}
// EList<MetadataTable> tableList = lastItemUsed.getConnection().getTables();
// for (MetadataTable table )
String displayName = //$NON-NLS-1$
RepositoryObjectHelper.getRepositoryAliasName(lastItemUsed) + ":" + lastItemUsed.getProperty().getLabel() + " - " + //$NON-NLS-1$
tableName;
//$NON-NLS-1$
IElementParameter infoObjectTypeParam = param.getElement().getElementParameter("INFO_OBJECT_TYPE");
if (infoObjectTypeParam != null) {
String innerIOType = (String) infoObjectTypeParam.getValue();
if (innerIOType != null) {
//$NON-NLS-1$ //$NON-NLS-2$
displayName = displayName + " (" + innerIOType + ")";
}
}
param.setListItemsDisplayName(new String[] { displayName });
param.setListItemsValue(new String[] { (String) param.getValue() });
}
}
use of org.talend.repository.model.IProxyRepositoryFactory in project tdi-studio-se by Talend.
the class ControllerRepositoryValueHander method fastRepositoryUpdateProperty.
private void fastRepositoryUpdateProperty(IElementParameter param) {
if (param != null && param.getValue() != null) {
IProxyRepositoryFactory factory = DesignerPlugin.getDefault().getProxyRepositoryFactory();
String linkedRepository = (String) param.getValue();
// value stored is the id, so we can get this item directly
Item item;
String displayName = "";
try {
IRepositoryViewObject object = factory.getLastVersion(linkedRepository.split(" - ")[0]);
if (object == null) {
return;
}
item = object.getProperty().getItem();
// Assert.isTrue(item instanceof ConnectionItem);
IESBService service = null;
if (GlobalServiceRegister.getDefault().isServiceRegistered(IESBService.class)) {
service = (IESBService) GlobalServiceRegister.getDefault().getService(IESBService.class);
}
if (service != null && ERepositoryObjectType.getItemType(item) == service.getServicesType()) {
lastItemUsed = (ConnectionItem) item;
displayName = "Service:" + service.getServiceLabel(item, linkedRepository);
} else if (item instanceof ConnectionItem) {
lastItemUsed = (ConnectionItem) item;
displayName = //$NON-NLS-1$
RepositoryObjectHelper.getRepositoryAliasName(lastItemUsed) + ":" + lastItemUsed.getProperty().getLabel();
}
if (item instanceof FileItem) {
// hywang add for 6484
lastFileItemUsed = (FileItem) item;
if (lastFileItemUsed instanceof RulesItem) {
displayName = //$NON-NLS-1$
"Rules:" + lastFileItemUsed.getProperty().getLabel();
}
}
if (item instanceof LinkRulesItem) {
lastLinkItem = (LinkRulesItem) item;
displayName = //$NON-NLS-1$
"Rules:" + lastLinkItem.getProperty().getLabel();
}
if (StringUtils.isEmpty(displayName)) {
ITDQPatternService tdqService = null;
try {
tdqService = (ITDQPatternService) GlobalServiceRegister.getDefault().getService(ITDQPatternService.class);
if (tdqService != null) {
displayName = tdqService.getPatternDisplayName(item);
}
} catch (RuntimeException e) {
// nothing to do
}
}
} catch (PersistenceException e) {
ExceptionHandler.process(e);
}
param.setListItemsDisplayName(new String[] { displayName });
param.setListItemsValue(new String[] { (String) param.getValue() });
}
}
use of org.talend.repository.model.IProxyRepositoryFactory in project tdi-studio-se by Talend.
the class UpdateContentProvider method getElements.
@Override
@SuppressWarnings("unchecked")
public Object[] getElements(Object inputElement) {
List<Job> jobs = new ArrayList<Job>();
if (inputElement instanceof Collection) {
for (UpdateResult result : (List<UpdateResult>) inputElement) {
String jobName = result.getJobInfor();
if (jobName == null) {
jobName = UpdatesConstants.EMPTY;
}
Job job = getJob(jobs, jobName);
if (job == null) {
job = new Job(jobName);
Object job2 = result.getJob();
if (job2 != null) {
if (job2 instanceof IProcess2) {
// ?? joblet
job.setJoblet(((IProcess2) job2).disableRunJobView());
job.setReadOnlyProcess(result.isReadOnlyProcess());
IProcess2 process = (IProcess2) job2;
org.talend.core.model.properties.Item processItem = process.getProperty().getItem();
job.setModelItem(processItem);
boolean isMRProcess = false;
if (GlobalServiceRegister.getDefault().isServiceRegistered(IMRProcessService.class)) {
IMRProcessService mrProcessService = (IMRProcessService) GlobalServiceRegister.getDefault().getService(IMRProcessService.class);
isMRProcess = mrProcessService.isMapReduceItem(processItem);
}
boolean isStreamingProcess = false;
if (GlobalServiceRegister.getDefault().isServiceRegistered(IStormProcessService.class)) {
IStormProcessService streamingService = (IStormProcessService) GlobalServiceRegister.getDefault().getService(IStormProcessService.class);
isStreamingProcess = streamingService.isStormItem(processItem);
}
if (isMRProcess) {
job.setMR(isMRProcess);
} else if (isStreamingProcess) {
job.setStreaming(isStreamingProcess);
} else if (processItem instanceof ProcessItem) {
job.setJoblet(false);
job.setMR(false);
job.setStreaming(false);
job.setSparkJoblet(false);
job.setSparkStreamingJoblet(false);
} else if (processItem instanceof JobletProcessItem) {
boolean isSpark = false;
boolean isSparkStreaming = false;
if (GlobalServiceRegister.getDefault().isServiceRegistered(ISparkJobletProviderService.class)) {
ISparkJobletProviderService sparkJobletService = (ISparkJobletProviderService) GlobalServiceRegister.getDefault().getService(ISparkJobletProviderService.class);
if (sparkJobletService != null && sparkJobletService.isSparkJobletItem(processItem)) {
isSpark = true;
}
}
if (GlobalServiceRegister.getDefault().isServiceRegistered(ISparkStreamingJobletProviderService.class)) {
ISparkStreamingJobletProviderService sparkStreamingJobletService = (ISparkStreamingJobletProviderService) GlobalServiceRegister.getDefault().getService(ISparkStreamingJobletProviderService.class);
if (sparkStreamingJobletService != null && sparkStreamingJobletService.isSparkStreamingJobletItem(processItem)) {
isSparkStreaming = true;
}
}
if (isSpark) {
job.setSparkJoblet(true);
job.setJoblet(false);
} else if (isSparkStreaming) {
job.setSparkStreamingJoblet(true);
job.setJoblet(false);
} else {
job.setJoblet(true);
}
}
}
} else {
String itemId = result.getObjectId();
if (itemId != null) {
IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
try {
IRepositoryViewObject repoViewObject = factory.getLastVersion(itemId);
if (repoViewObject != null) {
Property property = repoViewObject.getProperty();
if (property != null) {
job.setModelItem(property.getItem());
}
}
} catch (PersistenceException e) {
CommonExceptionHandler.process(e, Priority.WARN);
}
}
job.setJoblet(result.isJoblet());
job.setMR(result.isMR());
job.setStreaming(result.isStreaming());
job.setSparkJoblet(result.isSparkJoblet());
job.setSparkStreamingJoblet(result.isSparkStreamingJoblet());
}
jobs.add(job);
}
Category category = job.getCategory(result.getCategory());
if (category == null) {
category = new Category(job, result.getCategory());
// for icon
category.setType(result.getUpdateType());
if (result.getUpdateObject() instanceof Node) {
// for node icon
category.setNode(result.getUpdateObject());
}
if (result.getUpdateObject() instanceof NodeType) {
// for node icon
category.setNode(result.getUpdateObject());
}
if (result.getUpdateObject() instanceof List) {
// for node icon
List list = (List) result.getUpdateObject();
if (list.size() > 0) {
Object object = list.get(0);
if (object instanceof Node) {
category.setNode(object);
}
}
}
job.addCategory(category);
}
Item item = new Item(category, result);
category.addItem(item);
}
}
return jobs.toArray();
}
use of org.talend.repository.model.IProxyRepositoryFactory in project tdi-studio-se by Talend.
the class SetupProcessDependenciesRoutinesAction method init.
@Override
public void init(TreeViewer viewer, IStructuredSelection selection) {
boolean canWork = !selection.isEmpty() && selection.size() == 1;
IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
if (factory.isUserReadOnlyOnCurrentProject()) {
canWork = false;
}
if (canWork) {
Object o = selection.getFirstElement();
RepositoryNode node = (RepositoryNode) o;
switch(node.getType()) {
case REPOSITORY_ELEMENT:
if (ERepositoryObjectType.PROCESS_STORM != null && node.getObjectType().equals(ERepositoryObjectType.PROCESS_STORM)) {
canWork = true;
} else if (ERepositoryObjectType.PROCESS_MR != null && node.getObjectType().equals(ERepositoryObjectType.PROCESS_MR)) {
canWork = true;
} else if (ERepositoryObjectType.SPARK_JOBLET != null && node.getObjectType().equals(ERepositoryObjectType.SPARK_JOBLET)) {
canWork = true;
} else if (ERepositoryObjectType.SPARK_STREAMING_JOBLET != null && node.getObjectType().equals(ERepositoryObjectType.SPARK_STREAMING_JOBLET)) {
canWork = true;
} else if (node.getObjectType() != ERepositoryObjectType.PROCESS && node.getObjectType() != ERepositoryObjectType.JOBLET) {
canWork = false;
}
break;
default:
canWork = false;
}
if (canWork && node.getObject() != null && ProxyRepositoryFactory.getInstance().getStatus(node.getObject()) == ERepositoryStatus.DELETED) {
canWork = false;
}
if (canWork && !ProjectManager.getInstance().isInCurrentMainProject(node)) {
canWork = false;
}
// If the editProcess action canwork is true, then detect that the job version is the latest verison or not.
if (canWork) {
canWork = isLastVersion(node);
}
}
setEnabled(canWork);
}
use of org.talend.repository.model.IProxyRepositoryFactory in project tdi-studio-se by Talend.
the class SetupProcessDependenciesRoutinesAction method doRun.
@Override
protected void doRun() {
ISelection selection = getSelection();
Object obj = ((IStructuredSelection) selection).getFirstElement();
if (obj == null) {
return;
}
RepositoryNode node = (RepositoryNode) obj;
boolean readonly = false;
IRepositoryService service = DesignerPlugin.getDefault().getRepositoryService();
IProxyRepositoryFactory repFactory = service.getProxyRepositoryFactory();
ERepositoryStatus status = repFactory.getStatus(node.getObject());
if (!repFactory.isPotentiallyEditable(node.getObject()) || status == ERepositoryStatus.LOCK_BY_OTHER || status == ERepositoryStatus.LOCK_BY_USER) {
readonly = true;
}
Item item = node.getObject().getProperty().getItem();
if (item instanceof ProcessItem) {
ProcessItem processItem = (ProcessItem) item;
ProcessType process = processItem.getProcess();
SetupProcessDependenciesRoutinesDialog dialog = new SetupProcessDependenciesRoutinesDialog(PlatformUI.getWorkbench().getDisplay().getActiveShell(), process, readonly);
if (dialog.open() == Window.OK && !readonly) {
process.getParameters().getRoutinesParameter().clear();
createRoutinesDependencies(process, dialog.getSystemRoutines());
createRoutinesDependencies(process, dialog.getUserRoutines());
try {
CorePlugin.getDefault().getRepositoryService().getProxyRepositoryFactory().save(processItem);
RelationshipItemBuilder.getInstance().addOrUpdateItem(processItem);
} catch (PersistenceException e) {
ExceptionHandler.process(e);
}
}
} else if (item instanceof JobletProcessItem) {
JobletProcessItem jobProcessItem = (JobletProcessItem) item;
ProcessType process = jobProcessItem.getJobletProcess();
SetupProcessDependenciesRoutinesDialog dialog = new SetupProcessDependenciesRoutinesDialog(PlatformUI.getWorkbench().getDisplay().getActiveShell(), process, readonly);
if (dialog.open() == Window.OK && !readonly) {
process.getParameters().getRoutinesParameter().clear();
createRoutinesDependencies(process, dialog.getSystemRoutines());
createRoutinesDependencies(process, dialog.getUserRoutines());
try {
CorePlugin.getDefault().getRepositoryService().getProxyRepositoryFactory().save(jobProcessItem);
IJobletProviderService jobletService = (IJobletProviderService) GlobalServiceRegister.getDefault().getService(IJobletProviderService.class);
if (jobletService != null) {
jobletService.loadComponentsFromProviders();
}
RelationshipItemBuilder.getInstance().addOrUpdateItem(jobProcessItem);
} catch (PersistenceException e) {
ExceptionHandler.process(e);
}
}
}
}
Aggregations