use of org.talend.core.model.properties.FolderItem in project tdq-studio-se by Talend.
the class RecycleBinRepNode method addItemToRecycleBin.
private void addItemToRecycleBin(DQRepositoryNode parentNode, Item item, List<DQRepositoryNode> foldersList, Project project) {
ERepositoryObjectType itemType = ERepositoryObjectType.getItemType(item);
DQRepositoryNode currentParentNode = parentNode;
if (item instanceof FolderItem) {
itemType = getFolderContentType((FolderItem) item);
FolderItem folderItem = (FolderItem) item;
EList<Item> childrenList = folderItem.getChildren();
if (childrenList.isEmpty()) {
initChildren(folderItem, itemType);
}
if (folderItem.getState() != null && folderItem.getState().isDeleted()) {
// need to display this folder in the recycle bin.
Folder folder = new Folder(folderItem.getProperty(), itemType);
DQRepositoryNode folderNode = null;
for (DQRepositoryNode existingFolder : foldersList) {
if (existingFolder.getContentType() == null) {
// this can appear temporary when another user has deleted a folder
break;
}
if (existingFolder.getContentType().equals(folder.getRepositoryObjectType()) && existingFolder.getProperties(EProperties.LABEL).equals(folder.getLabel())) {
folderNode = existingFolder;
break;
}
}
if (folderNode == null) {
folderNode = new DQRepositoryNode(folder, parentNode, ENodeType.SIMPLE_FOLDER, project);
folderNode.setProperties(EProperties.CONTENT_TYPE, itemType);
folderNode.setProperties(EProperties.LABEL, folder.getLabel());
foldersList.add(folderNode);
parentNode.getChildren(false).add(folderNode);
folderNode.setParent(parentNode);
}
for (Item curItem : new ArrayList<Item>(childrenList)) {
if (isAviableFolderForDQ(curItem, itemType)) {
addItemToRecycleBin(folderNode, curItem, foldersList, project);
}
}
currentParentNode = folderNode;
} else {
for (Item curItem : new ArrayList<Item>(childrenList)) {
if (isAviableFolderForDQ(curItem, itemType)) {
addItemToRecycleBin(parentNode, curItem, foldersList, project);
}
}
}
} else if (item.getState() != null && item.getState().isDeleted()) {
// try {
// IRepositoryViewObject lastVersion = ProxyRepositoryFactory.getInstance().getLastVersion(getProject(),
// item.getProperty().getId());
// String version = lastVersion.getVersion();
// if (item.getProperty() .getVersion() .equals(version)) {
DQRepositoryNode repNode = new DQRepositoryNode(new RepositoryViewObject(item.getProperty()), currentParentNode, ENodeType.REPOSITORY_ELEMENT, project);
repNode.setProperties(EProperties.CONTENT_TYPE, itemType);
repNode.setProperties(EProperties.LABEL, item.getProperty().getLabel());
currentParentNode.getChildren(false).add(repNode);
repNode.setParent(currentParentNode);
// }
// } catch (PersistenceException e) {
// ExceptionHandler.process(e);
// }
}
}
use of org.talend.core.model.properties.FolderItem in project tmdm-studio-se by Talend.
the class RemoveFromRepositoryAction method removeFolderObject.
private void removeFolderObject(IRepositoryViewObject viewObj) {
if (removed.contains(viewObj.getId())) {
return;
}
for (IRepositoryViewObject childObj : viewObj.getChildren()) {
if (childObj instanceof FolderRepositoryObject) {
removeFolderObject(childObj);
} else {
removeServerObject(childObj);
}
}
removed.add(viewObj.getId());
//
ContainerItem containerItem = (ContainerItem) viewObj.getProperty().getItem();
String path = containerItem.getState().getPath();
ERepositoryObjectType repObjType = containerItem.getRepObjType();
ContainerCacheService.removeContainer(repObjType, path);
FolderItem folderItem = factory.getFolderItem(ProjectManager.getInstance().getCurrentProject(), repObjType, new Path(path));
folderItem.getState().setDeleted(true);
}
use of org.talend.core.model.properties.FolderItem in project tbd-studio-se by Talend.
the class HadoopClusterRepositoryTypeProcessor method selectRepositoryNode.
/*
* (non-Javadoc)
*
* @see
* org.talend.repository.ui.processor.SingleTypeProcessor#selectRepositoryNode(org.eclipse.jface.viewers.Viewer,
* org.talend.repository.model.RepositoryNode, org.talend.repository.model.RepositoryNode)
*/
@Override
protected boolean selectRepositoryNode(Viewer viewer, RepositoryNode parentNode, RepositoryNode node) {
final String repositoryType = getRepositoryType();
if (node == null || repositoryType == null) {
return false;
}
ERepositoryObjectType repObjType = (ERepositoryObjectType) node.getProperties(EProperties.CONTENT_TYPE);
if (repObjType == ERepositoryObjectType.REFERENCED_PROJECTS) {
return true;
}
if (node.getType() == ENodeType.SYSTEM_FOLDER) {
return true;
}
if (node.getType() == ENodeType.SIMPLE_FOLDER || HCRepositoryUtil.isHadoopContainerNode(node)) {
return isValidFolder(node);
}
IRepositoryViewObject object = node.getObject();
if (object == null || object.getProperty().getItem() == null) {
return false;
}
if (object instanceof MetadataTable) {
return false;
}
Item item = object.getProperty().getItem();
if (item instanceof FolderItem) {
return true;
}
return true;
}
use of org.talend.core.model.properties.FolderItem in project tbd-studio-se by Talend.
the class HadoopSubRepositoryTypeProcessor method selectRepositoryNode.
/*
* (non-Javadoc)
*
* @see
* org.talend.repository.ui.processor.SingleTypeProcessor#selectRepositoryNode(org.eclipse.jface.viewers.Viewer,
* org.talend.repository.model.RepositoryNode, org.talend.repository.model.RepositoryNode)
*/
@Override
protected boolean selectRepositoryNode(Viewer viewer, RepositoryNode parentNode, RepositoryNode node) {
final String repositoryType = getRepositoryType();
if (node == null || repositoryType == null) {
return false;
}
ERepositoryObjectType repObjType = (ERepositoryObjectType) node.getProperties(EProperties.CONTENT_TYPE);
if (repObjType == ERepositoryObjectType.REFERENCED_PROJECTS) {
return true;
}
if (node.getType() == ENodeType.SYSTEM_FOLDER) {
return true;
}
if (node.getType() == ENodeType.SIMPLE_FOLDER || HCRepositoryUtil.isHadoopContainerNode(node)) {
return isValidFolder(node);
}
IRepositoryViewObject object = node.getObject();
if (object == null || object.getProperty().getItem() == null) {
return false;
}
if (object instanceof MetadataTable) {
return false;
}
Item item = object.getProperty().getItem();
if (item instanceof FolderItem) {
return true;
}
return true;
}
use of org.talend.core.model.properties.FolderItem in project tbd-studio-se by Talend.
the class NoSQLRepositoryTypeProcessor method selectRepositoryNode.
/*
* (non-Javadoc)
*
* @see
* org.talend.repository.ui.processor.SingleTypeProcessor#selectRepositoryNode(org.eclipse.jface.viewers.Viewer,
* org.talend.repository.model.RepositoryNode, org.talend.repository.model.RepositoryNode)
*/
@Override
protected boolean selectRepositoryNode(Viewer viewer, RepositoryNode parentNode, RepositoryNode node) {
final String repositoryType = getRepositoryType();
if (node == null || repositoryType == null) {
return false;
}
ERepositoryObjectType repObjType = (ERepositoryObjectType) node.getProperties(EProperties.CONTENT_TYPE);
if (repObjType == ERepositoryObjectType.REFERENCED_PROJECTS) {
return true;
}
if (node.getType() == ENodeType.SYSTEM_FOLDER) {
return true;
}
IRepositoryViewObject object = node.getObject();
if (object == null || object.getProperty().getItem() == null) {
return false;
}
if (object instanceof MetadataTable) {
return false;
}
Item item = object.getProperty().getItem();
if (item instanceof FolderItem) {
return true;
}
if (item instanceof NoSQLConnectionItem) {
NoSQLConnectionItem connectionItem = (NoSQLConnectionItem) item;
NoSQLConnection connection = (NoSQLConnection) connectionItem.getConnection();
if (repositoryType.startsWith(INoSQLConstants.NOSQL_TYPE_PREFIX)) {
// $NON-NLS-1$
String realDbType = repositoryType.substring(repositoryType.indexOf(":") + 1);
if (!StringUtils.equalsIgnoreCase(realDbType, connection.getDbType())) {
return false;
}
}
}
return true;
}
Aggregations