use of org.talend.core.model.general.Project in project tesb-studio-se by Talend.
the class ESBService method editJobName.
@Override
public void editJobName(String originaleObjectLabel, String newLabel) {
IProxyRepositoryFactory proxyRepositoryFactory = CoreRuntimePlugin.getInstance().getProxyRepositoryFactory();
Project project = ProjectManager.getInstance().getCurrentProject();
List<IRepositoryViewObject> service = null;
try {
service = proxyRepositoryFactory.getAll(project, ESBRepositoryNodeType.SERVICES, true);
} catch (PersistenceException e) {
ExceptionHandler.process(e);
}
if (service != null && service.size() > 0) {
for (IRepositoryViewObject Object : service) {
boolean flag = false;
ServiceItem item = (ServiceItem) Object.getProperty().getItem();
ServiceConnection serviceConnection = (ServiceConnection) item.getConnection();
List<ServicePort> servicePorts = serviceConnection.getServicePort();
for (ServicePort port : servicePorts) {
List<ServiceOperation> serviceOperations = port.getServiceOperation();
for (ServiceOperation operation : serviceOperations) {
String originaleItemLabel = operation.getLabel();
if (originaleItemLabel.contains("-")) {
String[] array = originaleItemLabel.split("-");
if (originaleObjectLabel.equals(array[1])) {
operation.setLabel(array[0] + "-" + newLabel);
flag = true;
}
}
}
}
if (flag) {
try {
proxyRepositoryFactory.save(item);
} catch (PersistenceException e) {
ExceptionHandler.process(e);
}
}
}
}
// RepositoryManager.refresh(ESBRepositoryNodeType.SERVICES);
}
use of org.talend.core.model.general.Project in project tdi-studio-se by Talend.
the class DemosImportTest method createTempDemoProject.
protected void createTempDemoProject(String demoName) throws CoreException, PersistenceException {
Project projectInfor = new Project();
projectInfor.setLabel(demoName);
projectInfor.setDescription("no desc");
projectInfor.setLanguage(ECodeLanguage.JAVA);
User user = PropertiesFactory.eINSTANCE.createUser();
user.setLogin("testauto@talend.com");
projectInfor.setAuthor(user);
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
String technicalLabel = Project.createTechnicalName(projectInfor.getLabel());
IProject prj = root.getProject(technicalLabel);
final IWorkspace workspace = ResourcesPlugin.getWorkspace();
try {
IProjectDescription desc = null;
if (prj.exists()) {
// always delete to avoid conflicts between 2 tests
prj.delete(true, null);
}
desc = workspace.newProjectDescription(technicalLabel);
desc.setNatureIds(new String[] { TalendNature.ID });
desc.setComment(projectInfor.getDescription());
prj.create(desc, null);
prj.open(IResource.DEPTH_INFINITE, null);
prj.setDefaultCharset("UTF-8", null);
} catch (CoreException e) {
throw new PersistenceException(e);
}
tempDemoProject = new Project();
// Fill project object
tempDemoProject.setLabel(projectInfor.getLabel());
tempDemoProject.setDescription(projectInfor.getDescription());
tempDemoProject.setLanguage(projectInfor.getLanguage());
tempDemoProject.setAuthor(projectInfor.getAuthor());
tempDemoProject.setLocal(true);
tempDemoProject.setTechnicalLabel(technicalLabel);
XmiResourceManager xmiResourceManager = new XmiResourceManager();
Resource projectResource = xmiResourceManager.createProjectResource(prj);
projectResource.getContents().add(tempDemoProject.getEmfProject());
projectResource.getContents().add(tempDemoProject.getAuthor());
xmiResourceManager.saveResource(projectResource);
}
use of org.talend.core.model.general.Project in project tdi-studio-se by Talend.
the class AddContextCommentValueMigrationTaskTest method createTempProject.
private static void createTempProject() throws CoreException, PersistenceException, LoginException {
Project projectInfor = new Project();
projectInfor.setLabel("testauto");
projectInfor.setDescription("no desc");
projectInfor.setLanguage(ECodeLanguage.JAVA);
User user = PropertiesFactory.eINSTANCE.createUser();
user.setLogin("testauto@talend.com");
projectInfor.setAuthor(user);
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
String technicalLabel = Project.createTechnicalName(projectInfor.getLabel());
IProject prj = root.getProject(technicalLabel);
final IWorkspace workspace = ResourcesPlugin.getWorkspace();
try {
IProjectDescription desc = null;
if (prj.exists()) {
// always delete to avoid conflicts between 2 tests
prj.delete(true, null);
}
desc = workspace.newProjectDescription(technicalLabel);
desc.setNatureIds(new String[] { TalendNature.ID });
desc.setComment(projectInfor.getDescription());
prj.create(desc, null);
prj.open(IResource.DEPTH_INFINITE, null);
prj.setDefaultCharset("UTF-8", null);
} catch (CoreException e) {
throw new PersistenceException(e);
}
sampleProject = new Project();
// Fill project object
sampleProject.setLabel(projectInfor.getLabel());
sampleProject.setDescription(projectInfor.getDescription());
sampleProject.setLanguage(projectInfor.getLanguage());
sampleProject.setAuthor(projectInfor.getAuthor());
sampleProject.setLocal(true);
sampleProject.setTechnicalLabel(technicalLabel);
XmiResourceManager xmiResourceManager = new XmiResourceManager();
Resource projectResource = xmiResourceManager.createProjectResource(prj);
projectResource.getContents().add(sampleProject.getEmfProject());
projectResource.getContents().add(sampleProject.getAuthor());
xmiResourceManager.saveResource(projectResource);
}
use of org.talend.core.model.general.Project in project tdi-studio-se by Talend.
the class FixUnevenItemContextParametersMigrationTaskTest method createTempProject.
private static void createTempProject() throws CoreException, PersistenceException, LoginException {
Project projectInfor = new Project();
projectInfor.setLabel("testauto");
projectInfor.setDescription("no desc");
projectInfor.setLanguage(ECodeLanguage.JAVA);
User user = PropertiesFactory.eINSTANCE.createUser();
user.setLogin("testauto@talend.com");
projectInfor.setAuthor(user);
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
String technicalLabel = Project.createTechnicalName(projectInfor.getLabel());
IProject prj = root.getProject(technicalLabel);
final IWorkspace workspace = ResourcesPlugin.getWorkspace();
try {
IProjectDescription desc = null;
if (prj.exists()) {
// always delete to avoid conflicts between 2 tests
prj.delete(true, null);
}
desc = workspace.newProjectDescription(technicalLabel);
desc.setNatureIds(new String[] { TalendNature.ID });
desc.setComment(projectInfor.getDescription());
prj.create(desc, null);
prj.open(IResource.DEPTH_INFINITE, null);
prj.setDefaultCharset("UTF-8", null);
} catch (CoreException e) {
throw new PersistenceException(e);
}
sampleProject = new Project();
// Fill project object
sampleProject.setLabel(projectInfor.getLabel());
sampleProject.setDescription(projectInfor.getDescription());
sampleProject.setLanguage(projectInfor.getLanguage());
sampleProject.setAuthor(projectInfor.getAuthor());
sampleProject.setLocal(true);
sampleProject.setTechnicalLabel(technicalLabel);
XmiResourceManager xmiResourceManager = new XmiResourceManager();
Resource projectResource = xmiResourceManager.createProjectResource(prj);
projectResource.getContents().add(sampleProject.getEmfProject());
projectResource.getContents().add(sampleProject.getAuthor());
xmiResourceManager.saveResource(projectResource);
}
use of org.talend.core.model.general.Project 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