use of org.talend.core.model.properties.ItemState in project tdi-studio-se by Talend.
the class BusinessDiagramEditor method isLastVersion.
@Override
public boolean isLastVersion(Item item) {
if (lastVersion != null) {
return lastVersion;
}
if (item.getProperty() != null) {
try {
List<IRepositoryViewObject> allVersion = null;
ItemState state = item.getState();
ERepositoryObjectType type = ERepositoryObjectType.BUSINESS_PROCESS;
if (type != null && state != null && state.getPath() != null) {
allVersion = CorePlugin.getDefault().getRepositoryService().getProxyRepositoryFactory().getAllVersion(item.getProperty().getId(), state.getPath(), type);
} else {
allVersion = CorePlugin.getDefault().getRepositoryService().getProxyRepositoryFactory().getAllVersion(item.getProperty().getId());
}
if (allVersion == null || allVersion.isEmpty()) {
return false;
}
String lastVersion = VersionUtils.DEFAULT_VERSION;
for (IRepositoryViewObject object : allVersion) {
if (VersionUtils.compareTo(object.getVersion(), lastVersion) > 0) {
lastVersion = object.getVersion();
}
}
if (VersionUtils.compareTo(item.getProperty().getVersion(), lastVersion) == 0) {
return true;
}
} catch (PersistenceException e) {
ExceptionHandler.process(e);
}
}
return false;
}
use of org.talend.core.model.properties.ItemState 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.ItemState in project tdi-studio-se by Talend.
the class DateSection method getCommitDate.
protected Date getCommitDate() {
Property property = getObject().getProperty();
if (property == null || property.getItem() == null) {
return null;
}
Item item = property.getItem();
ItemState state = item.getState();
return state.getCommitDate();
}
use of org.talend.core.model.properties.ItemState in project tesb-studio-se by Talend.
the class RouteResourcesHelper method getClasspathUrl.
public static String getClasspathUrl(Item item) {
String classPathUrl;
ItemState state = item.getState();
String path = state.getPath();
if (path != null && !path.isEmpty()) {
classPathUrl = path + "/" + getFileName(item);
} else {
classPathUrl = getFileName(item);
}
return classPathUrl;
}
use of org.talend.core.model.properties.ItemState in project tdi-studio-se by Talend.
the class FixUnevenItemContextParametersMigrationTaskTest method createTempProcessItem.
private ProcessItem createTempProcessItem() throws PersistenceException {
ProcessItem processItem = PropertiesFactory.eINSTANCE.createProcessItem();
Property myProperty = PropertiesFactory.eINSTANCE.createProperty();
myProperty.setId(ProxyRepositoryFactory.getInstance().getNextId());
ItemState itemState = PropertiesFactory.eINSTANCE.createItemState();
itemState.setDeleted(false);
itemState.setPath("");
processItem.setState(itemState);
processItem.setProperty(myProperty);
myProperty.setLabel("myJob");
myProperty.setVersion("0.1");
processItem.setProcess(TalendFileFactory.eINSTANCE.createProcessType());
ProxyRepositoryFactory.getInstance().create(processItem, new Path(""));
return processItem;
}
Aggregations