use of org.talend.core.model.properties.FolderItem in project tdq-studio-se by Talend.
the class RepositoryNodeHelper method getRootNode.
public static RepositoryNode getRootNode(ERepositoryObjectType nodeType, boolean open, org.talend.core.model.general.Project project) {
DQRepositoryNode node = null;
FolderItem folderItem = ProxyRepositoryFactory.getInstance().getFolderItem(project, nodeType, Path.EMPTY);
CommonViewer commonViewer = getDQCommonViewer(open);
if (commonViewer != null) {
TreeItem[] items = commonViewer.getTree().getItems();
for (TreeItem item : items) {
node = (DQRepositoryNode) item.getData();
DQRepositoryNode matchNode = getMatchNode(project, node, folderItem);
if (matchNode != null) {
return matchNode;
}
}
// $NON-NLS-1$
log.error(Messages.getString("RepositoryNodeHelper.canNotFindRootNode") + nodeType.getLabel());
}
return node;
}
use of org.talend.core.model.properties.FolderItem in project tdq-studio-se by Talend.
the class RepositoryNodeHelper method restoreCorruptedConn.
/**
* restore Connection which is corrupted.
*
* @param property
*/
public static void restoreCorruptedConn(Property property) {
if (!(property.getItem() instanceof ConnectionItem)) {
return;
}
ConnectionItem connItem = (ConnectionItem) property.getItem();
ERepositoryObjectType itemType = ERepositoryObjectType.getItemType(connItem);
// connection
Connection createConnection = RepositoryObjectTypeHelper.CreateConnectionFromType(itemType);
if (!(ConnectionImpl.class == connItem.getConnection().getClass())) {
return;
}
connItem.setConnection(createConnection);
try {
FolderItem folderItem = ProxyRepositoryFactory.getInstance().getFolderItem(ProjectManager.getInstance().getCurrentProject(), itemType, Path.EMPTY);
Object refreshFolderItem = refreshFolderItem(folderItem, property);
if (refreshFolderItem == null) {
// $NON-NLS-1$
log.debug("Can not replace the connection from it's FolderItem : " + connItem.eResource().getURI());
}
ProxyRepositoryFactory.getInstance().save(connItem);
EMFSharedResources.getInstance().reloadResource(connItem.eResource().getURI());
} catch (PersistenceException e) {
log.error(e, e);
}
}
use of org.talend.core.model.properties.FolderItem in project tdq-studio-se by Talend.
the class UnitTestBuildHelper method buildRepositoryViewObjectSystemFolder.
/**
* create a RepositoryViewObject which is a system folder.
*
* @param tProject
* @param author
* @param type
* @return
*/
public static IRepositoryViewObject buildRepositoryViewObjectSystemFolder(org.talend.core.model.properties.Project emfProject, User author, ERepositoryObjectType type) {
ItemState itemState = PropertiesFactory.eINSTANCE.createItemState();
FolderItem folderItem = PropertiesFactory.eINSTANCE.createFolderItem();
Property property = PropertiesFactory.eINSTANCE.createProperty();
itemState.setItemRelated(folderItem);
folderItem.setState(itemState);
folderItem.setParent(emfProject);
folderItem.setType(FolderType.STABLE_SYSTEM_FOLDER_LITERAL);
folderItem.setProperty(property);
property.setAuthor(author);
property.setCreationDate(new Date());
property.setId(StringUtilities.getRandomString(26));
property.setItem(folderItem);
property.setLabel(type.getFolder());
property.setMaxInformationLevel(InformationLevel.DEBUG_LITERAL);
// $NON-NLS-1$
property.setOldStatusCode("");
// $NON-NLS-1$
property.setVersion("0.1");
return new Folder(property, type);
}
use of org.talend.core.model.properties.FolderItem in project tdq-studio-se by Talend.
the class WorkbenchUtils method getFolderContentType.
/**
* Add qiongli: get the detail ERepositoryObjectType of folderItem.
*
* @param folderItem
* @return
*/
public static ERepositoryObjectType getFolderContentType(FolderItem folderItem) {
if (!folderItem.getType().equals(FolderType.SYSTEM_FOLDER_LITERAL)) {
if (!(folderItem.getParent() instanceof FolderItem)) {
// appears only for a folder for expression builder !
return null;
}
return getFolderContentType((FolderItem) folderItem.getParent());
}
for (ERepositoryObjectType objectType : (ERepositoryObjectType[]) ERepositoryObjectType.values()) {
String folderName;
try {
folderName = ERepositoryObjectType.getFolderName(objectType);
} catch (Exception e) {
// just catch exception to avoid the types who don't have folders
continue;
}
if (folderName.contains("/")) {
// $NON-NLS-1$
// $NON-NLS-1$
String[] folders = folderName.split("/");
FolderItem currentFolderItem = folderItem;
boolean found = true;
for (int i = folders.length - 1; i >= 0; i--) {
if (!currentFolderItem.getProperty().getLabel().equals(folders[i])) {
found = false;
break;
}
if (i > 0) {
if (!(currentFolderItem.getParent() instanceof FolderItem)) {
found = false;
break;
}
currentFolderItem = (FolderItem) currentFolderItem.getParent();
}
}
if (found) {
return objectType;
}
} else {
if (folderName.equals(folderItem.getProperty().getLabel())) {
return objectType;
}
}
}
if (folderItem.getParent() instanceof FolderItem) {
return getFolderContentType((FolderItem) folderItem.getParent());
}
return null;
}
use of org.talend.core.model.properties.FolderItem in project tdq-studio-se by Talend.
the class DQRespositoryView method initAllFolders.
/**
* DOC qiongli Comment method "initAllFolder".
*/
private void initAllFolders() {
Project newProject = ProjectManager.getInstance().getCurrentProject();
List<FolderItem> folderItems = ProjectManager.getInstance().getFolders(newProject.getEmfProject());
try {
for (FolderItem folder : new ArrayList<FolderItem>(folderItems)) {
if (WorkbenchUtils.isTDQOrMetadataRootFolder(folder, ProjectManager.getInstance().getCurrentProject().getEmfProject())) {
ERepositoryObjectType type = WorkbenchUtils.getFolderContentType(folder);
// MOD by zshen to avoid NullPointerException.
if (type != null) {
ProxyRepositoryFactory.getInstance().getAll(type, true);
}
}
}
} catch (PersistenceException e) {
log.error(e, e);
}
}
Aggregations