use of org.talend.core.model.repository.Folder in project tdq-studio-se by Talend.
the class RulesParserFolderRepNode method getChildrenForProject.
/*
* (non-Javadoc)
*
* @see org.talend.dq.nodes.DQFolderRepNode#getChildrenForProject(boolean, org.talend.core.model.general.Project)
*/
@Override
public void getChildrenForProject(boolean withDeleted, Project project) throws PersistenceException {
RootContainer<String, IRepositoryViewObject> tdqViewObjects = super.getTdqViewObjects(project, this);
// sub folders
for (Container<String, IRepositoryViewObject> container : tdqViewObjects.getSubContainer()) {
Folder folder = new Folder((Property) container.getProperty(), ERepositoryObjectType.TDQ_RULES_PARSER);
if (isIgnoreFolder(withDeleted, project, folder)) {
continue;
}
RulesParserSubFolderRepNode childNodeFolder = new RulesParserSubFolderRepNode(folder, this, ENodeType.SIMPLE_FOLDER, project);
childNodeFolder.setProperties(EProperties.CONTENT_TYPE, ERepositoryObjectType.TDQ_RULES_PARSER);
childNodeFolder.setProperties(EProperties.LABEL, ERepositoryObjectType.TDQ_RULES_PARSER);
super.getChildren().add(childNodeFolder);
}
// rule files
for (IRepositoryViewObject viewObject : tdqViewObjects.getMembers()) {
if (!withDeleted && viewObject.isDeleted()) {
continue;
}
RuleRepNode repNode = new RuleRepNode(viewObject, this, ENodeType.REPOSITORY_ELEMENT, project);
repNode.setProperties(EProperties.CONTENT_TYPE, ERepositoryObjectType.TDQ_RULES_PARSER);
repNode.setProperties(EProperties.LABEL, ERepositoryObjectType.TDQ_RULES_PARSER);
viewObject.setRepositoryNode(repNode);
super.getChildren().add(repNode);
}
}
use of org.talend.core.model.repository.Folder in project tdq-studio-se by Talend.
the class RulesSQLFolderRepNode method getChildrenForProject.
/*
* (non-Javadoc)
*
* @see org.talend.dq.nodes.DQFolderRepNode#getChildrenForProject(boolean, org.talend.core.model.general.Project)
*/
@Override
public void getChildrenForProject(boolean withDeleted, Project project) throws PersistenceException {
RootContainer<String, IRepositoryViewObject> tdqViewObjects = super.getTdqViewObjects(project, this);
// sub folders
for (Container<String, IRepositoryViewObject> container : tdqViewObjects.getSubContainer()) {
Folder folder = new Folder((Property) container.getProperty(), ERepositoryObjectType.TDQ_RULES_SQL);
if (isIgnoreFolder(withDeleted, project, folder)) {
continue;
}
RulesSQLSubFolderRepNode childNodeFolder = new RulesSQLSubFolderRepNode(folder, this, ENodeType.SIMPLE_FOLDER, project);
childNodeFolder.setProperties(EProperties.CONTENT_TYPE, ERepositoryObjectType.TDQ_RULES_SQL);
childNodeFolder.setProperties(EProperties.LABEL, ERepositoryObjectType.TDQ_RULES_SQL);
super.getChildren().add(childNodeFolder);
}
// rule files
for (IRepositoryViewObject viewObject : tdqViewObjects.getMembers()) {
if (!withDeleted && viewObject.isDeleted()) {
continue;
}
RuleRepNode repNode = new RuleRepNode(viewObject, this, ENodeType.REPOSITORY_ELEMENT, project);
repNode.setProperties(EProperties.CONTENT_TYPE, ERepositoryObjectType.TDQ_RULES_SQL);
repNode.setProperties(EProperties.LABEL, ERepositoryObjectType.TDQ_RULES_SQL);
viewObject.setRepositoryNode(repNode);
// ADD msjian TDQ-4914: when the node is SystemDemoRule from ref project, we don't show it
if (ProxyRepositoryManager.getInstance().isMergeRefProject()) {
if (!project.isMainProject()) {
ModelElement meNode = RepositoryNodeHelper.getResourceModelElement(repNode);
if (meNode != null) {
String uuid = RepositoryNodeHelper.getUUID(meNode);
if (RepositoryNodeHelper.isSystemDemoRule(uuid)) {
continue;
}
}
}
}
// TDQ-4914~
super.getChildren().add(repNode);
}
}
use of org.talend.core.model.repository.Folder in project tdq-studio-se by Talend.
the class SourceFileFolderRepNode method getChildrenForProject.
/*
* (non-Javadoc)
*
* @see org.talend.dq.nodes.DQFolderRepNode#getChildrenForProject(boolean, org.talend.core.model.general.Project)
*/
@Override
public void getChildrenForProject(boolean withDeleted, org.talend.core.model.general.Project project) throws PersistenceException {
RootContainer<String, IRepositoryViewObject> sourceFiles = super.getTdqViewObjects(project, this);
// sub folders
for (Container<String, IRepositoryViewObject> container : sourceFiles.getSubContainer()) {
Folder folder = new Folder((Property) container.getProperty(), ERepositoryObjectType.TDQ_SOURCE_FILE_ELEMENT);
if (isIgnoreFolder(withDeleted, project, folder)) {
continue;
}
SourceFileSubFolderNode childNodeFolder = new SourceFileSubFolderNode(folder, this, ENodeType.SIMPLE_FOLDER, project);
childNodeFolder.setProperties(EProperties.CONTENT_TYPE, ERepositoryObjectType.TDQ_SOURCE_FILE_ELEMENT);
childNodeFolder.setProperties(EProperties.LABEL, ERepositoryObjectType.TDQ_SOURCE_FILE_ELEMENT);
super.getChildren().add(childNodeFolder);
}
// source files
for (IRepositoryViewObject viewObject : sourceFiles.getMembers()) {
if (!withDeleted && viewObject.isDeleted()) {
continue;
}
// ADD msjian TDQ-4914: when the node is SystemDemoRule from ref project, we don't show it
if (ProxyRepositoryManager.getInstance().isMergeRefProject()) {
if (!project.isMainProject()) {
if (RepositoryNodeHelper.isSystemDemoSourceFile(viewObject.getLabel())) {
continue;
}
}
}
// TDQ-4914~
SourceFileRepNode repNode = new SourceFileRepNode(viewObject, this, ENodeType.REPOSITORY_ELEMENT, project);
repNode.setProperties(EProperties.CONTENT_TYPE, ERepositoryObjectType.TDQ_SOURCE_FILE_ELEMENT);
repNode.setProperties(EProperties.LABEL, ERepositoryObjectType.TDQ_SOURCE_FILE_ELEMENT);
viewObject.setRepositoryNode(repNode);
super.getChildren().add(repNode);
}
}
use of org.talend.core.model.repository.Folder in project tdq-studio-se by Talend.
the class UserDefIndicatorFolderRepNode method getChildrenForProject.
/*
* (non-Javadoc)
*
* @see org.talend.dq.nodes.DQFolderRepNode#getChildrenForProject(boolean, org.talend.core.model.general.Project)
*/
@Override
public void getChildrenForProject(boolean withDeleted, Project project) throws PersistenceException {
RootContainer<String, IRepositoryViewObject> tdqViewObjects = super.getTdqViewObjects(project, this);
// sub folders
for (Container<String, IRepositoryViewObject> container : tdqViewObjects.getSubContainer()) {
Folder folder = new Folder((Property) container.getProperty(), ERepositoryObjectType.TDQ_USERDEFINE_INDICATORS);
if (isIgnoreFolder(withDeleted, project, folder) || "lib".equals(folder.getLabel())) {
// $NON-NLS-1$
continue;
}
UserDefIndicatorSubFolderRepNode childNodeFolder = new UserDefIndicatorSubFolderRepNode(folder, this, ENodeType.SIMPLE_FOLDER, project);
childNodeFolder.setProperties(EProperties.CONTENT_TYPE, ERepositoryObjectType.TDQ_USERDEFINE_INDICATORS);
childNodeFolder.setProperties(EProperties.LABEL, ERepositoryObjectType.TDQ_USERDEFINE_INDICATORS);
super.getChildren().add(childNodeFolder);
}
// rule files
for (IRepositoryViewObject viewObject : tdqViewObjects.getMembers()) {
if (!withDeleted && viewObject.isDeleted()) {
continue;
}
SysIndicatorDefinitionRepNode repNode = new SysIndicatorDefinitionRepNode(viewObject, this, ENodeType.REPOSITORY_ELEMENT, project);
repNode.setProperties(EProperties.CONTENT_TYPE, ERepositoryObjectType.TDQ_USERDEFINE_INDICATORS);
repNode.setProperties(EProperties.LABEL, ERepositoryObjectType.TDQ_USERDEFINE_INDICATORS);
viewObject.setRepositoryNode(repNode);
super.getChildren().add(repNode);
}
}
use of org.talend.core.model.repository.Folder in project tdq-studio-se by Talend.
the class DQStructureManager method copyFilesToFolder.
/**
* DOC klliu Comment method "copyFilesToFolder".
*
* @param plugin
* @param srcPath
* @param recurse
* @param desFolder
* @param suffix
* @param type
* @throws IOException
* @throws CoreException
*/
public void copyFilesToFolder(Plugin plugin, String srcPath, boolean recurse, Folder desFolder, String suffix, ERepositoryObjectType type) throws IOException, CoreException {
if (plugin == null) {
return;
}
IProject project = ResourceManager.getRootProject();
Enumeration<?> paths = null;
paths = plugin.getBundle().getEntryPaths(srcPath);
if (paths == null) {
return;
}
while (paths.hasMoreElements()) {
String nextElement = (String) paths.nextElement();
// $NON-NLS-1$
String currentPath = "/" + nextElement;
URL resourceURL = plugin.getBundle().getEntry(currentPath);
URL fileURL = null;
File file = null;
try {
fileURL = FileLocator.toFileURL(resourceURL);
file = new File(fileURL.getFile());
if (file.isDirectory() && recurse) {
if (file.getName().startsWith(".")) {
// $NON-NLS-1$
continue;
}
Folder sourcefolder = null;
IFolder targetfolder = WorkbenchUtils.folder2IFolder(desFolder);
if (!targetfolder.getFolder(file.getName()).exists()) {
sourcefolder = ProxyRepositoryFactory.getInstance().createFolder(type, Path.EMPTY, file.getName());
} else {
FolderItem folderItem = ProxyRepositoryFactory.getInstance().getFolderItem(ProjectManager.getInstance().getCurrentProject(), type, new Path(file.getName()));
if (folderItem == null) {
sourcefolder = ProxyRepositoryFactory.getInstance().createFolder(type, Path.EMPTY, file.getName());
// $NON-NLS-1$
String subSourceFolder = type.getFolder().concat("/").concat(file.getName());
sourcefolder.getProperty().getItem().getState().setPath(subSourceFolder);
} else {
// $NON-NLS-1$
String subSourceFolder = type.getFolder().concat("/").concat(file.getName());
sourcefolder = new Folder(folderItem.getProperty(), type);
sourcefolder.getProperty().getItem().getState().setPath(subSourceFolder);
}
}
copyFilesToFolder(plugin, currentPath, recurse, sourcefolder, suffix, type);
continue;
}
if (suffix != null && !file.getName().endsWith(suffix)) {
continue;
}
String fileName = new Path(fileURL.getPath()).lastSegment();
InputStream openStream = fileURL.openStream();
String folderName = null;
if (type.equals(ERepositoryObjectType.TDQ_PATTERN_ELEMENT)) {
folderName = ERepositoryObjectType.getFolderName(type);
}
if (type.equals(ERepositoryObjectType.TDQ_RULES_SQL) || type.equals(ERepositoryObjectType.TDQ_RULES_PARSER)) {
folderName = ERepositoryObjectType.getFolderName(type);
} else if (type.equals(ERepositoryObjectType.TDQ_SOURCE_FILE_ELEMENT)) {
folderName = ERepositoryObjectType.getFolderName(type);
} else {
// $NON-NLS-1$
folderName = ERepositoryObjectType.getFolderName(type) + "/" + desFolder.getLabel();
}
if (folderName.equals("date")) {
// $NON-NLS-1$
continue;
}
IFolder folder = project.getFolder(folderName);
if (type.equals(ERepositoryObjectType.TDQ_SOURCE_FILE_ELEMENT)) {
String name = file.getName();
// $NON-NLS-1$
int indexOf = name.indexOf(".");
String label = name.substring(0, indexOf);
String extendtion = name.substring(indexOf + 1);
createSourceFileItem(file, Path.EMPTY, label, extendtion);
} else {
copyFileToFolder(openStream, fileName, folder);
}
openStream.close();
} catch (IOException e) {
log.error(e, e);
} catch (PersistenceException e) {
log.error(e, e);
}
}
}
Aggregations