use of org.talend.core.model.properties.Property in project tdi-studio-se by Talend.
the class VersionManagementPage method updateItemsVersion.
@Override
protected void updateItemsVersion() {
final IWorkspaceRunnable runnable = new IWorkspaceRunnable() {
@Override
public void run(final IProgressMonitor monitor) throws CoreException {
RepositoryWorkUnit<Object> rwu = new RepositoryWorkUnit<Object>(project, "Update items version") {
@Override
protected void run() throws LoginException, PersistenceException {
//$NON-NLS-1$
monitor.beginTask("Update items version", checkedObjects.size());
Map<String, String> versions = new HashMap<String, String>();
for (int i = 0; i < checkedObjects.size(); i++) {
ItemVersionObject object = checkedObjects.get(i);
versions.put(object.getItem().getProperty().getId(), object.getOldVersion());
}
for (ItemVersionObject object : checkedObjects) {
IRepositoryViewObject repositoryObject = object.getRepositoryNode().getObject();
if (repositoryObject != null && repositoryObject.getProperty() != null) {
if (!object.getNewVersion().equals(repositoryObject.getVersion())) {
final Item item = object.getItem();
Property itemProperty = item.getProperty();
itemProperty.setVersion(object.getNewVersion());
monitor.subTask(itemProperty.getLabel());
try {
// for bug 12853 ,version management doesn't work for joblet because eResource
// is null
IRepositoryViewObject obj = null;
if (itemProperty.eResource() == null) {
ItemState state = item.getState();
if (state != null && state.getPath() != null) {
obj = FACTORY.getLastVersion(project, itemProperty.getId(), state.getPath(), object.getRepositoryNode().getObjectType());
} else {
obj = FACTORY.getLastVersion(project, itemProperty.getId());
}
}
if (obj != null) {
// obj.setVersion(object.getNewVersion());
FACTORY.save(project, obj.getProperty());
builder.addOrUpdateItem(obj.getProperty().getItem(), true);
} else {
String id = itemProperty.getId();
FACTORY.save(project, itemProperty);
if (versionLatest.getSelection()) {
builder.updateItemVersion(item, object.getOldVersion(), id, versions, true);
}
builder.addOrUpdateItem(item, true);
}
} catch (PersistenceException e) {
ExceptionHandler.process(e);
}
}
}
monitor.worked(1);
}
try {
FACTORY.saveProject(project);
} catch (PersistenceException e) {
ExceptionHandler.process(e);
}
}
};
rwu.setAvoidUnloadResources(true);
rwu.executeRun();
monitor.done();
}
};
IRunnableWithProgress iRunnableWithProgress = new IRunnableWithProgress() {
@Override
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
IWorkspace workspace = ResourcesPlugin.getWorkspace();
try {
ISchedulingRule schedulingRule = workspace.getRoot();
// the update the project files need to be done in the workspace runnable to avoid all notification
// of changes before the end of the modifications.
workspace.run(runnable, schedulingRule, IWorkspace.AVOID_UPDATE, monitor);
} catch (CoreException e) {
ExceptionHandler.process(e);
}
}
};
// final ProgressMonitorJobsDialog dialog = new ProgressMonitorJobsDialog(null);
final ProgressMonitorDialog dialog = new ProgressMonitorDialog(null);
try {
dialog.run(false, false, iRunnableWithProgress);
} catch (InvocationTargetException e) {
ExceptionHandler.process(e);
} catch (InterruptedException e) {
ExceptionHandler.process(e);
}
}
use of org.talend.core.model.properties.Property in project tdi-studio-se by Talend.
the class AbstractConextAction method updateNodeToLastVersion.
/*
* (non-Javadoc)
*
* @see org.talend.repository.ui.actions.AContextualAction#updateNodeToLastVersion()
*/
@Override
protected void updateNodeToLastVersion() {
if (repositoryNode == null || repositoryNode.getObject() == null || !(repositoryNode.getObject() instanceof RepositoryObject)) {
return;
}
Property property = repositoryNode.getObject().getProperty();
Property updatedProperty = null;
try {
updatedProperty = ProxyRepositoryFactory.getInstance().getLastVersion(new Project(ProjectManager.getInstance().getProject(property.getItem())), property.getId()).getProperty();
} catch (PersistenceException e) {
ExceptionHandler.process(e);
}
// update the property of the node repository object
// repositoryNode.getObject().setProperty(updatedProperty);
}
use of org.talend.core.model.properties.Property in project tdi-studio-se by Talend.
the class AbstractSchemaController method createComboCommand.
@Override
protected Command createComboCommand(CCombo combo) {
IMetadataTable repositoryMetadata = null;
String fullParamName = (String) combo.getData(PARAMETER_NAME);
IElementParameter switchParam = elem.getElementParameter(EParameterName.REPOSITORY_ALLOW_AUTO_SWITCH.getName());
//$NON-NLS-1$
String value = new String("");
IElementParameter param = elem.getElementParameter(fullParamName);
for (int j = 0; j < param.getListItemsValue().length; j++) {
if (combo.getText().equals(param.getListItemsDisplayName()[j])) {
value = (String) param.getListItemsValue()[j];
}
}
// if change to build-in, unuse the validation rule if the component has.
boolean isValRulesLost = false;
IRepositoryViewObject currentValRuleObj = ValidationRulesUtil.getCurrentValidationRuleObjs(elem);
if (value.equals(EmfComponent.BUILTIN) && currentValRuleObj != null) {
if (!MessageDialog.openConfirm(combo.getShell(), //$NON-NLS-1$
Messages.getString("AbstractSchemaController.validationrule.title.confirm"), Messages.getString("AbstractSchemaController.validationrule.selectBuildInMsg"))) {
//$NON-NLS-1$
return null;
} else {
isValRulesLost = true;
}
}
org.talend.core.model.metadata.builder.connection.Connection connection = null;
if (elem instanceof Node) {
Node node = (Node) elem;
Command baseCommand = null;
boolean isReadOnly = false;
String newRepositoryIdValue = null;
if (node.getMetadataFromConnector(param.getContext()) != null) {
isReadOnly = node.getMetadataFromConnector(param.getContext()).isReadOnly();
}
if (//$NON-NLS-1$
value.equals(EmfComponent.BUILTIN) && isReadOnly && !"tLogCatcher".equals(node.getComponent().getName()) && !"tStatCatcher".equals(node.getComponent().getName())) {
//$NON-NLS-1$
boolean hasMetadataInput = false;
if (node.getCurrentActiveLinksNbInput(EConnectionType.FLOW_MAIN) > 0 || node.getCurrentActiveLinksNbInput(EConnectionType.TABLE) > 0) {
hasMetadataInput = true;
}
repositoryMetadata = new MetadataTable();
if (hasMetadataInput) {
for (Connection connec : (List<Connection>) node.getIncomingConnections()) {
if (connec.isActivate() && (connec.getLineStyle().equals(EConnectionType.FLOW_MAIN) || connec.getLineStyle().equals(EConnectionType.TABLE))) {
repositoryMetadata = connec.getMetadataTable().clone();
}
}
}
} else if (value.equals(EmfComponent.REPOSITORY)) {
// Map<String, IMetadataTable> repositoryTableMap = dynamicProperty.getRepositoryTableMap();
IElementParameter property = ((Node) elem).getElementParameter(EParameterName.PROPERTY_TYPE.getName());
if ((property != null) && EmfComponent.REPOSITORY.equals(property.getValue())) {
String propertySelected = (String) ((Node) elem).getElementParameter(EParameterName.REPOSITORY_PROPERTY_TYPE.getName()).getValue();
IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
/* 16969 */
Item item = null;
try {
IRepositoryViewObject repobj = factory.getLastVersion(propertySelected);
if (repobj != null) {
Property tmpproperty = repobj.getProperty();
if (tmpproperty != null) {
item = tmpproperty.getItem();
}
}
// item = factory.getLastVersion(propertySelected).getProperty().getItem();
} catch (PersistenceException e) {
ExceptionHandler.process(e);
}
if (item != null && item instanceof ConnectionItem) {
final ConnectionItem connectionItem = (ConnectionItem) item;
if (connectionItem != null) {
connection = connectionItem.getConnection();
}
}
}
IElementParameter repositorySchemaType = param.getParentParameter().getChildParameters().get(EParameterName.REPOSITORY_SCHEMA_TYPE.getName());
String schemaSelected = (String) repositorySchemaType.getValue();
if (schemaSelected == null) {
//$NON-NLS-1$
schemaSelected = "";
}
/* value can be devided means the value like "connectionid - label" */
//$NON-NLS-1$
String[] keySplitValues = schemaSelected.toString().split(" - ");
if (keySplitValues.length > 1) {
String connectionId = keySplitValues[0];
String tableLabel = keySplitValues[1];
IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
Item item = null;
try {
IRepositoryViewObject repobj = factory.getLastVersion(connectionId);
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) {
final ConnectionItem connectionItem = (ConnectionItem) item;
if (connectionItem != null) {
connection = connectionItem.getConnection();
}
}
if (item != null && item instanceof ConnectionItem) {
boolean findTable = false;
Set<org.talend.core.model.metadata.builder.connection.MetadataTable> tables = null;
IGenericWizardService wizardService = null;
if (GlobalServiceRegister.getDefault().isServiceRegistered(IGenericWizardService.class)) {
wizardService = (IGenericWizardService) GlobalServiceRegister.getDefault().getService(IGenericWizardService.class);
}
if (wizardService != null && wizardService.isGenericItem(item)) {
tables = new HashSet<>(wizardService.getMetadataTables(connection));
} else {
tables = ConnectionHelper.getTables(connection);
}
for (org.talend.core.model.metadata.builder.connection.MetadataTable table : tables) {
if (table.getLabel().equals(tableLabel)) {
repositoryMetadata = ConvertionHelper.convert(table);
newRepositoryIdValue = schemaSelected;
findTable = true;
break;
}
}
if (!findTable) {
repositoryMetadata = new MetadataTable();
}
} else {
repositoryMetadata = new MetadataTable();
}
} else {
// value only got a empty string
repositoryMetadata = new MetadataTable();
}
} else {
baseCommand = new PropertyChangeCommand(elem, fullParamName, value);
}
if (switchParam != null) {
switchParam.setValue(Boolean.FALSE);
}
CompoundCommand cc = new CompoundCommand();
if (baseCommand != null) {
cc.add(baseCommand);
} else {
RepositoryChangeMetadataCommand changeMetadataCommand = new RepositoryChangeMetadataCommand((Node) elem, fullParamName, value, repositoryMetadata, newRepositoryIdValue, null);
changeMetadataCommand.setConnection(connection);
cc.add(changeMetadataCommand);
}
// unuse the validation rules of the component.
if (isValRulesLost) {
ValidationRulesUtil.appendRemoveValidationRuleCommands(cc, elem);
}
return cc;
}
return null;
}
use of org.talend.core.model.properties.Property in project tdi-studio-se by Talend.
the class ComboController method createButtonCommand.
/**
* This method is used for "Guess Query" button.
*
* @return
*/
private Command createButtonCommand() {
IMetadataTable repositoryMetadata = null;
IMetadataTable newRepositoryMetadata = null;
String realTableName = null;
String realTableId = null;
// Only for getting the real table name.
if (elem.getPropertyValue(EParameterName.SCHEMA_TYPE.getName()).equals(EmfComponent.REPOSITORY)) {
String paramName;
IElementParameter repositorySchemaTypeParameter = elem.getElementParameter(EParameterName.REPOSITORY_SCHEMA_TYPE.getName());
Object repositoryControl = hashCurControls.get(repositorySchemaTypeParameter.getName());
paramName = EParameterName.REPOSITORY_SCHEMA_TYPE.getName();
if (repositoryControl != null) {
String selectedComboItem = ((CCombo) repositoryControl).getText();
if (selectedComboItem != null && selectedComboItem.length() > 0) {
//$NON-NLS-1$
String value = new String("");
for (int i = 0; i < elem.getElementParameters().size(); i++) {
IElementParameter param = elem.getElementParameters().get(i);
if (param.getName().equals(paramName)) {
for (int j = 0; j < param.getListItemsValue().length; j++) {
if (selectedComboItem.equals(param.getListItemsDisplayName()[j])) {
value = (String) param.getListItemsValue()[j];
}
}
}
}
if (elem instanceof Node) {
// this.dynamicProperty.updateRepositoryList();
String connectionId = value.toString().split(" - ")[0];
String tableLabel = value.toString().split(" - ")[1];
IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
Item item = null;
try {
IRepositoryViewObject repobj = factory.getLastVersion(connectionId);
if (repobj != null) {
Property property = repobj.getProperty();
if (property != null) {
item = property.getItem();
}
}
} catch (PersistenceException e) {
ExceptionHandler.process(e);
}
if (item != null && item instanceof ConnectionItem) {
boolean findTable = false;
Connection connection = ((ConnectionItem) item).getConnection();
for (org.talend.core.model.metadata.builder.connection.MetadataTable table : ConnectionHelper.getTables(connection)) {
if (table.getLabel().equals(tableLabel)) {
repositoryMetadata = ConvertionHelper.convert(table);
findTable = true;
break;
}
}
if (!findTable) {
repositoryMetadata = new MetadataTable();
}
}
// if (repositoryTableMap.containsKey(value)) {
// repositoryMetadata = repositoryTableMap.get(value);
// realTableName = repositoryMetadata.getTableName();
// realTableId = repositoryMetadata.getId();
// } else {
// repositoryMetadata = new MetadataTable();
// }
}
}
}
}
// Ends
QueryGuessCommand cmd = null;
INode node = null;
if (elem instanceof INode) {
node = (INode) elem;
} else {
// else instanceof Connection
node = ((IConnection) elem).getSource();
}
newRepositoryMetadata = node.getMetadataList().get(0);
if (newRepositoryMetadata == null) {
String schemaSelected = (String) node.getPropertyValue(EParameterName.REPOSITORY_SCHEMA_TYPE.getName());
if (schemaSelected != null) {
String connectionId = schemaSelected.toString().split(" - ")[0];
String tableLabel = schemaSelected.toString().split(" - ")[1];
IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
Item item = null;
try {
IRepositoryViewObject repobj = factory.getLastVersion(connectionId);
if (repobj != null) {
Property property = repobj.getProperty();
if (property != null) {
item = property.getItem();
}
}
} catch (PersistenceException e) {
ExceptionHandler.process(e);
}
if (item != null && item instanceof ConnectionItem) {
boolean findTable = false;
Connection connection = ((ConnectionItem) item).getConnection();
for (org.talend.core.model.metadata.builder.connection.MetadataTable table : ConnectionHelper.getTables(connection)) {
if (table.getLabel().equals(tableLabel)) {
repositoryMetadata = ConvertionHelper.convert(table);
findTable = true;
break;
}
}
if (!findTable) {
repositoryMetadata = new MetadataTable();
}
}
// repositoryMetadata = repositoryTableMap.get(schemaSelected);
} else if (newRepositoryMetadata == null) {
MessageDialog.openWarning(new Shell(), Messages.getString("ComboController.alert"), //$NON-NLS-1$ //$NON-NLS-2$
Messages.getString("ComboController.nothingGuess"));
return cmd;
}
}
cmd = new QueryGuessCommand(node, newRepositoryMetadata);
/* parameter can be null,the setMaps won't use the third parameter */
cmd.setMaps(dynamicProperty.getTableIdAndDbTypeMap(), dynamicProperty.getTableIdAndDbSchemaMap(), null);
//$NON-NLS-1$
String type = getValueFromRepositoryName("TYPE");
cmd.setParameters(realTableId, realTableName, type);
return cmd;
}
use of org.talend.core.model.properties.Property 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();
}
Aggregations