use of org.talend.commons.runtime.model.repository.ERepositoryStatus in project tdi-studio-se by Talend.
the class JobletUtil method lockByOthers.
// public void reloadJobletComponent(IProcess2 process){
// IJobletProviderService service = (IJobletProviderService) GlobalServiceRegister.getDefault().getService(
// IJobletProviderService.class);
// if (service != null) {
// process.get
// service.reloadJobletProcess(this);
// }
// }
public boolean lockByOthers(Item item) {
IProxyRepositoryService service = (IProxyRepositoryService) GlobalServiceRegister.getDefault().getService(IProxyRepositoryService.class);
IProxyRepositoryFactory factory = service.getProxyRepositoryFactory();
ERepositoryStatus repositoryStatus = factory.getStatus(item);
if (repositoryStatus == ERepositoryStatus.LOCK_BY_OTHER) {
return true;
}
return false;
}
use of org.talend.commons.runtime.model.repository.ERepositoryStatus in project tdi-studio-se by Talend.
the class ImportItemWizardPage method populateItems.
/**
* DOC hcw Comment method "populateItems".
*/
private void populateItems() {
selectedItems.clear();
final Collection<ItemRecord> items = new ArrayList<ItemRecord>();
IRunnableWithProgress op = new IRunnableWithProgress() {
@Override
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
repositoryUtil.clearAllData();
items.addAll(totalItemRecords = repositoryUtil.populateItems(manager, overwrite, monitor));
}
};
try {
new ProgressMonitorDialog(getShell()).run(true, true, op);
} catch (Exception e) {
// ignore me
}
errors.clear();
for (ItemRecord itemRecord : items) {
// bug 21738
if (itemRecord.getExistingItemWithSameId() != null && itemRecord.getExistingItemWithSameId() instanceof RepositoryViewObject) {
RepositoryViewObject reObject = (RepositoryViewObject) itemRecord.getExistingItemWithSameId();
if (itemRecord.getProperty() != null && reObject != null) {
if (itemRecord.getProperty().getId().equals(reObject.getId()) && itemRecord.getProperty().getLabel().equals(reObject.getLabel()) && itemRecord.getProperty().getVersion().equals(reObject.getVersion())) {
for (String error : itemRecord.getErrors()) {
//$NON-NLS-1$ //$NON-NLS-2$
errors.add("'" + itemRecord.getItemName() + "' " + error);
}
} else if (itemRecord.getProperty().getId().equals(reObject.getId()) && itemRecord.getProperty().getLabel().equals(reObject.getLabel()) && !itemRecord.getProperty().getVersion().equals(reObject.getVersion())) {
for (String error : itemRecord.getErrors()) {
//$NON-NLS-1$ //$NON-NLS-2$
errors.add("'" + itemRecord.getItemName() + "' " + Messages.getString("ImportItemWizardPage.ErrorsMessage", reObject.getVersion()));
}
} else {
// TDI-21399,TDI-21401
// if item is locked, cannot overwrite
ERepositoryStatus status = reObject.getRepositoryStatus();
if (status == ERepositoryStatus.LOCK_BY_OTHER || status == ERepositoryStatus.LOCK_BY_USER) {
for (String error : itemRecord.getErrors()) {
//$NON-NLS-1$ //$NON-NLS-2$
errors.add("'" + itemRecord.getItemName() + "' " + error);
}
}
}
}
} else {
if (itemRecord.getProperty() != null) {
Item item = itemRecord.getProperty().getItem();
if (item != null && (item instanceof JobDocumentationItem || item instanceof JobletDocumentationItem)) {
continue;
}
for (String error : itemRecord.getErrors()) {
//$NON-NLS-1$ //$NON-NLS-2$
errors.add("'" + itemRecord.getItemName() + "' " + error);
}
}
}
}
if (errorsList != null) {
errorsList.refresh();
}
selectedItems.addAll(items);
checkTreeViewer.refresh(true);
checkTreeViewer.expandAll();
filteredCheckboxTree.resetCheckedElements();
checkValidItems();
updateFinishStatus();
// see feature 0004170: Unselect all items to import
// itemsList.setCheckedElements(checkValidItems());
}
use of org.talend.commons.runtime.model.repository.ERepositoryStatus in project tesb-studio-se by Talend.
the class RouteResourceEditorUtil method isReadOnly.
public static boolean isReadOnly(IRepositoryNode node) {
IRepositoryService service = DesignerPlugin.getDefault().getRepositoryService();
IProxyRepositoryFactory repFactory = service.getProxyRepositoryFactory();
/*
* if user is readonly , then set enable as false
*/
if (repFactory.isUserReadOnlyOnCurrentProject()) {
return true;
}
// if it's not in current project, then it's disable
if (!ProjectManager.getInstance().isInCurrentMainProject(node)) {
return true;
}
// if it's locked by others, then it's disable
IRepositoryViewObject object = node.getObject();
if (object == null) {
return false;
}
Property property = object.getProperty();
if (property == null) {
return false;
}
Item item = property.getItem();
if (item == null) {
return false;
}
ERepositoryStatus status = repFactory.getStatus(item);
if (ERepositoryStatus.LOCK_BY_OTHER.equals(status) || ERepositoryStatus.DELETED.equals(status)) {
return true;
}
if (!isLatestVersion(property)) {
return true;
}
return false;
}
use of org.talend.commons.runtime.model.repository.ERepositoryStatus in project tdi-studio-se by Talend.
the class ConfigExternalLibPage method isReadOnly.
public boolean isReadOnly() {
boolean readonly = false;
IProxyRepositoryFactory repFactory = ProxyRepositoryFactory.getInstance();
ERepositoryStatus status = repFactory.getStatus(getSelectedRepositoryNode().getObject());
if (!repFactory.isPotentiallyEditable(getSelectedRepositoryNode().getObject()) || status == ERepositoryStatus.LOCK_BY_OTHER || status == ERepositoryStatus.LOCK_BY_USER) {
readonly = true;
}
return readonly;
}
use of org.talend.commons.runtime.model.repository.ERepositoryStatus in project tdi-studio-se by Talend.
the class TalendImportUtil method importItems.
public static boolean importItems(String zipPath, IProgressMonitor monitor, final boolean overwrite, final boolean openThem, boolean needMigrationTask) throws IOException {
// File srcFile = new File(zipPath);
ZipFile srcZipFile = new ZipFile(zipPath);
final ImportExportHandlersManager importManager = new ImportExportHandlersManager();
final ResourcesManager resourcesManager = ResourcesManagerFactory.getInstance().createResourcesManager(srcZipFile);
// resourcesManager.collectPath2Object(srcFile);
resourcesManager.collectPath2Object(srcZipFile);
final List<ImportItem> items = populateItems(importManager, resourcesManager, monitor, overwrite);
final List<String> itemIds = new ArrayList<String>();
try {
for (ImportItem itemRecord : items) {
Item item = itemRecord.getProperty().getItem();
if (item instanceof ProcessItem) {
// only select jobs
itemIds.add(item.getProperty().getId());
}
IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
if (item.getState().isLocked()) {
factory.unlock(item);
}
ERepositoryStatus status = factory.getStatus(item);
if (status != null && status == ERepositoryStatus.LOCK_BY_USER) {
factory.unlock(item);
}
if (!needMigrationTask) {
itemRecord.setMigrationTasksToApply(null);
}
}
// nodesBuilder.getAllImportItemRecords(), null);
if (items != null && !items.isEmpty()) {
importManager.importItemRecords(monitor, resourcesManager, items, overwrite, nodesBuilder.getAllImportItemRecords(), null);
}
} catch (Exception e) {
CommonExceptionHandler.process(e);
} finally {
// clean
if (resourcesManager != null) {
resourcesManager.closeResource();
}
nodesBuilder.clear();
}
return true;
}
Aggregations