use of org.talend.core.model.properties.FolderItem in project tdi-studio-se by Talend.
the class RepositoryTypeProcessor method selectRepositoryNode.
@Override
protected boolean selectRepositoryNode(Viewer viewer, RepositoryNode parentNode, RepositoryNode node) {
final String repositoryType = getRepositoryType();
if (node == null) {
return false;
}
if (node.getContentType() == ERepositoryObjectType.REFERENCED_PROJECTS) {
return true;
}
// for sub folders
if (node.getType() == ENodeType.STABLE_SYSTEM_FOLDER) {
return false;
}
// for Db Connections
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 ConnectionItem) {
ConnectionItem connectionItem = (ConnectionItem) item;
Connection connection = connectionItem.getConnection();
// tAdvancedFileOutputXML
if (repositoryType != null && repositoryType.equals(ERepositoryCategoryType.XMLOUTPUT.getName())) {
if (connection instanceof XmlFileConnection && ((XmlFileConnection) connection).isInputModel()) {
return false;
}
}
if (repositoryType.startsWith(ERepositoryCategoryType.DATABASE.getName())) {
//$NON-NLS-1$
String currentDbType = (String) RepositoryToComponentProperty.getValue(connection, "TYPE", null);
if (repositoryType.contains(":")) {
// database //$NON-NLS-1$
// is
// specified
// //$NON-NLS-1$
//$NON-NLS-1$
String neededDbType = repositoryType.substring(repositoryType.indexOf(":") + 1);
if (hidenTypeSelection) {
return true;
}
if (!MetadataTalendType.sameDBProductType(neededDbType, currentDbType)) {
return false;
}
}
}
}
if (repositoryType.startsWith(ERepositoryCategoryType.HEADERFOOTER.getName())) {
if (item instanceof HeaderFooterConnectionItem) {
HeaderFooterConnectionItem connectionItem = (HeaderFooterConnectionItem) item;
HeaderFooterConnection connection = (HeaderFooterConnection) connectionItem.getConnection();
boolean isHeader = connection.isIsHeader();
if ((isHeader && isHeaderButton) || (!isHeader && !isHeaderButton)) {
return true;
} else {
return false;
}
}
}
return true;
}
use of org.talend.core.model.properties.FolderItem in project tdi-studio-se by Talend.
the class ValidationRuleTypeProcessor method selectRepositoryNode.
@Override
protected boolean selectRepositoryNode(Viewer viewer, RepositoryNode parentNode, RepositoryNode node) {
if (node.getContentType() == ERepositoryObjectType.REFERENCED_PROJECTS) {
return true;
}
ProjectManager pManager = ProjectManager.getInstance();
if (!pManager.isInCurrentMainProject(node)) {
if (node.getType() == ENodeType.STABLE_SYSTEM_FOLDER) {
return false;
}
if (node.getType() == ENodeType.SYSTEM_FOLDER) {
return true;
}
}
if (node.getType() == ENodeType.SYSTEM_FOLDER) {
return true;
}
if (node.getObject() == null || node.getObject().getProperty().getItem() == null) {
return false;
}
if (node.getObject() instanceof MetadataTable) {
return false;
}
Item item = node.getObject().getProperty().getItem();
if (item instanceof FolderItem) {
return true;
}
if (node.getObjectType() == getType()) {
return true;
}
return false;
}
use of org.talend.core.model.properties.FolderItem in project tdi-studio-se by Talend.
the class TosTokenCollector method collectJobDetails.
/**
* DOC nrousseau Comment method "collectJobDetails".
*
* @param all
* @param jobDetails
* @throws JSONException
*/
private void collectJobDetails(List<IRepositoryViewObject> allRvo, JSONObject jobDetails) throws JSONException {
IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
IWorkbenchWindow ww = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
IEditorReference[] reference = new IEditorReference[0];
if (ww != null) {
IWorkbenchPage page = ww.getActivePage();
reference = page.getEditorReferences();
}
List<IProcess2> processes = RepositoryPlugin.getDefault().getDesignerCoreService().getOpenedProcess(reference);
Set<String> idsOpened = new HashSet<String>();
for (IProcess2 process : processes) {
idsOpened.add(process.getId());
}
JSONArray components = new JSONArray();
int contextVarsNum = 0;
int nbComponentsUsed = 0;
for (IRepositoryViewObject rvo : allRvo) {
Item item = rvo.getProperty().getItem();
if (item instanceof ProcessItem) {
ProcessType processType = ((ProcessItem) item).getProcess();
for (NodeType node : (List<NodeType>) processType.getNode()) {
JSONObject component_names = null;
String componentName = node.getComponentName();
int nbComp = 0;
for (int i = 0; i < components.length(); i++) {
JSONObject temp = components.getJSONObject(i);
if (temp.get("component_name").equals(componentName)) {
//$NON-NLS-1$
//$NON-NLS-1$
nbComp = temp.getInt("count");
component_names = temp;
break;
}
}
if (component_names == null) {
component_names = new JSONObject();
components.put(component_names);
}
component_names.put("component_name", componentName);
component_names.put("count", nbComp + 1);
nbComponentsUsed++;
}
// context variable per job
EList contexts = processType.getContext();
if (contexts.size() > 0) {
ContextType contextType = (ContextType) contexts.get(0);
contextVarsNum += contextType.getContextParameter().size();
}
}
if (factory.getStatus(item) != ERepositoryStatus.LOCK_BY_USER && !idsOpened.contains(item.getProperty().getId())) {
// job is not locked and not opened by editor, so we can unload.
if (item.getParent() instanceof FolderItem) {
((FolderItem) item.getParent()).getChildren().remove(item);
item.setParent(null);
}
item.eResource().unload();
}
}
jobDetails.put("components", components);
jobDetails.put("nb.contextVars", contextVarsNum);
jobDetails.put("nb.components", nbComponentsUsed);
}
Aggregations