use of org.talend.core.repository.model.ProxyRepositoryFactory in project tdi-studio-se by Talend.
the class ChangeReturnTypeOfServerAliveResult method convertItem.
private boolean convertItem(Item item, ProcessType processType) throws PersistenceException {
ProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
boolean modified = false;
ECodeLanguage language = getProject().getLanguage();
EList node = processType.getNode();
EList connections = processType.getConnection();
for (Object n : node) {
NodeType type = (NodeType) n;
EList elementParameterList = type.getElementParameter();
for (Object elem : elementParameterList) {
ElementParameterType elemType = (ElementParameterType) elem;
if (language.equals(ECodeLanguage.JAVA)) {
if (elemType.getValue() != null && elemType.getValue().contains("tServerAlive")) {
//$NON-NLS-1$
Matcher match = PATTERN_GET.matcher(elemType.getValue());
String replace = getReplaceValue(match);
if (replace != null && replace.length() > 0) {
elemType.setValue(replace);
modified = true;
}
}
}
// for table
EList elemValue = elemType.getElementValue();
for (Object elemV : elemValue) {
ElementValueType elemVal = (ElementValueType) elemV;
if (language.equals(ECodeLanguage.JAVA)) {
if (elemVal.getValue() != null && elemVal.getValue().contains("tServerAlive")) {
//$NON-NLS-1$
Matcher match = PATTERN_GET.matcher(elemVal.getValue());
String replace = getReplaceValue(match);
if (replace != null && replace.length() > 0) {
elemVal.setValue(replace);
modified = true;
}
}
}
}
}
}
// the links
for (Object n : connections) {
ConnectionType type = (ConnectionType) n;
EList elementParameterList = type.getElementParameter();
for (Object elem : elementParameterList) {
ElementParameterType elemType = (ElementParameterType) elem;
if (language.equals(ECodeLanguage.JAVA)) {
if (elemType.getValue() != null && elemType.getValue().contains("tServerAlive")) {
//$NON-NLS-1$
Matcher match = PATTERN_GET.matcher(elemType.getValue());
String replace = getReplaceValue(match);
if (replace != null && replace.length() > 0) {
elemType.setValue(replace);
modified = true;
}
}
}
}
}
if (modified) {
factory.save(item, true);
}
return modified;
}
use of org.talend.core.repository.model.ProxyRepositoryFactory in project tdi-studio-se by Talend.
the class ChangeUniqRowLinksMigrationTask method replaceConnections.
public boolean replaceConnections(Item item) throws PersistenceException {
ProcessType processType = getProcessType(item);
if (processType == null) {
return false;
}
ProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
boolean replaceDone = false;
boolean modified = false;
for (Object o : processType.getConnection()) {
ConnectionType currentConnection = (ConnectionType) o;
// output of the tUniqRow, set the connector name to UNIQUE.
if (((currentConnection.getConnectorName() == null) || STANDARD_CONNECTOR_NAME.equals(currentConnection.getConnectorName())) && sourceComeFromtUniqRow(processType, currentConnection.getSource())) {
currentConnection.setConnectorName(NEW_CONNECTOR_NAME);
modified = true;
}
}
if (modified) {
factory.save(item, true);
replaceDone = true;
}
return replaceDone;
}
use of org.talend.core.repository.model.ProxyRepositoryFactory in project tdi-studio-se by Talend.
the class ChangeJobscriptContentValueMigrationTask method execute.
/*
* (non-Javadoc)
*
* @see org.talend.core.model.migration.AbstractItemMigrationTask#execute(org.talend.core.model.properties.Item)
*/
@Override
public ExecutionResult execute(Item item) {
ProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
if (item instanceof JobScriptItem) {
byte[] bytes = ((JobScriptItem) item).getContent().getInnerContent();
String message = new String(bytes);
message = message.replaceAll("PATTREN", "PATTERN");
try {
ByteArray byteArray = PropertiesFactory.eINSTANCE.createByteArray();
byteArray.setInnerContent(message.getBytes());
((JobScriptItem) item).setContent(byteArray);
factory.save(item, true);
} catch (PersistenceException e) {
ExceptionHandler.process(e);
return ExecutionResult.FAILURE;
}
return ExecutionResult.SUCCESS_NO_ALERT;
}
return ExecutionResult.NOTHING_TO_DO;
}
use of org.talend.core.repository.model.ProxyRepositoryFactory in project tdi-studio-se by Talend.
the class AbstractRoutineAction method openRoutineEditor.
/**
* DOC smallet Comment method "openRoutineEditor".
*
* @param routineItem
* @throws SystemException
* @throws PartInitException
*/
protected IEditorPart openRoutineEditor(RoutineItem routineItem, boolean readOnly) throws SystemException, PartInitException {
if (routineItem == null) {
return null;
}
ICodeGeneratorService service = (ICodeGeneratorService) GlobalServiceRegister.getDefault().getService(ICodeGeneratorService.class);
ECodeLanguage lang = ((RepositoryContext) CorePlugin.getContext().getProperty(Context.REPOSITORY_CONTEXT_KEY)).getProject().getLanguage();
ITalendSynchronizer routineSynchronizer;
switch(lang) {
case JAVA:
routineSynchronizer = service.createJavaRoutineSynchronizer();
break;
case PERL:
routineSynchronizer = service.createPerlRoutineSynchronizer();
break;
default:
//$NON-NLS-1$
throw new UnsupportedOperationException(Messages.getString("AbstractRoutineAction.unknowLanguage") + lang);
}
// check if the related editor is open.
IWorkbenchPage page = getActivePage();
IEditorReference[] editorParts = page.getEditorReferences();
//$NON-NLS-1$ //$NON-NLS-2$
String talendEditorID = "org.talend.designer.core.ui.editor.StandAloneTalend" + lang.getCaseName() + "Editor";
boolean found = false;
IEditorPart talendEditor = null;
for (IEditorReference reference : editorParts) {
IEditorPart editor = reference.getEditor(false);
if (talendEditorID.equals(editor.getSite().getId())) {
// TextEditor talendEditor = (TextEditor) editor;
RepositoryEditorInput editorInput = (RepositoryEditorInput) editor.getEditorInput();
if (editorInput.getItem().equals(routineItem)) {
page.bringToTop(editor);
found = true;
talendEditor = editor;
break;
}
}
}
if (!found) {
IFile file = null;
ProjectManager projectManager = ProjectManager.getInstance();
boolean flag = projectManager.isInCurrentMainProject(routineItem);
if (!flag) {
// is ref project
file = routineSynchronizer.getRoutinesFile(routineItem);
} else {
// need open from item file with multiple version
boolean needForceRefresh = false;
if (!ProxyRepositoryFactory.getInstance().isLocalConnectionProvider()) {
// in case only routine.item file modified, better refresh every time, especially for git mode
needForceRefresh = true;
}
routineSynchronizer.syncRoutine(routineItem, true, needForceRefresh);
ProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
String lastVersion = factory.getLastVersion(routineItem.getProperty().getId()).getVersion();
String curVersion = routineItem.getProperty().getVersion();
if (curVersion != null && curVersion.equals(lastVersion)) {
file = routineSynchronizer.getFile(routineItem);
} else {
file = routineSynchronizer.getRoutinesFile(routineItem);
}
}
if (file == null) {
return null;
}
RepositoryEditorInput input = new RoutineEditorInput(file, routineItem);
input.setReadOnly(readOnly);
talendEditor = page.openEditor(input, talendEditorID);
}
return talendEditor;
}
use of org.talend.core.repository.model.ProxyRepositoryFactory in project tdi-studio-se by Talend.
the class SelectDeleteProjectDialog method getProjectItem.
private List<Project> getProjectItem() {
if (login) {
List<Project> projectList = new ArrayList<Project>();
if (projectItemList != null && !projectItemList.isEmpty()) {
Iterator<Object> iter = projectItemList.iterator();
while (iter.hasNext()) {
Object project = iter.next();
if (project instanceof Project) {
projectList.add((Project) project);
}
}
}
return projectList;
}
if (!projects.isEmpty()) {
return projects;
}
ProxyRepositoryFactory repositoryFactory = ProxyRepositoryFactory.getInstance();
Project[] projects = null;
try {
projects = repositoryFactory.readProject();
} catch (PersistenceException e) {
CommonExceptionHandler.process(e);
} catch (BusinessException e) {
CommonExceptionHandler.process(e);
}
for (Project p : projects) {
this.projects.add(p);
}
if (projects != null) {
return this.projects;
}
return Collections.emptyList();
}
Aggregations