use of org.talend.repository.model.IRepositoryNode in project tdi-studio-se by Talend.
the class GenerateSelectSQLAction method init.
//$NON-NLS-1$
@SuppressWarnings("unchecked")
public void init() {
selectedNodes.clear();
IStructuredSelection structuredSelection = (IStructuredSelection) provider.getSelection();
for (int i = 0; i < structuredSelection.toList().size(); i++) {
RepositoryNode repositoryNode = (RepositoryNode) structuredSelection.toList().get(i);
if (SQLBuilderRepositoryNodeManager.getRepositoryType(repositoryNode) == RepositoryNodeType.FOLDER) {
this.setEnabled(false);
return;
}
RepositoryNode rootNode = SQLBuilderRepositoryNodeManager.getRoot(repositoryNode);
if (!selectedNodes.isEmpty() && selectedNodes.get(0) != null && !rootNode.equals(SQLBuilderRepositoryNodeManager.getRoot((RepositoryNode) selectedNodes.get(0)))) {
setEnabled(false);
return;
}
selectedNodes.add(repositoryNode);
}
if (selectedNodes.isEmpty()) {
this.setEnabled(false);
return;
}
this.setEnabled(true);
for (IRepositoryNode node : selectedNodes) {
Object type = node.getProperties(EProperties.CONTENT_TYPE);
if (type != RepositoryNodeType.COLUMN && type != RepositoryNodeType.TABLE && type != RepositoryNodeType.DATABASE) {
setEnabled(false);
break;
}
}
}
use of org.talend.repository.model.IRepositoryNode in project tdi-studio-se by Talend.
the class GenerateSelectSQLAction method getTablePrefix.
private String getTablePrefix(IRepositoryNode node) {
RepositoryNode root = SQLBuilderRepositoryNodeManager.getRoot((RepositoryNode) node);
DatabaseConnection connection = (DatabaseConnection) ((ConnectionItem) root.getObject().getProperty().getItem()).getConnection();
if (connection.getUiSchema() != null && !connection.getUiSchema().trim().equals("")) {
//$NON-NLS-1$
return connection.getUiSchema();
} else {
//$NON-NLS-1$
return "";
}
}
use of org.talend.repository.model.IRepositoryNode in project tdi-studio-se by Talend.
the class GenerateSelectSQLAction method getPrePostfix.
/**
* Get Prepostfix.
*
* @param node the selected node
* @return PrePostfix
*/
private String getPrePostfix(IRepositoryNode node) {
RepositoryNode root = SQLBuilderRepositoryNodeManager.getRoot((RepositoryNode) node);
DatabaseConnection connection = (DatabaseConnection) ((ConnectionItem) root.getObject().getProperty().getItem()).getConnection();
if (TextUtil.isDoubleQuotesNeededDbType(connection.getDatabaseType())) {
//$NON-NLS-1$
return "\"";
}
//$NON-NLS-1$
return "";
}
use of org.talend.repository.model.IRepositoryNode in project tdi-studio-se by Talend.
the class JobVersionUtilsTest method testGetCurrentVersion.
/**
* Test method for
* {@link org.talend.repository.utils.JobVersionUtils#getCurrentVersion(org.talend.repository.model.RepositoryNode)}
* .
*
* @throws PersistenceException
*/
@Test
public void testGetCurrentVersion() throws PersistenceException {
repositoryObject = createRepositoryObject("job1");
RepositoryNode childrenNode = mock(RepositoryNode.class);
when(childrenNode.getObject()).thenReturn(repositoryObject);
when(childrenNode.getId()).thenReturn(repositoryObject.getProperty().getId());
List<IRepositoryNode> children = new ArrayList<IRepositoryNode>();
children.add(childrenNode);
RepositoryNode folderNode = mock(RepositoryNode.class);
when(folderNode.getObject()).thenReturn(folder);
when(folderNode.getId()).thenReturn(folder.getId());
when(folderNode.getChildren()).thenReturn(children);
// test,one situation
String vesion = JobVersionUtils.getCurrentVersion(folderNode);
assertEquals(vesion, "0.1");
// test,two situation
repositoryObject.getProperty().setVersion("0.2");
String vesion2 = JobVersionUtils.getCurrentVersion(folderNode);
assertEquals(vesion2, "0.2");
}
use of org.talend.repository.model.IRepositoryNode in project tesb-studio-se by Talend.
the class JavaCamelJobScriptsExportWSAction method exportAllReferenceRoutelets.
@SuppressWarnings("unchecked")
protected final void exportAllReferenceRoutelets(String routeName, ProcessItem routeProcess, Set<String> routelets) throws InvocationTargetException, InterruptedException {
for (NodeType node : (Collection<NodeType>) routeProcess.getProcess().getNode()) {
if (!EmfModelUtils.isComponentActive(node)) {
continue;
}
final ElementParameterType routeletId = EmfModelUtils.findElementParameterByName(EParameterName.PROCESS_TYPE.getName() + ':' + EParameterName.PROCESS_TYPE_PROCESS.getName(), node);
if (null != routeletId) {
final IRepositoryNode referencedRouteletNode;
try {
referencedRouteletNode = getJobRepositoryNode(routeletId.getValue(), CamelRepositoryNodeType.repositoryRouteletType);
// getRouteletRepositoryNode(routeletId);
} catch (PersistenceException e) {
throw new InvocationTargetException(e);
}
final ProcessItem routeletProcess = (ProcessItem) referencedRouteletNode.getObject().getProperty().getItem();
final String className = RouteJavaScriptOSGIForESBManager.getClassName(routeletProcess);
String idSuffix = "-" + routeName;
if (!routelets.add(className + idSuffix)) {
continue;
}
String routeletVersion = EmfModelUtils.findElementParameterByName(EParameterName.PROCESS_TYPE.getName() + ':' + EParameterName.PROCESS_TYPE_VERSION.getName(), node).getValue();
if (RelationshipItemBuilder.LATEST_VERSION.equals(routeletVersion)) {
routeletVersion = referencedRouteletNode.getObject().getVersion();
}
final File routeletFile;
try {
routeletFile = File.createTempFile("routelet", FileConstants.JAR_FILE_SUFFIX, //$NON-NLS-1$
new File(getTempDir()));
} catch (IOException e) {
throw new InvocationTargetException(e);
}
String routeletName = referencedRouteletNode.getObject().getLabel();
String routeletBundleName = routeName + "_" + routeletName;
String routeletBundleSymbolicName = routeletBundleName;
Project project = ProjectManager.getInstance().getCurrentProject();
if (project != null) {
String projectName = project.getLabel();
if (projectName != null && projectName.length() > 0) {
routeletBundleSymbolicName = projectName.toLowerCase() + '.' + routeletBundleSymbolicName;
}
}
BundleModel routeletModel = new BundleModel(getGroupId(), routeletBundleName, getArtifactVersion(), routeletFile);
if (featuresModel.addBundle(routeletModel)) {
exportRouteBundle(referencedRouteletNode, routeletFile, routeletVersion, routeletBundleName, routeletBundleSymbolicName, bundleVersion, idSuffix, null, EmfModelUtils.findElementParameterByName(EParameterName.PROCESS_TYPE.getName() + ':' + EParameterName.PROCESS_TYPE_CONTEXT.getName(), node).getValue());
CamelFeatureUtil.addFeatureAndBundles(routeletProcess, featuresModel);
exportAllReferenceRoutelets(routeName, routeletProcess, routelets);
}
}
}
}
Aggregations