Compare commits

...

3 Commits

Author SHA1 Message Date
cmeng-talend
74d8de2ee9 TDI-31531 fix bug: Bug with txmlmap used in a joblet
https://jira.talendforge.org/browse/TDI-31531

Checked with bugfixer, forgot to commit on this branch, commit it
2015-05-20 10:19:57 +08:00
xhkong
5ce4b4f7d0 TPS-909 [5.4.2] Sometime Routines don't saves (TDI-32401)
https://jira.talendforge.org/browse/TPS-909
2015-05-11 17:13:17 +08:00
xhkong
c3bf8b1d34 TPS-909 [5.4.2] Sometime Routines don't saves (TDI-32401)
https://jira.talendforge.org/browse/TPS-909
2015-05-06 18:36:22 +08:00
3 changed files with 89 additions and 14 deletions

View File

@@ -842,4 +842,7 @@ PaserRuleSelectionDialog.RULE_VALUE=Rule Value
PasswordController.NewPassword=Enter a new password
PasswordController.NoteConvention=Note: Follow the usual Java convention which requires text to be surrounded by double quotes.
NodeSelectedDialog.title=Select node
NodeSelectedDialog.msg=Please select a node.
NodeSelectedDialog.msg=Please select a node.
SaveRoutineContentError.ErrorTitile=Error
SaveRoutineContentError.ErrorContent=Save Routine Failed!

View File

@@ -16,9 +16,15 @@ import java.lang.reflect.InvocationTargetException;
import java.util.List;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.IWorkspaceRunnable;
import org.eclipse.core.resources.IncrementalProjectBuilder;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.ISchedulingRule;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.impl.AdapterImpl;
import org.eclipse.emf.common.util.EList;
@@ -50,21 +56,26 @@ import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.part.FileEditorInput;
import org.talend.commons.exception.LoginException;
import org.talend.commons.exception.PersistenceException;
import org.talend.commons.ui.gmf.util.DisplayUtils;
import org.talend.commons.ui.runtime.exception.ExceptionHandler;
import org.talend.commons.ui.runtime.exception.ExceptionMessageDialog;
import org.talend.commons.ui.runtime.image.ImageProvider;
import org.talend.commons.utils.VersionUtils;
import org.talend.core.CorePlugin;
import org.talend.core.GlobalServiceRegister;
import org.talend.core.model.general.Project;
import org.talend.core.model.properties.ByteArray;
import org.talend.core.model.properties.FileItem;
import org.talend.core.model.properties.Information;
import org.talend.core.model.properties.Item;
import org.talend.core.model.properties.Property;
import org.talend.core.model.properties.RoutineItem;
import org.talend.core.model.repository.ERepositoryObjectType;
import org.talend.core.model.repository.Folder;
import org.talend.core.model.repository.IRepositoryViewObject;
import org.talend.core.model.utils.RepositoryManagerHelper;
import org.talend.core.repository.model.ProxyRepositoryFactory;
import org.talend.core.runtime.CoreRuntimePlugin;
import org.talend.core.ui.ILastVersionChecker;
import org.talend.core.ui.IUIRefresher;
import org.talend.core.ui.branding.IBrandingService;
@@ -74,6 +85,7 @@ import org.talend.designer.core.ui.action.SaveAsRoutineAction;
import org.talend.designer.core.ui.action.SaveAsSQLPatternAction;
import org.talend.designer.core.ui.views.problems.Problems;
import org.talend.designer.core.utils.DesignerColorUtils;
import org.talend.repository.ProjectManager;
import org.talend.repository.RepositoryWorkUnit;
import org.talend.repository.editor.RepositoryEditorInput;
import org.talend.repository.model.ERepositoryStatus;
@@ -299,6 +311,27 @@ public class StandAloneTalendJavaEditor extends CompilationUnitEditor implements
}
public void resetItem() throws PersistenceException {
if (item.getProperty().eResource() == null || item.eResource() == null) {
IRepositoryService service = CoreRuntimePlugin.getInstance().getRepositoryService();
IProxyRepositoryFactory factory = service.getProxyRepositoryFactory();
//
// Property updated = factory.getUptodateProperty(getItem().getProperty());
Property updatedProperty = null;
try {
factory.initialize();
IRepositoryViewObject repositoryViewObject = factory.getLastVersion(new Project(ProjectManager.getInstance()
.getProject(item.getProperty().getItem())), item.getProperty().getId());
if (repositoryViewObject != null) {
updatedProperty = repositoryViewObject.getProperty();
item = (FileItem) updatedProperty.getItem();
}
} catch (PersistenceException e) {
ExceptionHandler.process(e);
}
}
}
@Override
public void doSave(final IProgressMonitor monitor) {
IRepositoryService service = CorePlugin.getDefault().getRepositoryService();
@@ -325,6 +358,7 @@ public class StandAloneTalendJavaEditor extends CompilationUnitEditor implements
super.doSave(monitor);
try {
resetItem();
ByteArray byteArray = item.getContent();
byteArray.setInnerContentFromFile(((FileEditorInput) getEditorInput()).getFile());
try {
@@ -343,27 +377,65 @@ public class StandAloneTalendJavaEditor extends CompilationUnitEditor implements
refreshJobAndSave(repFactory);
}
};
repositoryWorkUnit.setAvoidSvnUpdate(true);
repositoryWorkUnit.setAvoidUnloadResources(true);
repFactory.executeRepositoryWorkUnit(repositoryWorkUnit);
repositoryWorkUnit.throwPersistenceExceptionIfAny();
// for bug 11930: Unable to save Routines.* in db project
// repFactory.save(item);
// startRefreshJob(repFactory);
} catch (Exception e) {
// e.printStackTrace();
} catch (final Exception e) {
ExceptionHandler.process(e);
final Display disp = DisplayUtils.getDisplay();
disp.asyncExec(new Runnable() {
@Override
public void run() {
ExceptionMessageDialog.openError(disp.getActiveShell(),
Messages.getString("SaveRoutineContentError.ErrorTitile"),
Messages.getString("SaveRoutineContentError.ErrorContent"), e);
}
});
}
}
private void refreshJobAndSave(final IProxyRepositoryFactory repFactory) {
private void refreshJobAndSave(final IProxyRepositoryFactory repFactory) throws PersistenceException {
final IWorkspaceRunnable op = new IWorkspaceRunnable() {
@Override
public void run(IProgressMonitor monitor) throws CoreException {
try {
repFactory.save(item);
} catch (Throwable e) {
throw new CoreException(new Status(IStatus.ERROR, DesignerPlugin.ID, "Save Routine failed!", e));
}
};
};
IRunnableWithProgress iRunnableWithProgress = new IRunnableWithProgress() {
@Override
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
IWorkspace workspace = ResourcesPlugin.getWorkspace();
try {
ISchedulingRule schedulingRule = workspace.getRoot();
// the update the project files need to be done in the workspace runnable to avoid all
// notification
// of changes before the end of the modifications.
workspace.run(op, schedulingRule, IWorkspace.AVOID_UPDATE, monitor);
} catch (CoreException e) {
throw new InvocationTargetException(e);
}
}
};
try {
// cause it to update MaxInformationLevel
repFactory.save(item);
} catch (Exception e) {
PlatformUI.getWorkbench().getProgressService().run(false, false, iRunnableWithProgress);
} catch (InvocationTargetException e) {
throw new PersistenceException(e);
} catch (InterruptedException e) {
throw new PersistenceException(e);
}
// update editor image
setTitleImage(getTitleImage());
}

View File

@@ -18,7 +18,7 @@ public class XmlMapExpressionManager {
private final static String EXPRESSION_PATTERN = "(\\[)\\s*(\\w+)\\s*\\.(\\w+\\s*:\\s*(/.+?)+(/@.+?)*)\\s*(\\])|((?!\\[)\\s*\\w+)\\s*\\.\\s*(\\w+(?!\\]))";
private final String SUBS_PATTERN_FOR_REPLACE_LOCATION = "{0}(\\s*){1}(\\s*)\\.(\\s*){2}(\\s*){3}";
private final String SUBS_PATTERN_FOR_REPLACE_LOCATION = "{0}(\\s*\\b){1}(\\s*)\\.(\\s*){2}(\\b\\s*){3}";
private Perl5Matcher matcher = new Perl5Matcher();