Compare commits

...

12 Commits

Author SHA1 Message Date
zwzhao-talend
36f40e47c7 patch TPS-678 : [5.3.1] HL7 repository parse issues (TDI-24882,
TDI-29999)
2014-07-23 10:48:38 +08:00
wchen-talend
5a57a533c1 Studio build properties : remove all references to empty 2014-07-16 11:39:01 +08:00
Sébastien Gandon
6659a31f24 Committed by hcyi for Patch TPS-630: [5.3.1] Some items from an export are not imported (TDI-29017) 2014-06-22 14:46:09 +02:00
Sébastien Gandon
60f0ca72a9 [TESB-12909] Problems with multiple cTalendJob usage 2014-06-22 14:46:08 +02:00
Sébastien Gandon
4e4b936c4b Committed by liugang for Patch TPS-601 : [5.3.1] Problems with multiple cTalendJob usage (TESB-12909) 2014-06-22 14:46:08 +02:00
Sébastien Gandon
ab112c658c Committed by zwzhao for Patch TPS-558 : [5.3.1] Need a patch for TDI-28375 tWebServiceInput advanced setting cannot be used to generate routines 2014-06-22 14:46:08 +02:00
Sébastien Gandon
f4bf3a8efc Committed by ldong for bug TDI-28274:can not open job. 2014-06-22 14:46:08 +02:00
Sébastien Gandon
3e32d94637 Committed by xqliu for Patch TPS-539: [5.3.1] Running tDQReportRun job against remote jobserver not working when the studio is on MAC OS 2014-06-22 14:46:08 +02:00
Sébastien Gandon
4ed1c20d19 Committed by plv for Patch TPS-524 : [5.3.1]slow response when retrieve db connections from Repository(TDI-27485) 2014-06-22 14:46:07 +02:00
Sébastien Gandon
439990117b Committed by jyhu for bug TDI-27608: missing support for Dynamic data type in LDAP components. 2014-06-22 14:46:07 +02:00
Sébastien Gandon
d6d3883e15 Committed by hcyi for Patch TPS-485 : [5.3.1]tHL7Output component Bug(TDI-26984, TDI-25946) 2014-06-22 14:46:07 +02:00
Sébastien Gandon
c8659a0c0f Committed by hcyi for Patch TPS-464 : [5.3.1] tWebService does not return any value (TDI-26617) . 2014-06-22 14:46:07 +02:00
64 changed files with 5221 additions and 4963 deletions

View File

@@ -65,24 +65,6 @@ if(("false").equals(useExistingConn)){
env_<%=cid%>.put(javax.naming.Context.REFERRAL, "<%=referrals%>"); env_<%=cid%>.put(javax.naming.Context.REFERRAL, "<%=referrals%>");
env_<%=cid%>.put("java.naming.ldap.derefAliases","<%=aliases%>"); env_<%=cid%>.put("java.naming.ldap.derefAliases","<%=aliases%>");
<% <%
// Types binaires
if(useFieldOptions){
boolean isBinary = false;
for(IMetadataColumn column:columnList){
for(Map<String, String> line:fieldOptions){// search in the configuration table
String columnName = line.get("SCHEMA_COLUMN");
if(column.getLabel().equals(columnName)){
isBinary = "true".equals(line.get("BINARY"));
break;
}
}
if(isBinary){
%>
env_<%=cid%>.put("java.naming.ldap.attributes.binary","<%=column.getOriginalDbColumnName()%>");
<%
}
}
}
if(baseDN == null || baseDN.length()<=2){ if(baseDN == null || baseDN.length()<=2){
%> %>
env_<%=cid%>.put(javax.naming.Context.PROVIDER_URL, "ldap://"+<%=host%>+":"+<%=port%>); env_<%=cid%>.put(javax.naming.Context.PROVIDER_URL, "ldap://"+<%=host%>+":"+<%=port%>);
@@ -145,6 +127,14 @@ if(("false").equals(useExistingConn)){
javax.naming.directory.SearchControls searchCtls_<%=cid%> = new javax.naming.directory.SearchControls(); javax.naming.directory.SearchControls searchCtls_<%=cid%> = new javax.naming.directory.SearchControls();
searchCtls_<%=cid%>.setSearchScope(javax.naming.directory.SearchControls.SUBTREE_SCOPE); searchCtls_<%=cid%>.setSearchScope(javax.naming.directory.SearchControls.SUBTREE_SCOPE);
<%
boolean isDynamic = metadata.isDynamicSchema();
if(isDynamic){
%>
routines.system.Dynamic dcg_<%=cid%> = new routines.system.Dynamic();
<%
}else{
%>
searchCtls_<%=cid%>.setReturningAttributes(new String[]{ searchCtls_<%=cid%>.setReturningAttributes(new String[]{
<% <%
for(IMetadataColumn column:columnList){ for(IMetadataColumn column:columnList){
@@ -154,6 +144,9 @@ if(("false").equals(useExistingConn)){
} }
%> %>
}); });
<%
}
%>
searchCtls_<%=cid%>.setTimeLimit(<%=timeout%>*1000); searchCtls_<%=cid%>.setTimeLimit(<%=timeout%>*1000);
searchCtls_<%=cid%>.setCountLimit(<%=limit %>); searchCtls_<%=cid%>.setCountLimit(<%=limit %>);
<% <%
@@ -180,6 +173,85 @@ if(("false").equals(useExistingConn)){
} }
} }
%> %>
<%
String binaryColumns = "";
boolean hasDynamicBinary=false;
if(useFieldOptions){
for(int i = 0;i<fieldOptions.size();i++){// search in the configuration table
Map<String, String> line = fieldOptions.get(i);
String columnName = line.get("SCHEMA_COLUMN");
Boolean isBinary = "true".equals(line.get("BINARY"));
if(isBinary){
IMetadataColumn column = columnList.get(i);
if(!column.getTalendType().equals("id_Dynamic")){
if(binaryColumns.length()>0){
binaryColumns+=" ";
}
binaryColumns+=column.getOriginalDbColumnName();
}else{
hasDynamicBinary = true;
}
}
}
}
boolean hasBinaryColumn = binaryColumns.length()>0 || hasDynamicBinary;
if(hasBinaryColumn){
%>
String binaryColumns_<%=cid%> = "<%=binaryColumns%>";
<%
}
if(isDynamic){
String columnsStr = "";
for(IMetadataColumn column:columnList){
columnsStr += column.getOriginalDbColumnName() + ",";
}
%>
String[] columnsInSchema_<%=cid%> = "<%=columnsStr%>".split(",");
java.util.Arrays.sort(columnsInSchema_<%=cid%>);
javax.naming.directory.Attributes attrsDyn_<%=cid%> = null;
javax.naming.NamingEnumeration answerDyn_<%=cid%> = ctx_<%=cid%>.search(<%if(("false").equals(useExistingConn)){%>baseDN_<%=cid%><%}else{%>""<%}%>, <%=filter%>, searchCtls_<%=cid%>);
while (answerDyn_<%=cid%> .hasMoreElements()) {
javax.naming.directory.SearchResult srDyn_<%=cid%> = (javax.naming.directory.SearchResult) answerDyn_<%=cid%>.next();
attrsDyn_<%=cid%> = srDyn_<%=cid%>.getAttributes();
javax.naming.NamingEnumeration ne_<%=cid%> =attrsDyn_<%=cid%>.getAll();
while(ne_<%=cid%>.hasMoreElements()){
String element_<%=cid%> = ne_<%=cid%>.nextElement().toString();
int splitorIndex_<%=cid%> = element_<%=cid%>.indexOf(":");
if(splitorIndex_<%=cid%>>0){
String columnName_<%=cid%> = element_<%=cid%>.substring(0,splitorIndex_<%=cid%>);
if(java.util.Arrays.binarySearch(columnsInSchema_<%=cid%>,columnName_<%=cid%>) < 0 || "<%=metadata.getDynamicColumn().getOriginalDbColumnName()%>".equals(columnName_<%=cid%>)){
DynamicMetadata dm_<%=cid%> = new DynamicMetadata();
dm_<%=cid%>.setName(columnName_<%=cid%>);
dm_<%=cid%>.setDbName(columnName_<%=cid%>);
dm_<%=cid%>.setType("id_String");
if(!dcg_<%=cid%>.metadatas.contains(dm_<%=cid%>)){
dcg_<%=cid%>.metadatas.add(dm_<%=cid%>);
<%
if(hasDynamicBinary){
if(binaryColumns.length()==0){
%>
if(binaryColumns_<%=cid%>.length()>0){
binaryColumns_<%=cid%>+=" ";
}
<%
}else{
%>
binaryColumns_<%=cid%>+=" ";
<%
}
%>
binaryColumns_<%=cid%>+=columnName_<%=cid%>;
<%
}
%>
}
}
}
}
}
<%
}
%>
<%if(paging){%> <%if(paging){%>
// Set the page size and initialize the cookie that we pass back in subsequent pages // Set the page size and initialize the cookie that we pass back in subsequent pages
int pageSize_<%=cid%> = <%=pageSize %>; int pageSize_<%=cid%> = <%=pageSize %>;
@@ -190,6 +262,17 @@ if(("false").equals(useExistingConn)){
do { do {
<%}%> <%}%>
<%
if(hasBinaryColumn){
%>
if(binaryColumns_<%=cid%>.length()>0){
java.util.Hashtable orignal_env_<%=cid%>= ctx_<%=cid%>.getEnvironment();
orignal_env_<%=cid%>.put("java.naming.ldap.attributes.binary",binaryColumns_<%=cid%>);
ctx_<%=cid%> = new javax.naming.ldap.InitialLdapContext(orignal_env_<%=cid%>, null);
}
<%
}
%>
javax.naming.NamingEnumeration answer_<%=cid%> = ctx_<%=cid%>.search(<%if(("false").equals(useExistingConn)){%>baseDN_<%=cid%><%}else{%>""<%}%>, <%=filter%>, searchCtls_<%=cid%>); javax.naming.NamingEnumeration answer_<%=cid%> = ctx_<%=cid%>.search(<%if(("false").equals(useExistingConn)){%>baseDN_<%=cid%><%}else{%>""<%}%>, <%=filter%>, searchCtls_<%=cid%>);
while (answer_<%=cid%> .hasMoreElements()) {//a while (answer_<%=cid%> .hasMoreElements()) {//a
@@ -267,6 +350,29 @@ do {
<%=conn.getName()%>.<%=column.getLabel()%> = ("".equals(sr_<%=cid%>.getName())?sr_<%=cid%>.getName():(sr_<%=cid%>.getName()+ ",")) + baseDN_<%=cid%>; <%=conn.getName()%>.<%=column.getLabel()%> = ("".equals(sr_<%=cid%>.getName())?sr_<%=cid%>.getName():(sr_<%=cid%>.getName()+ ",")) + baseDN_<%=cid%>;
<% <%
}else{ }else{
%>
<%
if("id_Dynamic".equals(column.getTalendType())) {
%>
dcg_<%=cid%>.clearColumnValues();
for(DynamicMetadata dm_<%=cid%> :dcg_<%=cid%>.metadatas){
javax.naming.directory.Attribute attr_<%=column.getLabel()%>_<%=cid%> = attrs_<%=cid%>.get(dm_<%=cid%>.getDbName());
if(attr_<%=column.getLabel()%>_<%=cid%> != null){
StringBuilder attrStr_<%=cid%> = new StringBuilder();
for (javax.naming.NamingEnumeration e_<%=cid%> = attr_<%=column.getLabel()%>_<%=cid%>.getAll(); e_<%=cid%>.hasMore();){
if(attrStr_<%=cid%>.length()>0){
attrStr_<%=cid%>.append(<%=separator%>);
}
attrStr_<%=cid%>.append(e_<%=cid%>.next().toString());
}
dcg_<%=cid%>.addColumnValue(attrStr_<%=cid%>.toString());
}else{
dcg_<%=cid%>.addColumnValue(null);
}
}
<%=conn.getName() %>.<%=column.getLabel() %> = dcg_<%=cid%>;
<%
}else{
%> %>
javax.naming.directory.Attribute attr_<%=column.getLabel()%>_<%=cid%> = attrs_<%=cid%>.get("<%=column.getOriginalDbColumnName()%>"); javax.naming.directory.Attribute attr_<%=column.getLabel()%>_<%=cid%> = attrs_<%=cid%>.get("<%=column.getOriginalDbColumnName()%>");
if(attr_<%=column.getLabel()%>_<%=cid%> != null){ if(attr_<%=column.getLabel()%>_<%=cid%> != null){
@@ -297,6 +403,7 @@ do {
} }
<% <%
}
} }
} }
}//5 }//5

View File

@@ -29,6 +29,7 @@ import org.talend.core.model.metadata.QueryUtil;
import org.talend.core.model.metadata.builder.connection.Connection; import org.talend.core.model.metadata.builder.connection.Connection;
import org.talend.core.model.metadata.builder.connection.DatabaseConnection; import org.talend.core.model.metadata.builder.connection.DatabaseConnection;
import org.talend.core.model.metadata.builder.connection.FTPConnection; import org.talend.core.model.metadata.builder.connection.FTPConnection;
import org.talend.core.model.metadata.builder.connection.HL7Connection;
import org.talend.core.model.metadata.builder.connection.MDMConnection; import org.talend.core.model.metadata.builder.connection.MDMConnection;
import org.talend.core.model.metadata.builder.connection.MetadataTable; import org.talend.core.model.metadata.builder.connection.MetadataTable;
import org.talend.core.model.metadata.builder.connection.Query; import org.talend.core.model.metadata.builder.connection.Query;
@@ -551,6 +552,16 @@ public class ChangeValuesFromRepository extends ChangeMetadataCommand {
if (curParam.getFieldType().equals(EParameterFieldType.AS400_CHECK)) { if (curParam.getFieldType().equals(EParameterFieldType.AS400_CHECK)) {
setOtherProperties(); setOtherProperties();
} }
// change the HL7 Version
if (connection instanceof HL7Connection) {
if (curParam.getName().equals("HL7_VER")) {
String hl7VersionString = connection.getVersion();
if (hl7VersionString != null) {
hl7VersionString = hl7VersionString.replace(".", "");
curParam.setValue(hl7VersionString);
}
}
}
} }
if (elem instanceof Node) { if (elem instanceof Node) {

View File

@@ -81,7 +81,10 @@ public class ConnectionFigure extends PolylineConnection {
if (PluginChecker.isAutoParalelPluginLoaded()) { if (PluginChecker.isAutoParalelPluginLoaded()) {
addParallelFigure(); addParallelFigure();
initFigureMap(); // TDI-26611
if (connection != null) {
initFigureMap();
}
} }
} }

View File

@@ -1260,7 +1260,7 @@ public class TalendEditorDropTargetListener extends TemplateTransferDropTargetLi
// fore HL7, by gcui // fore HL7, by gcui
if (selectedNode.getObjectType() == ERepositoryObjectType.METADATA_FILE_HL7 && PluginChecker.isHL7PluginLoaded()) { if (selectedNode.getObjectType() == ERepositoryObjectType.METADATA_FILE_HL7 && PluginChecker.isHL7PluginLoaded()) {
for (MetadataTable table : ConnectionHelper.getTables(originalConnection)) { for (MetadataTable table : ConnectionHelper.getTablesWithOrders(originalConnection)) {
Command hl7Cmd = new RepositoryChangeMetadataForHL7Command(node, IHL7Constant.TABLE_SCHEMAS, Command hl7Cmd = new RepositoryChangeMetadataForHL7Command(node, IHL7Constant.TABLE_SCHEMAS,
table.getLabel(), ConvertionHelper.convert(table)); table.getLabel(), ConvertionHelper.convert(table));
list.add(hl7Cmd); list.add(hl7Cmd);

View File

@@ -57,6 +57,7 @@ import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.PlatformUI; import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.views.properties.tabbed.ITabbedPropertyConstants; import org.eclipse.ui.views.properties.tabbed.ITabbedPropertyConstants;
import org.talend.commons.exception.LoginException;
import org.talend.commons.exception.PersistenceException; import org.talend.commons.exception.PersistenceException;
import org.talend.commons.exception.SystemException; import org.talend.commons.exception.SystemException;
import org.talend.commons.ui.runtime.exception.ExceptionHandler; import org.talend.commons.ui.runtime.exception.ExceptionHandler;
@@ -91,6 +92,7 @@ import org.talend.designer.core.model.utils.emf.talendfile.RoutinesParameterType
import org.talend.designer.core.ui.editor.nodes.Node; import org.talend.designer.core.ui.editor.nodes.Node;
import org.talend.designer.runprocess.IRunProcessService; import org.talend.designer.runprocess.IRunProcessService;
import org.talend.repository.ProjectManager; import org.talend.repository.ProjectManager;
import org.talend.repository.RepositoryWorkUnit;
import org.talend.repository.model.IProxyRepositoryFactory; import org.talend.repository.model.IProxyRepositoryFactory;
import org.talend.repository.model.IRepositoryService; import org.talend.repository.model.IRepositoryService;
import org.talend.repository.ui.views.IRepositoryView; import org.talend.repository.ui.views.IRepositoryView;
@@ -244,10 +246,12 @@ public class WSDL2JAVAController extends AbstractElementPropertySectionControlle
* org.talend.designer.core.ui.editor.properties2.editors.AbstractElementPropertySectionController#createCommand() * org.talend.designer.core.ui.editor.properties2.editors.AbstractElementPropertySectionController#createCommand()
*/ */
private void generateJavaFile() { private void generateJavaFile() {
final IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
RepositoryWorkUnit<Object> workUnit = new RepositoryWorkUnit<Object>("", this) {//$NON-NLS-1$
final IWorkspaceRunnable op = new IWorkspaceRunnable() { @Override
protected void run() throws PersistenceException {
public void run(IProgressMonitor monitor) throws CoreException {
Node node = (Node) elem; Node node = (Node) elem;
IProcess process = node.getProcess(); IProcess process = node.getProcess();
@@ -382,30 +386,9 @@ public class WSDL2JAVAController extends AbstractElementPropertySectionControlle
// } // }
FilesUtils.removeFolder(dir, true); FilesUtils.removeFolder(dir, true);
} }
}; };
IRunnableWithProgress iRunnableWithProgress = new IRunnableWithProgress() { workUnit.setAvoidUnloadResources(true);
factory.executeRepositoryWorkUnit(workUnit);
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 {
PlatformUI.getWorkbench().getProgressService().run(true, true, iRunnableWithProgress);
} catch (InvocationTargetException e) {
ExceptionHandler.process(e);
} catch (InterruptedException e) {
ExceptionHandler.process(e);
}
} }
private void refreshProject() { private void refreshProject() {

View File

@@ -225,30 +225,6 @@ public class PropertiesTableEditorView<B> extends AbstractDataTableEditorView<B>
} else { } else {
returnedValue = null; returnedValue = null;
} }
if (element instanceof INode) {
INode node = (INode) element;
if (node.getComponent().getName() != null && node.getComponent().getName().equals("tHL7Output")) {
IElementParameter rootParameter = element.getElementParameter("ROOT");
if (rootParameter != null) {
List<Map<String, String>> rootValue = (List<Map<String, String>>) rootParameter
.getValue();
if (rootValue != null) {
for (int i = 0; i < rootValue.size(); i++) {
Map<String, String> map = (Map<String, String>) rootValue.get(i);
String columnName = map.get("COLUMN");
String split[] = columnName.split(":");
if (split.length == 2 && !returnedValue.equals("<Empty>")) {
String newName = returnedValue + ":" + split[1];
map.put("COLUMN", newName);
} else if (split.length == 1 && !returnedValue.equals("<Empty>")) {
String newName = (String) returnedValue;
map.put("COLUMN", newName);
}
}
}
}
}
}
return returnedValue; return returnedValue;
}; };

View File

@@ -23,6 +23,10 @@ Bundle-Vendor: .Talend SA.
Bundle-ClassPath: . Bundle-ClassPath: .
Export-Package: org.talend.designer.hl7, Export-Package: org.talend.designer.hl7,
org.talend.designer.hl7.action, org.talend.designer.hl7.action,
org.talend.designer.hl7.dnd,
org.talend.designer.hl7.model,
org.talend.designer.hl7.ui.data, org.talend.designer.hl7.ui.data,
org.talend.designer.hl7.ui.edit, org.talend.designer.hl7.ui.edit,
org.talend.designer.hl7.ui.form org.talend.designer.hl7.ui.form,
org.talend.designer.hl7.ui.header,
org.talend.designer.hl7.util

View File

@@ -5,3 +5,5 @@ FooterComposite.AutoMap=Auto map!
FooterComposite.AutoMapTip=Map automatically schema to xml tree (for empty column node only) FooterComposite.AutoMapTip=Map automatically schema to xml tree (for empty column node only)
FooterComposite.RootElementError.Title=Error FooterComposite.RootElementError.Title=Error
FooterComposite.RootElementError.Message=Root elements of xml tree should be the same. FooterComposite.RootElementError.Message=Root elements of xml tree should be the same.
SetRepetableAction_removeRepeatable=Remove Repeatable
SetRepetableAction_setAsRepeatable=Set As Repeatable Element

View File

@@ -1,230 +1,230 @@
// ============================================================================ // ============================================================================
// //
// Copyright (C) 2006-2013 Talend Inc. - www.talend.com // Copyright (C) 2006-2014 Talend Inc. - www.talend.com
// //
// This source code is available under agreement available at // This source code is available under agreement available at
// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt // %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt
// //
// You should have received a copy of the agreement // You should have received a copy of the agreement
// along with this program; if not, write to Talend SA // along with this program; if not, write to Talend SA
// 9 rue Pages 92150 Suresnes, France // 9 rue Pages 92150 Suresnes, France
// //
// ============================================================================ // ============================================================================
package org.talend.designer.hl7; package org.talend.designer.hl7;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Shell;
import org.talend.commons.ui.runtime.exception.ExceptionHandler; import org.talend.commons.ui.runtime.exception.ExceptionHandler;
import org.talend.core.model.components.IODataComponent; import org.talend.core.model.components.IODataComponent;
import org.talend.core.model.metadata.ColumnNameChanged; import org.talend.core.model.metadata.ColumnNameChanged;
import org.talend.core.model.metadata.IMetadataTable; import org.talend.core.model.metadata.IMetadataTable;
import org.talend.core.model.process.AbstractExternalNode; import org.talend.core.model.process.AbstractExternalNode;
import org.talend.core.model.process.EParameterFieldType; import org.talend.core.model.process.EParameterFieldType;
import org.talend.core.model.process.IComponentDocumentation; import org.talend.core.model.process.IComponentDocumentation;
import org.talend.core.model.process.IElementParameter; import org.talend.core.model.process.IElementParameter;
import org.talend.core.model.process.IExternalData; import org.talend.core.model.process.IExternalData;
import org.talend.core.model.process.INode;
/**
* DOC Administrator class global comment. Detailled comment /**
*/ * DOC Administrator class global comment. Detailled comment
public class HL7InputComponent extends AbstractExternalNode { */
public class HL7InputComponent extends AbstractExternalNode {
public static final String ROOT = "ROOT"; //$NON-NLS-1$
public static final String ROOT = "ROOT"; //$NON-NLS-1$
public static final String GROUP = "GROUP"; //$NON-NLS-1$
public static final String GROUP = "GROUP"; //$NON-NLS-1$
public static final String LOOP = "LOOP"; //$NON-NLS-1$
public static final String LOOP = "LOOP"; //$NON-NLS-1$
public static final String PATH = "PATH"; //$NON-NLS-1$
public static final String PATH = "PATH"; //$NON-NLS-1$
public static final String VALUE = "VALUE"; //$NON-NLS-1$
public static final String VALUE = "VALUE"; //$NON-NLS-1$
public static final String TYPE = "TYPE"; //$NON-NLS-1$
public static final String TYPE = "TYPE"; //$NON-NLS-1$
public static final String COLUMN = "COLUMN"; //$NON-NLS-1$
public static final String COLUMN = "COLUMN"; //$NON-NLS-1$
public static final String ATTRIBUTE = "ATTRIBUTE"; //$NON-NLS-1$s
public static final String ATTRIBUTE = "ATTRIBUTE"; //$NON-NLS-1$s
public static final String ORDER = "ORDER"; //$NON-NLS-1$
public static final String ORDER = "ORDER"; //$NON-NLS-1$
private HL7Main hl7main;
private HL7Main hl7main;
@Override
protected void renameMetadataColumnName(String conectionName, String oldColumnName, String newColumnName) { @Override
} protected void renameMetadataColumnName(String conectionName, String oldColumnName, String newColumnName) {
}
public IComponentDocumentation getComponentDocumentation(String componentName, String tempFolderPath) {
return null; public IComponentDocumentation getComponentDocumentation(String componentName, String tempFolderPath) {
} return null;
}
public IExternalData getExternalData() {
return null; @Override
} public IExternalData getExternalData() {
return null;
public IExternalData getTMapExternalData() { }
return null;
} public IExternalData getTMapExternalData() {
return null;
public void initialize() { }
} public void initialize() {
public int open(Display display) { }
hl7main = new HL7Main(this);
Shell shell = hl7main.createUI(display); public int open(Display display) {
while (!shell.isDisposed()) { hl7main = new HL7Main(this);
try { Shell shell = hl7main.createUI(display);
if (!display.readAndDispatch()) { while (!shell.isDisposed()) {
display.sleep(); try {
} if (!display.readAndDispatch()) {
} catch (Throwable e) { display.sleep();
if (hl7main.isStandAloneMode()) { }
e.printStackTrace(); } catch (Throwable e) {
} else { if (hl7main.isStandAloneMode()) {
ExceptionHandler.process(e); e.printStackTrace();
} } else {
} ExceptionHandler.process(e);
} }
if (hl7main.isStandAloneMode()) { }
display.dispose(); }
} if (hl7main.isStandAloneMode()) {
return hl7main.getHl7Manager().getUiManager().getUiResponse(); display.dispose();
} }
return hl7main.getHl7Manager().getUiManager().getUiResponse();
public int open(Composite parent) { }
return open(parent.getDisplay());
} public int open(Composite parent) {
return open(parent.getDisplay());
public void renameInputConnection(String oldName, String newName) { }
List<Map<String, String>> listRoot = (List<Map<String, String>>) this.getElementParameter(ROOT).getValue();
boolean flagRoot = false; public void renameInputConnection(String oldName, String newName) {
String schemaId = oldName + ":"; INode node = getOriginalNode();
if (oldName != null) {
for (Map<String, String> map : listRoot) { IElementParameter elementParameter = this.getElementParameter("SCHEMAS");
String rowName = map.get(COLUMN); if (elementParameter != null) {
if (rowName == null) { Object listItemsValue = elementParameter.getValue();
continue; if (listItemsValue instanceof List) {
} for (Object obj : (List) listItemsValue) {
if (rowName.equals(oldName)) { if (obj instanceof Map) {
map.put(COLUMN, newName); Object row = ((Map) obj).get("PARENT_ROW");
flagRoot = true; if (oldName.equals(row)) {
} else if (rowName.startsWith(schemaId)) { ((Map) obj).put("PARENT_ROW", newName);
rowName = newName + rowName.substring(rowName.indexOf(":")); }
map.put(COLUMN, rowName);
flagRoot = true; }
} }
} }
if (flagRoot) { }
this.getElementParameter(ROOT).setValue(listRoot);
} }
} }
public void renameOutputConnection(String oldName, String newName) { public void renameOutputConnection(String oldName, String newName) {
} }
public void setExternalData(IExternalData persistentData) { public void setExternalData(IExternalData persistentData) {
} }
public IMetadataTable getMetadataTable() { public IMetadataTable getMetadataTable() {
try { try {
return getMetadataList().get(0); return getMetadataList().get(0);
} catch (Exception e) { } catch (Exception e) {
return null; return null;
} }
} }
@SuppressWarnings("unchecked")//$NON-NLS-1$ @SuppressWarnings("unchecked")
public List<Map<String, String>> getTableList(String paraName) { public List<Map<String, String>> getTableList(String paraName) {
List<Map<String, String>> list = new ArrayList<Map<String, String>>(); List<Map<String, String>> list = new ArrayList<Map<String, String>>();
List<IElementParameter> eps = (List<IElementParameter>) this.getElementParameters(); List<IElementParameter> eps = (List<IElementParameter>) this.getElementParameters();
if (eps == null) { if (eps == null) {
return list; return list;
} }
for (int i = 0; i < eps.size(); i++) { for (int i = 0; i < eps.size(); i++) {
IElementParameter parameter = eps.get(i); IElementParameter parameter = eps.get(i);
if (parameter.getFieldType() == EParameterFieldType.TABLE && parameter.getName().equals(paraName)) { if (parameter.getFieldType() == EParameterFieldType.TABLE && parameter.getName().equals(paraName)) {
list = (List<Map<String, String>>) parameter.getValue(); list = (List<Map<String, String>>) parameter.getValue();
break; break;
} }
} }
return list; return list;
} }
public boolean istFileInputHL7() { public boolean istFileInputHL7() {
return getComponent().getName().equals("tFileInputHL7"); //$NON-NLS-1$ //$NON-NLS-2$ return getComponent().getName().equals("tFileInputHL7"); //$NON-NLS-1$
} }
public boolean isHL7Output() { public boolean isHL7Output() {
return getComponent().getName().equals("tHL7Output");//$NON-NLS-1$ return getComponent().getName().equals("tHL7Output");//$NON-NLS-1$
} }
@SuppressWarnings("unchecked")//$NON-NLS-1$ @SuppressWarnings("unchecked")
public boolean setTableElementParameter(List<Map<String, String>> epsl, String paraName) { public boolean setTableElementParameter(List<Map<String, String>> epsl, String paraName) {
List<IElementParameter> eps = (List<IElementParameter>) this.getElementParameters(); List<IElementParameter> eps = (List<IElementParameter>) this.getElementParameters();
boolean result = true; boolean result = true;
for (int i = 0; i < eps.size(); i++) { for (int i = 0; i < eps.size(); i++) {
IElementParameter parameter = eps.get(i); IElementParameter parameter = eps.get(i);
if (parameter.getFieldType() == EParameterFieldType.TABLE && parameter.getName().equals(paraName)) { if (parameter.getFieldType() == EParameterFieldType.TABLE && parameter.getName().equals(paraName)) {
List<Map<String, String>> newValues = new ArrayList<Map<String, String>>(); List<Map<String, String>> newValues = new ArrayList<Map<String, String>>();
for (Map<String, String> map : epsl) { for (Map<String, String> map : epsl) {
Map<String, String> newMap = new HashMap<String, String>(); Map<String, String> newMap = new HashMap<String, String>();
newMap.putAll(map); newMap.putAll(map);
newValues.add(newMap); newValues.add(newMap);
} }
if (result) { if (result) {
parameter.setValue(newValues); parameter.setValue(newValues);
} }
break; break;
} }
} }
return result; return result;
} }
public void setValueToParameter(String paraName, Object value) { public void setValueToParameter(String paraName, Object value) {
IElementParameter parameter = this.getElementParameter(paraName); //$NON-NLS-N$ IElementParameter parameter = this.getElementParameter(paraName);
if (parameter != null && value != null) { if (parameter != null && value != null) {
parameter.setValue(value); parameter.setValue(value);
} }
} }
/* /*
* (non-Javadoc) * (non-Javadoc)
* *
* @seeorg.talend.core.model.process.AbstractExternalNode#metadataInputChanged(org.talend.core.model.components. * @seeorg.talend.core.model.process.AbstractExternalNode#metadataInputChanged(org.talend.core.model.components.
* IODataComponent, java.lang.String) * IODataComponent, java.lang.String)
*/ */
@Override @Override
public void metadataInputChanged(IODataComponent dataComponent, String connectionToApply) { public void metadataInputChanged(IODataComponent dataComponent, String connectionToApply) {
super.metadataInputChanged(dataComponent, connectionToApply); super.metadataInputChanged(dataComponent, connectionToApply);
List<Map<String, String>> listRoot = (List<Map<String, String>>) this.getElementParameter(ROOT).getValue(); List<Map<String, String>> listRoot = (List<Map<String, String>>) this.getElementParameter(ROOT).getValue();
boolean flagRoot = false; boolean flagRoot = false;
String schemaId = ""; //$NON-NLS-1$ String schemaId = ""; //$NON-NLS-1$
if (isHL7Output()) { if (isHL7Output()) {
schemaId = dataComponent.getConnection().getMetadataTable().getLabel() + ":"; //$NON-NLS-1$ schemaId = dataComponent.getConnection().getMetadataTable().getLabel() + ":"; //$NON-NLS-1$
} }
for (ColumnNameChanged col : dataComponent.getColumnNameChanged()) { for (ColumnNameChanged col : dataComponent.getColumnNameChanged()) {
for (Map<String, String> map : listRoot) { for (Map<String, String> map : listRoot) {
if (map.get(COLUMN).equals(schemaId + col.getOldName())) { if (map.get(COLUMN).equals(schemaId + col.getOldName())) {
map.put(COLUMN, schemaId + col.getNewName()); map.put(COLUMN, schemaId + col.getNewName());
flagRoot = true; flagRoot = true;
} }
} }
} }
if (flagRoot) { if (flagRoot) {
this.getElementParameter(ROOT).setValue(listRoot); this.getElementParameter(ROOT).setValue(listRoot);
} }
} }
} }

View File

@@ -1,158 +1,207 @@
// ============================================================================ // ============================================================================
// //
// Copyright (C) 2006-2013 Talend Inc. - www.talend.com // Copyright (C) 2006-2014 Talend Inc. - www.talend.com
// //
// This source code is available under agreement available at // This source code is available under agreement available at
// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt // %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt
// //
// You should have received a copy of the agreement // You should have received a copy of the agreement
// along with this program; if not, write to Talend SA // along with this program; if not, write to Talend SA
// 9 rue Pages 92150 Suresnes, France // 9 rue Pages 92150 Suresnes, France
// //
// ============================================================================ // ============================================================================
package org.talend.designer.hl7.action; package org.talend.designer.hl7.action;
import org.eclipse.jface.dialogs.InputDialog; import java.util.HashMap;
import org.eclipse.jface.dialogs.MessageDialog; import java.util.List;
import org.eclipse.jface.viewers.TreeViewer; import java.util.Map;
import org.eclipse.ui.actions.SelectionProviderAction;
import org.talend.designer.hl7.ui.HL7UI; import org.eclipse.jface.dialogs.IInputValidator;
import org.talend.designer.hl7.ui.data.Attribute; import org.eclipse.jface.dialogs.InputDialog;
import org.talend.designer.hl7.ui.data.Element; import org.eclipse.jface.dialogs.MessageDialog;
import org.talend.designer.hl7.ui.data.HL7TreeNode; import org.eclipse.jface.viewers.TreeViewer;
import org.talend.designer.hl7.ui.data.NameSpaceNode; import org.eclipse.ui.actions.SelectionProviderAction;
import org.talend.repository.ui.swt.utils.AbstractForm; import org.talend.core.model.metadata.IMetadataTable;
import org.talend.core.model.metadata.MetadataTable;
/** import org.talend.designer.hl7.managers.HL7OutputManager;
* bqian Create a xml node. <br/> import org.talend.designer.hl7.ui.HL7UI;
* import org.talend.designer.hl7.ui.data.Attribute;
* $Id: CreateElementAction.java,v 1.1 2007/06/12 07:20:38 gke Exp $ import org.talend.designer.hl7.ui.data.Element;
* import org.talend.designer.hl7.ui.data.HL7TreeNode;
*/ import org.talend.designer.hl7.ui.data.NameSpaceNode;
public class CreateHL7ElementAction extends SelectionProviderAction { import org.talend.repository.ui.swt.utils.AbstractForm;
/**
* bqian Create a xml node. <br/>
*
* $Id: CreateElementAction.java,v 1.1 2007/06/12 07:20:38 gke Exp $
*
*/
public class CreateHL7ElementAction extends SelectionProviderAction {
// the xml viewer, see HL7UI. // the xml viewer, see HL7UI.
private TreeViewer xmlViewer; private TreeViewer xmlViewer;
private HL7UI hl7ui; private HL7UI hl7ui;
private AbstractForm from; private AbstractForm from;
/** /**
* CreateNode constructor comment. * CreateNode constructor comment.
* *
* @param provider * @param provider
* @param text * @param text
*/ */
public CreateHL7ElementAction(TreeViewer xmlViewer, String text) { public CreateHL7ElementAction(TreeViewer xmlViewer, String text) {
super(xmlViewer, text); super(xmlViewer, text);
this.xmlViewer = xmlViewer; this.xmlViewer = xmlViewer;
} }
public CreateHL7ElementAction(TreeViewer xmlViewer, String text, AbstractForm from) { public CreateHL7ElementAction(TreeViewer xmlViewer, String text, AbstractForm from) {
super(xmlViewer, text); super(xmlViewer, text);
this.xmlViewer = xmlViewer; this.xmlViewer = xmlViewer;
this.from = from; this.from = from;
} }
public CreateHL7ElementAction(TreeViewer xmlViewer, HL7UI hl7ui, String text) { public CreateHL7ElementAction(TreeViewer xmlViewer, HL7UI hl7ui, String text) {
super(xmlViewer, text); super(xmlViewer, text);
this.xmlViewer = xmlViewer; this.xmlViewer = xmlViewer;
this.hl7ui = hl7ui; this.hl7ui = hl7ui;
} }
public void init() { public void init() {
HL7TreeNode node = (HL7TreeNode) this.getStructuredSelection().getFirstElement(); HL7TreeNode node = (HL7TreeNode) this.getStructuredSelection().getFirstElement();
if (node == null) { if (node == null) {
this.setEnabled(false); this.setEnabled(false);
return; return;
} }
// if (node.getParent() == null) { // if (node.getParent() == null) {
// this.setEnabled(false); // this.setEnabled(false);
// return; // return;
// } // }
if (node instanceof Attribute) { if (node instanceof Attribute) {
this.setEnabled(false); this.setEnabled(false);
return; return;
} }
if (node instanceof NameSpaceNode) { if (node instanceof NameSpaceNode) {
this.setEnabled(false); this.setEnabled(false);
return; return;
} }
this.setEnabled(true); this.setEnabled(true);
} }
/* /*
* (non-Javadoc) * (non-Javadoc)
* *
* @see org.eclipse.jface.action.Action#run() * @see org.eclipse.jface.action.Action#run()
*/ */
@Override @Override
public void run() { public void run() {
HL7TreeNode node = (HL7TreeNode) this.getStructuredSelection().getFirstElement(); HL7TreeNode node = (HL7TreeNode) this.getStructuredSelection().getFirstElement();
if (createChildNode(node)) { createChildNode(node);
if (hl7ui != null) { }
hl7ui.redrawLinkers();
} else if (from != null) { /**
from.refreshLinks(); * Create the child node of the input node
} *
} * @param node
} */
private boolean createChildNode(final HL7TreeNode node) {
/** if (node.getColumn() != null) {
* Create the child node of the input node if (!MessageDialog.openConfirm(
* xmlViewer.getControl().getShell(),
* @param node "Warning",
*/ "Do you want to disconnect the existing linker and then add an sub element for the selected element"
private boolean createChildNode(HL7TreeNode node) { + node.getLabel() + "\"?")) {
if (node.getColumn() != null) { return false;
if (!MessageDialog.openConfirm(xmlViewer.getControl().getShell(), "Warning", }
"Do you want to disconnect the existing linker and then add an sub element for the selected element" node.setColumn(null);
+ node.getLabel() + "\"?")) { }
return false; String label = "";
} final String nodeLabel = node.getLabel() + "-";
node.setColumn(null); while (!StringUtil.validateLabelForXML(label)) {
} // add validator
String label = ""; IInputValidator validator = new IInputValidator() {
final String nodeLabel = node.getLabel() + "-";
while (!StringUtil.validateLabelForXML(label)) { public String isValid(String newText) {
InputDialog dialog = new InputDialog(null, "Input element's label", "Input the new element's valid label", nodeLabel, if (newText != null) {
null) { String text = newText.trim();
for (HL7TreeNode children : node.getChildren()) {
/* if (text.equals(children.getLabel())) {
* (non-Javadoc) return "The name already existed."; //$NON-NLS-1$
* }
* @see org.eclipse.jface.dialogs.Dialog#okPressed() }
*/ }
@Override return null;
protected void okPressed() { }
String eleName = this.getValue(); };
// if (eleName.startsWith(nodeLabel)) { InputDialog dialog = new InputDialog(null, "Input element's label", "Input the new element's valid label", nodeLabel,
super.okPressed(); validator) {
// } else {
// setErrorMessage("Element's label must start with " + "\"" + nodeLabel + "\""); /*
// } * (non-Javadoc)
*
} * @see org.eclipse.jface.dialogs.Dialog#okPressed()
*/
}; @Override
dialog.setErrorMessage("name is error"); protected void okPressed() {
int status = dialog.open(); super.okPressed();
if (status == InputDialog.OK) { }
label = dialog.getValue().trim();
} };
if (status == InputDialog.CANCEL) { dialog.setErrorMessage("name is error");
return false; int status = dialog.open();
} if (status == InputDialog.OK) {
} label = dialog.getValue().trim();
HL7TreeNode child = new Element(label); }
child.setRow(node.getRow()); if (status == InputDialog.CANCEL) {
node.addChild(child); return false;
this.xmlViewer.refresh(); }
this.xmlViewer.expandAll(); }
return true; HL7TreeNode child = new Element(label);
} // if the root not have CurSchema
} if (node.getRow() == null || node.getRow().equals("")) {
if (hl7ui != null && hl7ui.gethl7Manager() instanceof HL7OutputManager) {
if (label.length() == 3) {
child.setRow(label);
IMetadataTable table = null;
for (IMetadataTable curTable : hl7ui.gethl7Manager().getHl7Component().getMetadataList()) {
if (label.equals(curTable.getLabel())) {
table = curTable;
break;
}
}
if (table == null) {
table = new MetadataTable();
table.setLabel(label);
table.setTableName(label);
hl7ui.gethl7Manager().getHl7Component().getMetadataList().add(table);
}
List<Map<String, String>> maps = (List<Map<String, String>>) hl7ui.gethl7Manager().getHl7Component()
.getElementParameter("SCHEMAS").getValue(); //$NON-NLS-1$
boolean found = false;
for (Map<String, String> map : maps) {
if (map.get("SCHEMA").equals(table.getTableName())) {
found = true;
}
}
if (!found) {
Map<String, String> hl7Schema = new HashMap<String, String>();
maps.add(hl7Schema);
hl7Schema.put("SCHEMA", table.getTableName());
}
}
} else if (label.length() == 3) {
child.setRow(label);
}
} else {
child.setRow(node.getRow());
}
node.addChild(child);
this.xmlViewer.refresh();
return true;
}
}

View File

@@ -1,136 +1,116 @@
// ============================================================================ // ============================================================================
// //
// Copyright (C) 2006-2013 Talend Inc. - www.talend.com // Copyright (C) 2006-2014 Talend Inc. - www.talend.com
// //
// This source code is available under agreement available at // This source code is available under agreement available at
// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt // %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt
// //
// You should have received a copy of the agreement // You should have received a copy of the agreement
// along with this program; if not, write to Talend SA // along with this program; if not, write to Talend SA
// 9 rue Pages 92150 Suresnes, France // 9 rue Pages 92150 Suresnes, France
// //
// ============================================================================ // ============================================================================
package org.talend.designer.hl7.action; package org.talend.designer.hl7.action;
import java.util.List; import java.util.List;
import org.eclipse.jface.viewers.TreeViewer; import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.ui.actions.SelectionProviderAction; import org.eclipse.ui.actions.SelectionProviderAction;
import org.talend.designer.hl7.ui.HL7UI; import org.talend.designer.hl7.ui.HL7UI;
import org.talend.designer.hl7.ui.data.Attribute; import org.talend.designer.hl7.ui.data.Element;
import org.talend.designer.hl7.ui.data.Element; import org.talend.designer.hl7.ui.data.HL7TreeNode;
import org.talend.designer.hl7.ui.data.HL7TreeNode; import org.talend.repository.ui.swt.utils.AbstractForm;
import org.talend.designer.hl7.ui.data.NameSpaceNode;
import org.talend.repository.ui.swt.utils.AbstractForm; /**
* bqian Create a xml node. <br/>
/** *
* bqian Create a xml node. <br/> * $Id: DeleteNodeAction.java,v 1.1 2007/06/12 07:20:38 gke Exp $
* *
* $Id: DeleteNodeAction.java,v 1.1 2007/06/12 07:20:38 gke Exp $ */
* public class DeleteHL7NodeAction extends SelectionProviderAction {
*/
public class DeleteHL7NodeAction extends SelectionProviderAction { // the xml viewer, see HL7UI.
private TreeViewer xmlViewer;
// the xml viewer, see HL7UI.
private TreeViewer xmlViewer; private HL7UI hl7ui;
private HL7UI hl7ui; private AbstractForm form;
private AbstractForm form; /**
* CreateNode constructor comment.
/** *
* CreateNode constructor comment. * @param provider
* * @param text
* @param provider */
* @param text public DeleteHL7NodeAction(TreeViewer xmlViewer, String text) {
*/ super(xmlViewer, text);
public DeleteHL7NodeAction(TreeViewer xmlViewer, String text) { this.xmlViewer = xmlViewer;
super(xmlViewer, text); }
this.xmlViewer = xmlViewer;
} public DeleteHL7NodeAction(TreeViewer xmlViewer, String text, AbstractForm form) {
super(xmlViewer, text);
public DeleteHL7NodeAction(TreeViewer xmlViewer, String text, AbstractForm form) { this.xmlViewer = xmlViewer;
super(xmlViewer, text); this.form = form;
this.xmlViewer = xmlViewer; }
this.form = form;
} public DeleteHL7NodeAction(TreeViewer xmlViewer, HL7UI hl7ui, String text) {
super(xmlViewer, text);
public DeleteHL7NodeAction(TreeViewer xmlViewer, HL7UI hl7ui, String text) { this.xmlViewer = xmlViewer;
super(xmlViewer, text); this.hl7ui = hl7ui;
this.xmlViewer = xmlViewer; }
this.hl7ui = hl7ui;
} public void init() {
HL7TreeNode node = (HL7TreeNode) this.getStructuredSelection().getFirstElement();
public void init() { if (node == null) {
HL7TreeNode node = (HL7TreeNode) this.getStructuredSelection().getFirstElement(); this.setEnabled(false);
if (node == null) { } else {
this.setEnabled(false); if (node.getParent() == null) {
} else { this.setEnabled(false);
if (node.getParent() == null) { } else {
this.setEnabled(false); this.setEnabled(true);
} else { }
this.setEnabled(true); }
} }
}
} /*
* (non-Javadoc)
/* *
* (non-Javadoc) * @see org.eclipse.jface.action.Action#run()
* */
* @see org.eclipse.jface.action.Action#run() @Override
*/ public void run() {
@Override HL7TreeNode node = (HL7TreeNode) this.getStructuredSelection().getFirstElement();
public void run() { if (node == null) {
HL7TreeNode node = (HL7TreeNode) this.getStructuredSelection().getFirstElement(); return;
if (node == null) { }
return;
} HL7TreeNode parent = node.getParent();
if (parent == null) {
HL7TreeNode parent = node.getParent(); return;
if (parent == null) { }
return; if (node instanceof Element) {
} disconnectSubTree(node);
if (node instanceof Element) { }
disconnectSubTree(node); parent.removeChild(node);
} xmlViewer.refresh(parent);
parent.removeChild(node); }
// if (TreeUtil.refreshTree((HL7TreeNode) xmlViewer.getTree().getItem(0).getData())) {
// xmlViewer.refresh(); /**
// } * DOC ke Comment method "disconnectSubTree".
if (node.isRepetable() || node.isGroup()) { *
// hl7ui.updateStatus(); * @param node
} */
xmlViewer.refresh(parent); private void disconnectSubTree(HL7TreeNode node) {
xmlViewer.expandAll(); if (node == null) {
if (hl7ui != null) { return;
hl7ui.redrawLinkers(); }
} else if (form != null) { if (node.hasLink()) {
form.refreshLinks(); node.setColumn(null);
} }
} List<HL7TreeNode> children = node.getChildren();
for (HL7TreeNode child : children) {
/** disconnectSubTree(child);
* DOC ke Comment method "disconnectSubTree". }
* }
* @param node
*/ }
private void disconnectSubTree(HL7TreeNode node) {
if (node == null) {
return;
}
if (node.hasLink()) {
node.setColumn(null);
}
if (node instanceof Attribute) {
return;
}
if (node instanceof NameSpaceNode) {
return;
}
List<HL7TreeNode> children = node.getChildren();
for (HL7TreeNode child : children) {
disconnectSubTree(child);
}
}
}

View File

@@ -1,429 +1,437 @@
// ============================================================================ // ============================================================================
// //
// Copyright (C) 2006-2013 Talend Inc. - www.talend.com // Copyright (C) 2006-2014 Talend Inc. - www.talend.com
// //
// This source code is available under agreement available at // This source code is available under agreement available at
// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt // %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt
// //
// You should have received a copy of the agreement // You should have received a copy of the agreement
// along with this program; if not, write to Talend SA // along with this program; if not, write to Talend SA
// 9 rue Pages 92150 Suresnes, France // 9 rue Pages 92150 Suresnes, France
// //
// ============================================================================ // ============================================================================
package org.talend.designer.hl7.action; package org.talend.designer.hl7.action;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import org.eclipse.emf.common.util.EList; import org.eclipse.emf.common.util.EList;
import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.gef.commands.Command;
import org.eclipse.jface.viewers.TreeViewer; import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.swt.widgets.FileDialog; import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.swt.widgets.TreeItem; import org.eclipse.swt.widgets.FileDialog;
import org.eclipse.ui.actions.SelectionProviderAction; import org.eclipse.swt.widgets.TreeItem;
import org.talend.core.model.metadata.builder.connection.HL7Connection; import org.eclipse.ui.actions.SelectionProviderAction;
import org.talend.core.model.metadata.builder.connection.HL7FileNode; import org.talend.commons.exception.ExceptionHandler;
import org.talend.designer.hl7.managers.HL7OutputManager; import org.talend.core.model.metadata.IHL7Constant;
import org.talend.designer.hl7.ui.HL7UI; import org.talend.core.model.metadata.IMetadataTable;
import org.talend.designer.hl7.ui.data.Attribute; import org.talend.core.model.metadata.builder.ConvertionHelper;
import org.talend.designer.hl7.ui.data.Element; import org.talend.core.model.metadata.builder.connection.ConnectionFactory;
import org.talend.designer.hl7.ui.data.HL7TreeNode; import org.talend.core.model.metadata.builder.connection.HL7Connection;
import org.talend.designer.hl7.ui.data.NameSpaceNode; import org.talend.core.model.metadata.builder.connection.HL7FileNode;
import org.talend.designer.hl7.ui.form.AbstractHL7StepForm; import org.talend.core.model.metadata.builder.connection.MetadataColumn;
import org.talend.designer.hl7.ui.header.HL7Parse; import org.talend.core.model.metadata.builder.connection.MetadataTable;
import org.talend.designer.hl7.util.HL7PublicUtil; import org.talend.core.model.process.IConnection;
import org.talend.core.model.process.IConnectionCategory;
import ca.uhn.hl7v2.model.Message; import org.talend.core.model.utils.NodeUtil;
import org.talend.core.runtime.CoreRuntimePlugin;
/** import org.talend.core.ui.metadata.command.RepositoryChangeMetadataForHL7Command;
* DOC hwang class global comment. Detailled comment import org.talend.designer.hl7.managers.HL7OutputManager;
*/ import org.talend.designer.hl7.ui.HL7UI;
public class ImportHL7StructureAction extends SelectionProviderAction { import org.talend.designer.hl7.ui.data.Element;
import org.talend.designer.hl7.ui.data.HL7TreeNode;
private TreeViewer xmlViewer; import org.talend.designer.hl7.ui.form.AbstractHL7StepForm;
import org.talend.designer.hl7.ui.header.HL7Parse;
private HL7UI hl7ui; import org.talend.designer.hl7.util.HL7PublicUtil;
import org.talend.repository.model.IProxyRepositoryFactory;
private AbstractHL7StepForm form;
import ca.uhn.hl7v2.model.Message;
private int order = 1;
/**
private HL7Connection hl7Connection; * DOC hwang class global comment. Detailled comment
*/
private HL7PublicUtil hl7Util = new HL7PublicUtil(); public class ImportHL7StructureAction extends SelectionProviderAction {
private Map<String, Integer> orderMap = new HashMap<String, Integer>(); private TreeViewer xmlViewer;
/** private HL7UI hl7ui;
* Create constructor comment.
* private AbstractHL7StepForm form;
* @param provider
* @param text private HL7Connection hl7Connection;
*/
public ImportHL7StructureAction(HL7Connection hl7Connection, TreeViewer xmlViewer, String text, AbstractHL7StepForm form) { private HL7PublicUtil hl7Util = new HL7PublicUtil();
super(xmlViewer, text);
this.xmlViewer = xmlViewer; private Map<String, Integer> orderMap = new HashMap<String, Integer>();
this.form = form;
this.hl7Connection = hl7Connection; /**
} * Create constructor comment.
*
public ImportHL7StructureAction(TreeViewer xmlViewer, HL7UI hl7ui, String text) { * @param provider
super(xmlViewer, text); * @param text
this.xmlViewer = xmlViewer; */
this.hl7ui = hl7ui; public ImportHL7StructureAction(HL7Connection hl7Connection, TreeViewer xmlViewer, String text, AbstractHL7StepForm form) {
} super(xmlViewer, text);
this.xmlViewer = xmlViewer;
private List treeNodeAdapt() { this.form = form;
List<HL7TreeNode> list = new ArrayList<HL7TreeNode>(); this.hl7Connection = hl7Connection;
FileDialog f = null; }
if (hl7ui != null) {
f = new FileDialog(hl7ui.getHl7UIParent().getShell()); public ImportHL7StructureAction(TreeViewer xmlViewer, HL7UI hl7ui, String text) {
} else if (form != null) { super(xmlViewer, text);
f = new FileDialog(form.getShell()); this.xmlViewer = xmlViewer;
} this.hl7ui = hl7ui;
String file = f.open(); }
if (file == null) {
return list; private List treeNodeAdapt() {
} List<HL7TreeNode> treeData = new ArrayList<HL7TreeNode>();
HL7Parse hl7Parse = new HL7Parse(); FileDialog f = null;
List<String> msgContentList = new ArrayList<String>(); if (hl7ui != null) {
f = new FileDialog(hl7ui.getHl7UIParent().getShell());
List<Message> messageList = hl7Parse.doParse(file, "'\\u000b'", "'\\u001c'"); } else if (form != null) {
List<HL7TreeNode> nodeList = hl7Util.getHL7TreeNodes(messageList); f = new FileDialog(form.getShell());
}
List schemaList = new ArrayList(); String file = f.open();
if (file == null) {
for (Message message : messageList) { return treeData;
schemaList.addAll(hl7Util.getFirstLevelChild(message)); }
} HL7Parse hl7Parse = new HL7Parse();
// for (Object obj : schemaList) { List<String> msgContentList = new ArrayList<String>();
//
// } List<Message> messageList = hl7Parse.doParse(file, "'\\u000b'", "'\\u001c'");
if (!nodeList.isEmpty()) { List<HL7TreeNode> nodeList = hl7Util.getHL7TreeNodes(messageList);
HL7TreeNode hl7TreeNode = nodeList.get(0);
List<HL7FileNode> table = new ArrayList<HL7FileNode>(); if (!nodeList.isEmpty()) {
if (hl7Connection != null) { HL7TreeNode hl7TreeNode = nodeList.get(0);
EList root = hl7Connection.getRoot(); List<HL7FileNode> table = new ArrayList<HL7FileNode>();
root.clear(); if (hl7Connection != null) {
if (hl7TreeNode != null) { EList root = hl7Connection.getRoot();
hl7Util.initNodeOrder(hl7TreeNode, orderMap, order); root.clear();
hl7Util.tableLoader((Element) hl7TreeNode, "", root, hl7TreeNode.getDefaultValue(), orderMap); if (hl7TreeNode != null) {
} hl7Util.initNodeOrder(hl7TreeNode, orderMap);
table.addAll(root); hl7Util.tableLoader((Element) hl7TreeNode, "", root, hl7TreeNode.getDefaultValue(), orderMap);
} else { }
if (hl7TreeNode != null) { table.addAll(root);
hl7Util.initNodeOrder(hl7TreeNode, orderMap, order); } else {
hl7Util.tableLoader((Element) hl7TreeNode, "", table, hl7TreeNode.getDefaultValue(), orderMap); if (hl7TreeNode != null) {
} hl7Util.initNodeOrder(hl7TreeNode, orderMap);
} hl7Util.tableLoader((Element) hl7TreeNode, "", table, hl7TreeNode.getDefaultValue(), orderMap);
}
// list.add(hl7TreeNode); }
initXmlTreeData(schemaList, table, list);
} List<String> schemaList = new ArrayList<String>();
for (HL7FileNode node : table) {
// try { String columnName = node.getRelatedColumn();
// ATreeNode treeNode = SchemaPopulationUtil.getSchemaTree(file, true, 0); if (columnName.contains(":")) {
// String schemaName = getSelectedSchema(); columnName = columnName.substring(0, columnName.indexOf(":"));
// HL7TreeNode root = cloneATreeNode(treeNode, schemaName); }
// root = ((Element) root).getElementChildren().get(0); if (!schemaList.contains(columnName) && !"".equals(columnName)) {
// root.setParent(null); schemaList.add(columnName);
// list.add(root); }
// } catch (Exception e) { }
// // e.printStackTrace(); initXmlTreeData(schemaList, table, treeData);
// ExceptionHandler.process(e); }
// } return treeData;
return list; }
}
private void initXmlTreeData(List<String> schemaList, List<HL7FileNode> root, List<HL7TreeNode> treeData) {
private void initXmlTreeData(List schemaList, List<HL7FileNode> root, List<HL7TreeNode> list) { Map<String, HL7TreeNode> mapNodes = new HashMap<String, HL7TreeNode>();
if (hl7ui != null) { List<? extends IConnection> incomingConnections = new ArrayList<IConnection>();
if (hl7ui.gethl7Manager() instanceof HL7OutputManager) { if (hl7ui != null) {
((HL7OutputManager) hl7ui.gethl7Manager()).getContents().clear(); if (hl7ui.gethl7Manager() instanceof HL7OutputManager) {
} ((HL7OutputManager) hl7ui.gethl7Manager()).getContents().clear();
} incomingConnections = NodeUtil.getIncomingConnections(hl7ui.gethl7Manager().getHl7Component(),
for (Object obj : schemaList) { IConnectionCategory.FLOW);
List<HL7TreeNode> treeNodes = null; }
HL7TreeNode rootNode = null; }
HL7TreeNode current = null; IProxyRepositoryFactory factory = CoreRuntimePlugin.getInstance().getProxyRepositoryFactory();
HL7TreeNode temp = null; List<MetadataTable> iMetadataTables = new ArrayList<MetadataTable>();
HL7TreeNode mainNode = null; HL7TreeNode rootNode = null;
String mainPath = null; Map<String, IMetadataTable> schemaNameToInputTable = new HashMap<String, IMetadataTable>();
String currentPath = null; Map<String, MetadataTable> schemaNameToOutputTable = new HashMap<String, MetadataTable>();
String defaultValue = null; for (String schemaName : schemaList) {
int nodeOrder = 0; IMetadataTable metadataTable = null;
boolean haveOrder = true; for (IConnection connection : incomingConnections) {
String schemaId = hl7Util.getLabel(obj, true) + ":";//((MetadataTable) obj).getLabel() + ":"; //$NON-NLS-1$ if (connection.getUniqueName().equals(schemaName)) {
if (hl7ui != null) { metadataTable = connection.getMetadataTable();
if (hl7ui.gethl7Manager() instanceof HL7OutputManager) { metadataTable.setLabel(connection.getUniqueName());
treeNodes = ((HL7OutputManager) hl7ui.gethl7Manager()).getTreeData(hl7Util.getLabel(obj, true)); schemaNameToInputTable.put(schemaName, metadataTable);
} break;
} }
if (treeNodes == null) { }
treeNodes = new ArrayList<HL7TreeNode>();
} MetadataTable targetMetadataTable = ConnectionFactory.eINSTANCE.createMetadataTable();
// build root tree targetMetadataTable.setId(factory.getNextId());
for (int i = 0; i < root.size(); i++) { schemaNameToOutputTable.put(schemaName, targetMetadataTable);
HL7FileNode node = (HL7FileNode) root.get(i); targetMetadataTable.setLabel(schemaName);
String newPath = node.getFilePath(); iMetadataTables.add(targetMetadataTable);
defaultValue = node.getDefaultValue(); }
String columnName = node.getRelatedColumn();
// String type = node.getType(); HL7TreeNode current = null;
String orderValue = String.valueOf(node.getOrder()); HL7TreeNode temp = null;
if (orderValue == null || "".equals(orderValue)) { String currentPath = null;
haveOrder = false; String defaultValue = null;
} int nodeOrder = 0;
if (haveOrder) { boolean haveOrder = true;
nodeOrder = node.getOrder(); // build root tree
} for (int i = 0; i < root.size(); i++) {
String flag = columnName + ":"; //$NON-NLS-1$ HL7FileNode node = root.get(i);
if (columnName != null && columnName.length() > 0 && !flag.startsWith(schemaId)) { String newPath = node.getFilePath();
continue; defaultValue = node.getDefaultValue();
} String columnName = node.getRelatedColumn();
if (node.getAttribute().equals("attri")) { // String type = node.getType();
temp = new Attribute(newPath); String orderValue = String.valueOf(node.getOrder());
temp.setDefaultValue(defaultValue); if (orderValue == null || "".equals(orderValue)) {
temp.setAttribute(true); haveOrder = false;
// temp.setDataType(type); }
current.addChild(temp); if (haveOrder) {
} else if (node.getAttribute().equals("ns")) { nodeOrder = node.getOrder();
temp = new NameSpaceNode(newPath); }
temp.setDefaultValue(defaultValue); String rowName = columnName;
temp.setNameSpace(true); if (columnName != null && columnName.contains(":")) {
// temp.setDataType(type); String[] names = columnName.split(":");
current.addChild(temp); rowName = names[0];
} else { columnName = names[1];
temp = this.addElement(current, currentPath, newPath, defaultValue); } else {
// temp.setDataType(type); columnName = null;
if (rootNode == null) { }
rootNode = temp; temp = this.addElement(current, currentPath, newPath, defaultValue, mapNodes);
} if (temp == null) {
if (node.getAttribute().equals("main")) { // should not happen
temp.setMain(true); continue;
mainNode = temp; }
mainPath = newPath; // temp.setDataType(type);
} if (rootNode == null) {
current = temp; rootNode = temp;
currentPath = newPath; }
} if (node.getAttribute().equals("main")) {
if (haveOrder) { temp.setMain(true);
temp.setOrder(nodeOrder); }
} current = temp;
// if (columnName != null && columnName.length() > 0) { currentPath = newPath;
// temp.setColumn(getColumn(columnName)); if (haveOrder) {
// temp.setOrder(nodeOrder);
// } }
temp.setRow(hl7Util.getLabel(obj, true)); if (rowName != null && rowName.length() > 0) {
if (columnName != null && columnName.length() > 0 && columnName.startsWith(schemaId)) { temp.setRow(rowName);
columnName = columnName.replace(schemaId, ""); //$NON-NLS-1$ }
// IMetadataTable iTable = ConvertionHelper.convert((MetadataTable) obj);
// // temp.setColumn(iTable.getColumn(columnName)); if (columnName != null) {
// temp.setTable(iTable); IMetadataTable metadataTable = schemaNameToInputTable.get(rowName);
} // group node can not get the metadata table
} if (metadataTable == null) {
IMetadataTable metadataTableTemp = null;
// build group tree for (IConnection connection : incomingConnections) {
current = mainNode; metadataTableTemp = connection.getMetadataTable();
currentPath = mainPath; String connectionName = metadataTableTemp.getLabel();
boolean isFirst = true; if (connectionName == null) {
connectionName = connection.getUniqueName();
// build loop tree }
current = mainNode; if (columnName.startsWith(connectionName)) {
currentPath = mainPath; break;
isFirst = true; }
}
if (rootNode == null) { temp.setColumnName(columnName);
rootNode = new Element("rootTag"); if (metadataTableTemp != null) {
} temp.setColumn(metadataTableTemp.getColumn(columnName));
// rootNode.setParent(null); temp.setTable(metadataTableTemp);
if (haveOrder) { }
orderNode(rootNode); } else {
} temp.setColumnName(columnName);
list.add(rootNode); temp.setColumn(metadataTable.getColumn(columnName));
rootNode.setRow(hl7Util.getLabel(obj, true)); temp.setTable(metadataTable);
// contents.put(((MetadataTable) obj).getLabel(), rootNode); }
treeNodes.clear(); //
treeNodes.add(rootNode); if (!temp.isMain()) {
if (hl7ui != null) { MetadataColumn newColumn = ConnectionFactory.eINSTANCE.createMetadataColumn();
if (hl7ui.gethl7Manager() instanceof HL7OutputManager) { newColumn.setLabel(columnName);
((HL7OutputManager) hl7ui.gethl7Manager()).getContents().put(hl7Util.getLabel(obj, true), treeNodes); newColumn.setName(temp.getLabel());
} newColumn.setLength(226);
newColumn.setTalendType("id_String");
} else if (form != null) { schemaNameToOutputTable.get(rowName).getColumns().add(newColumn);
for (HL7TreeNode hl7Node : treeNodes) { }
form.getContents().put(hl7Util.getLabel(obj, true), hl7Node); }
} }
} if (rootNode == null) {
} rootNode = new Element("rootTag");
}
// if (haveOrder) { if (haveOrder) {
// orderNode(rootNode); orderNode(rootNode);
// } }
// treeData.add(rootNode); if (rootNode != null) {
// rootNode.setRow(metadataTable.getLabel()); treeData.add(rootNode);
// }
} if (hl7ui != null) {
if (hl7ui.gethl7Manager() instanceof HL7OutputManager) {
private void orderNode(HL7TreeNode node) { ((HL7OutputManager) hl7ui.gethl7Manager()).getContents().put(rootNode.getColumnLabel(), treeData);
// reset the order. }
if (node != null) {
List<HL7TreeNode> firstSubChildren = node.getChildren(); } else if (form != null) {
HL7TreeNode foundNode = null; for (HL7TreeNode hl7Node : treeData) {
for (HL7TreeNode childen : firstSubChildren) { form.getContents().put(rootNode.getColumnLabel(), hl7Node);
if (childen.isRepetable()) { }
foundNode = childen; }
sortOrder(foundNode, node); if (hl7ui != null) {
break; // execute the commands,initialize the propertiesView .
} else if (childen.isGroup()) { List<Command> commands = new ArrayList<Command>();
foundNode = childen; for (MetadataTable tableTemp : iMetadataTables) {
sortOrder(foundNode, node); Command hl7Cmd = new RepositoryChangeMetadataForHL7Command(hl7ui.gethl7Manager().getHl7Component(),
orderNode(childen); IHL7Constant.TABLE_SCHEMAS, tableTemp.getLabel(), ConvertionHelper.convert(tableTemp));
} else { commands.add(hl7Cmd);
orderNode(childen); }
} for (Command command : commands) {
} command.execute();
} }
} }
}
private void sortOrder(HL7TreeNode treeNode, HL7TreeNode node) {
if (node != null) { private void orderNode(HL7TreeNode node) {
List<HL7TreeNode> children = node.getChildren(); // reset the order.
if (treeNode != null) { if (node != null) {
int tmpOrder = 0; List<HL7TreeNode> firstSubChildren = node.getChildren();
int attrNsCount = 0; HL7TreeNode foundNode = null;
for (HL7TreeNode child : children) { for (HL7TreeNode childen : firstSubChildren) {
if (child.getOrder() < treeNode.getOrder()) { if (childen.isRepetable()) {
tmpOrder++; foundNode = childen;
} sortOrder(foundNode, node);
if (child.isAttribute() || child.isNameSpace()) { break;
attrNsCount++; } else if (childen.isGroup()) {
} foundNode = childen;
} sortOrder(foundNode, node);
if (tmpOrder > -1) { orderNode(childen);
int oldOrder = children.indexOf(treeNode); } else {
if (oldOrder != -1 && oldOrder != tmpOrder) { orderNode(childen);
node.removeChild(treeNode); }
if (children.size() > tmpOrder) { }
node.addChild(tmpOrder - attrNsCount, treeNode); }
} else { }
node.addChild(treeNode);
} private void sortOrder(HL7TreeNode treeNode, HL7TreeNode node) {
} if (node != null) {
} List<HL7TreeNode> children = node.getChildren();
} if (treeNode != null) {
} int tmpOrder = 0;
int attrNsCount = 0;
} for (HL7TreeNode child : children) {
if (child.getOrder() < treeNode.getOrder()) {
protected HL7TreeNode addElement(HL7TreeNode current, String currentPath, String newPath, String defaultValue) { tmpOrder++;
String name = newPath.substring(newPath.lastIndexOf("/") + 1); //$NON-NLS-1$ }
String parentPath = newPath.substring(0, newPath.lastIndexOf("/")); //$NON-NLS-1$ if (child.isAttribute() || child.isNameSpace()) {
HL7TreeNode temp = new Element(name, defaultValue); attrNsCount++;
}
if (current == null) {// root node }
return temp; if (tmpOrder > -1) {
} int oldOrder = children.indexOf(treeNode);
if (oldOrder != -1 && oldOrder != tmpOrder) {
if (currentPath.equals(parentPath)) { node.removeChild(treeNode);
current.addChild(temp); if (children.size() > tmpOrder) {
} else { node.addChild(tmpOrder - attrNsCount, treeNode);
String[] nods = currentPath.split("/"); //$NON-NLS-1$ } else {
String[] newNods = parentPath.split("/"); //$NON-NLS-1$ node.addChild(treeNode);
int parentLevel = 0; }
int checkLength = nods.length < newNods.length ? nods.length : newNods.length; }
for (int i = 1; i < checkLength; i++) { }
if (nods[i].equals(newNods[i])) { }
parentLevel = i; }
}
} }
HL7TreeNode parent = current;
for (int i = 0; i < nods.length - (parentLevel + 1); i++) { protected HL7TreeNode addElement(HL7TreeNode current, String currentPath, String newPath, String defaultValue,
HL7TreeNode tmpParent = parent.getParent(); Map<String, HL7TreeNode> mapNodes) {
if (tmpParent == null) { HL7TreeNode temp = mapNodes.get(newPath);
break; if (temp == null) {
} // if node is not existing, create it.
parent = tmpParent; String name = newPath.substring(newPath.lastIndexOf("/") + 1); //$NON-NLS-1$
} temp = new Element(name, defaultValue);
if (current == null) {// root node
if (parent != null) mapNodes.put(newPath, temp);
parent.addChild(temp); return temp;
} }
mapNodes.put(newPath, temp);
return temp; String parentPath = newPath.substring(0, newPath.lastIndexOf("/")); //$NON-NLS-1$
} HL7TreeNode parentNode = mapNodes.get(parentPath);
if (parentNode != null) {
/** parentNode.addChild(temp);
* } else {
* wzhang Comment method "getSelectedSchema". ExceptionHandler.log("Error when parsing the HL7 data, parent not existing for:" + parentPath);
* }
* @return }
*/ return temp;
private String getSelectedSchema() { }
TreeItem[] selection = xmlViewer.getTree().getSelection();
if (selection.length > 0) { /**
Object data = selection[0].getData(); *
if (data instanceof HL7TreeNode) { * wzhang Comment method "getSelectedSchema".
return ((HL7TreeNode) data).getRow(); *
} * @return
} */
return "";// hl7ui.gethl7Manager().getCurrentSchema(); private String getSelectedSchema() {
} TreeItem[] selection = xmlViewer.getTree().getSelection();
if (selection.length > 0) {
public void init() { Object data = selection[0].getData();
this.setEnabled(true); if (data instanceof HL7TreeNode) {
} return ((HL7TreeNode) data).getRow();
}
/* }
* (non-Javadoc) return "";// hl7ui.gethl7Manager().getCurrentSchema();
* }
* @see org.eclipse.jface.action.Action#run()
*/ public void init() {
@Override this.setEnabled(true);
public void run() { }
List<HL7TreeNode> newInput = treeNodeAdapt();
if (newInput.size() == 0) { /*
return; * (non-Javadoc)
} *
List<HL7TreeNode> treeData = null; * @see org.eclipse.jface.action.Action#run()
if (form != null) { */
treeData = form.getTreeData(); @Override
public void run() {
} else if (hl7ui != null) { List<HL7TreeNode> newInput = treeNodeAdapt();
if (hl7ui.gethl7Manager() instanceof HL7OutputManager) { if (newInput.size() == 0) {
treeData = ((HL7OutputManager) hl7ui.gethl7Manager()).getTreeData(); return;
} }
} List<HL7TreeNode> treeData = null;
treeData.clear(); if (form != null) {
treeData.addAll(newInput); treeData = form.getTreeData();
xmlViewer.setInput(treeData);
// TreeUtil.guessAndSetLoopNode((HL7TreeNode) xmlViewer.getTree().getItem(0).getData()); } else if (hl7ui != null) {
xmlViewer.refresh(); if (hl7ui.gethl7Manager() instanceof HL7OutputManager) {
xmlViewer.expandAll(); treeData = ((HL7OutputManager) hl7ui.gethl7Manager()).getTreeData();
// hl7ui.updateStatus(); }
// hl7ui.redrawLinkers(); }
if (hl7ui != null) { treeData.clear();
hl7ui.redrawLinkers(); treeData.addAll(newInput);
} else if (form != null) { xmlViewer.setInput(treeData);
form.refreshLinks(); // TreeUtil.guessAndSetLoopNode((HL7TreeNode) xmlViewer.getTree().getItem(0).getData());
} xmlViewer.refresh();
} xmlViewer.expandAll();
// hl7ui.updateStatus();
/* // hl7ui.redrawLinkers();
* (non-Javadoc) if (hl7ui != null) {
* hl7ui.redrawLinkers();
* @see } else if (form != null) {
* org.eclipse.ui.actions.SelectionProviderAction#selectionChanged(org.eclipse.jface.viewers.IStructuredSelection) form.refreshLinks();
*/ }
@Override }
public void selectionChanged(IStructuredSelection selection) {
this.setEnabled(true); /*
HL7TreeNode node = (HL7TreeNode) this.getStructuredSelection().getFirstElement(); * (non-Javadoc)
if (node != null && form != null) { *
// hl7ui.setSelectedText(node.getLabel()); * @see
// Added by Marvin Wang on Sep. 11, 2012 for bug TDI-20702. * org.eclipse.ui.actions.SelectionProviderAction#selectionChanged(org.eclipse.jface.viewers.IStructuredSelection)
form.setSelectedText(node.getLabel()); */
} @Override
} public void selectionChanged(IStructuredSelection selection) {
this.setEnabled(true);
} HL7TreeNode node = (HL7TreeNode) this.getStructuredSelection().getFirstElement();
if (node != null && form != null) {
// hl7ui.setSelectedText(node.getLabel());
// Added by Marvin Wang on Sep. 11, 2012 for bug TDI-20702.
form.setSelectedText(node.getLabel());
}
}
}

View File

@@ -1,167 +1,113 @@
// ============================================================================ // ============================================================================
// //
// Copyright (C) 2006-2013 Talend Inc. - www.talend.com // Copyright (C) 2006-2014 Talend Inc. - www.talend.com
// //
// This source code is available under agreement available at // This source code is available under agreement available at
// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt // %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt
// //
// You should have received a copy of the agreement // You should have received a copy of the agreement
// along with this program; if not, write to Talend SA // along with this program; if not, write to Talend SA
// 9 rue Pages 92150 Suresnes, France // 9 rue Pages 92150 Suresnes, France
// //
// ============================================================================ // ============================================================================
package org.talend.designer.hl7.action; package org.talend.designer.hl7.action;
import org.eclipse.jface.viewers.TreeViewer; import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.ui.actions.SelectionProviderAction; import org.eclipse.ui.actions.SelectionProviderAction;
import org.talend.designer.hl7.ui.HL7UI; import org.talend.designer.hl7.i18n.Messages;
import org.talend.designer.hl7.ui.data.Attribute; import org.talend.designer.hl7.ui.HL7UI;
import org.talend.designer.hl7.ui.data.Element; import org.talend.designer.hl7.ui.data.Element;
import org.talend.designer.hl7.ui.data.HL7TreeNode; import org.talend.designer.hl7.ui.data.HL7TreeNode;
import org.talend.designer.hl7.ui.data.NameSpaceNode; import org.talend.repository.ui.swt.utils.AbstractForm;
import org.talend.repository.ui.swt.utils.AbstractForm;
/**
/** * bqian Create a xml node. <br/>
* bqian Create a xml node. <br/> *
* * $Id: CreateElementAction.java,v 1.1 2007/06/12 07:20:38 gke Exp $
* $Id: CreateElementAction.java,v 1.1 2007/06/12 07:20:38 gke Exp $ *
* */
*/ public class SetRepetableAction extends SelectionProviderAction {
public class SetRepetableAction extends SelectionProviderAction {
/**
// the xml viewer, see HL7UI. *
private TreeViewer xmlViewer; */
private static final String REMOVE_REPEATABLE = Messages.getString("SetRepetableAction_removeRepeatable"); //$NON-NLS-1$
private HL7UI hl7ui;
/**
private boolean value; *
*/
private AbstractForm form; private static final String SET_AS_REPEATABLE_ELEMENT = Messages.getString("SetRepetableAction_setAsRepeatable"); //$NON-NLS-1$
/** // the xml viewer, see HL7UI.
* SetForLoopAction constructor comment. private TreeViewer xmlViewer;
*
* @param provider public SetRepetableAction(TreeViewer xmlViewer, AbstractForm form) {
* @param text super(xmlViewer, SET_AS_REPEATABLE_ELEMENT);
*/ this.xmlViewer = xmlViewer;
public SetRepetableAction(TreeViewer xmlViewer, String text) { }
super(xmlViewer, text);
this.xmlViewer = xmlViewer; /**
} *
* SetForLoopAction constructor comment.
public SetRepetableAction(TreeViewer xmlViewer, String text, AbstractForm form) { *
super(xmlViewer, text); * @param xmlViewer
this.xmlViewer = xmlViewer; * @param text
this.form = form; * @param hl7ui
} */
public SetRepetableAction(TreeViewer xmlViewer, HL7UI hl7ui, String text, boolean value) {
/** super(xmlViewer, text);
* this.xmlViewer = xmlViewer;
* SetForLoopAction constructor comment. }
*
* @param xmlViewer public void init() {
* @param text setText(SET_AS_REPEATABLE_ELEMENT);
* @param hl7ui HL7TreeNode node = (HL7TreeNode) this.getStructuredSelection().getFirstElement();
*/ if (node == null) {
public SetRepetableAction(TreeViewer xmlViewer, HL7UI hl7ui, String text, boolean value) { this.setEnabled(false);
super(xmlViewer, text); return;
this.xmlViewer = xmlViewer; }
this.hl7ui = hl7ui; if (node.isRepetable()) {
this.value = value; this.setEnabled(true);
} this.setText(REMOVE_REPEATABLE);
return;
public void init() { }
HL7TreeNode node = (HL7TreeNode) this.getStructuredSelection().getFirstElement(); if (node.getLabel().length() != 3) {
if (node == null) { this.setEnabled(false);
this.setEnabled(false); return;
return; }
} this.setEnabled(true);
if (node.getParent() == null) { }
this.setEnabled(false);
return; /*
} * (non-Javadoc)
if (node.getParent().getParent() != null) { *
this.setEnabled(false); * @see org.eclipse.jface.action.Action#run()
return; */
} @Override
if (node.isRepetable()) { public void run() {
this.setEnabled(false); HL7TreeNode node = (HL7TreeNode) this.getStructuredSelection().getFirstElement();
return;
} if (!node.isRepetable()) {
if (!node.isMain()) { if (node.isGroup()) {
this.setEnabled(false); node.setGroup(false);
return; }
} node.setRepetable(true);
node.setMain(true);
if (node instanceof Attribute) { upsetMainNode(node);
this.setEnabled(false); } else {
return; node.setRepetable(false);
} }
xmlViewer.refresh();
if (node instanceof NameSpaceNode) { }
this.setEnabled(false);
return; public void upsetMainNode(HL7TreeNode node) {
} if (node instanceof Element) {
this.setEnabled(true); HL7TreeNode parent = node;
} while (parent != null) {
parent.setMain(true);
/* parent = parent.getParent();
* (non-Javadoc) }
*
* @see org.eclipse.jface.action.Action#run() }
*/ }
@Override }
public void run() {
HL7TreeNode node = (HL7TreeNode) this.getStructuredSelection().getFirstElement();
if (node.isRepetable()) {
return;
}
// HL7Manager hl7Manager = hl7ui.gethl7Manager();
// HL7TreeNode rootTreeData = hl7Manager.getRootHL7TreeNode(node);
// TreeUtil.clearSubGroupNode(node);
// // make sure group element is a ancestor of loop, or no group element.
// if (TreeUtil.findUpGroupNode(node) == null) {
// TreeUtil.clearSubGroupNode(rootTreeData);
// }
// TreeUtil.clearLoopNode(rootTreeData);
// TreeUtil.clearMainNode(rootTreeData);
if (node.isGroup()) {
node.setGroup(false);
}
node.setRepetable(true);
// if (this.value) {
// if (hl7ui != null && node.isGroup()) {
// // hl7ui.updateStatus();
// }
// // TreeUtil.upsetMainNode(node);
// // xmlViewer.refresh();
// } else {
// // if (hl7ui != null) {
// // hl7ui.updateStatus();
// // }
// // upsetMainNode(node);
// // xmlViewer.refresh();
// }
upsetMainNode(node);
xmlViewer.refresh();
if (form != null) {
form.refreshLinks();
}
// this.hl7ui.updateStatus();
}
public void upsetMainNode(HL7TreeNode node) {
if (node instanceof Element) {
HL7TreeNode parent = node;
while (parent != null) {
parent.setMain(true);
parent = parent.getParent();
}
}
}
}

View File

@@ -15,7 +15,11 @@ package org.talend.designer.hl7.model;
import org.talend.core.model.utils.TalendTextUtils; import org.talend.core.model.utils.TalendTextUtils;
import ca.uhn.hl7v2.model.Primitive; import ca.uhn.hl7v2.model.Primitive;
import ca.uhn.hl7v2.model.Type;
/**
* DOC gcui class global comment. Detailled comment
*/
public class PrimitiveModel extends AbstractStructureModel { public class PrimitiveModel extends AbstractStructureModel {
private int componentindex; private int componentindex;
@@ -37,18 +41,24 @@ public class PrimitiveModel extends AbstractStructureModel {
@Override @Override
protected void generateDisplayName() { protected void generateDisplayName() {
String parentName = ""; String parentName = ""; //$NON-NLS-1$
if (parent instanceof TypeModel) { if (parent instanceof TypeModel) {
TypeModel tm = (TypeModel) parent; TypeModel tm = (TypeModel) parent;
String extensionName = tm.getType().getName(); Type type = tm.getType();
String parentDisplayName = tm.getDisplayName(); String parentDisplayName = tm.getDisplayName();
// int extensionIndex = parentDisplayName.indexOf(extensionName); parentName = parentDisplayName;
int extensionIndex = parentDisplayName.lastIndexOf(extensionName);// changed for bug TDI-19467 if (type != null) {
parentName = parentDisplayName.substring(0, extensionIndex - 1); String extensionName = type.getName();
// int extensionIndex = parentDisplayName.indexOf(extensionName);
int extensionIndex = parentDisplayName.lastIndexOf(extensionName);// changed for bug TDI-19467
parentName = parentDisplayName.substring(0, extensionIndex - 1);
}
} }
String typeDispaly = primitive == null ? "" : TalendTextUtils.LBRACKET + this.primitive.getName()
+ TalendTextUtils.RBRACKET;
this.displayName = parentName + "-" + this.componentindex + "-" + this.subcomponentindex + typeDispaly; //$NON-NLS-1$ //$NON-NLS-2$
this.displayName = parentName + "-" + this.componentindex + "-" + this.subcomponentindex + TalendTextUtils.LBRACKET
+ this.primitive.getName() + TalendTextUtils.RBRACKET;
} }
} }

View File

@@ -1,86 +1,140 @@
// ============================================================================ // ============================================================================
// //
// Copyright (C) 2006-2013 Talend Inc. - www.talend.com // Copyright (C) 2006-2014 Talend Inc. - www.talend.com
// //
// This source code is available under agreement available at // This source code is available under agreement available at
// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt // %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt
// //
// You should have received a copy of the agreement // You should have received a copy of the agreement
// along with this program; if not, write to Talend SA // along with this program; if not, write to Talend SA
// 9 rue Pages 92150 Suresnes, France // 9 rue Pages 92150 Suresnes, France
// //
// ============================================================================ // ============================================================================
package org.talend.designer.hl7.model; package org.talend.designer.hl7.model;
import java.util.ArrayList; import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import ca.uhn.hl7v2.HL7Exception; import java.util.ArrayList;
import ca.uhn.hl7v2.model.Segment;
import ca.uhn.hl7v2.model.Structure; import ca.uhn.hl7v2.HL7Exception;
import ca.uhn.hl7v2.model.Type; import ca.uhn.hl7v2.model.Segment;
import ca.uhn.hl7v2.model.Structure;
/** import ca.uhn.hl7v2.model.Type;
* DOC Administrator class global comment. Detailled comment
*/ /**
public class SegmentModel extends AbstractStructureModel { * DOC Administrator class global comment. Detailled comment
*/
private Segment seg; public class SegmentModel extends AbstractStructureModel {
private int folderIndex, subfolderIndex; private Segment seg;
private TypeModel[] types; private int folderIndex, subfolderIndex;
public SegmentModel(Segment seg, Structure parent, int folderIndex, int subfolderIndex) { private TypeModel[] types;
this.seg = seg;
this.parent = parent; public SegmentModel(Segment seg, Structure parent, int folderIndex, int subfolderIndex) {
this.folderIndex = folderIndex; this.seg = seg;
this.subfolderIndex = subfolderIndex; this.parent = parent;
generateDataTypes(); this.folderIndex = folderIndex;
} this.subfolderIndex = subfolderIndex;
generateDataTypes();
protected void generateDisplayName() { }
this.displayName = seg.getName();
} @Override
protected void generateDisplayName() {
private void generateDataTypes() { this.displayName = seg.getName();
int number = this.seg.numFields(); }
ArrayList<TypeModel> datatypes = new ArrayList<TypeModel>();
for (int i = 1; i < number; i++) { private void generateDataTypes() {
try { int number = this.seg.numFields();
Type[] reps = seg.getField(i); ArrayList<TypeModel> datatypes = new ArrayList<TypeModel>();
for (int j = 0; j < reps.length; j++) { Method method = null;
TypeModel tm = new TypeModel(reps[j], seg, j, i); try {
datatypes.add(tm); for (Method curMethod : seg.getClass().getDeclaredMethods()) {
} if (curMethod.getName().equals("createNewTypeWithoutReflection")) {
} catch (HL7Exception e) { method = curMethod;
e.printStackTrace(); method.setAccessible(true);
} break;
} }
this.types = datatypes.toArray(new TypeModel[0]); }
}
if (method != null) {
public TypeModel[] getTypes() { // only access we have to get all the types is reflection (protected method).
return this.types; // so add test of null in case this method doesn't exist, even if it should be in every subclass.
} for (int i = 0; i < number; i++) {
public Segment getSeg() { Type type = (Type) method.invoke(seg, i);
return this.seg; TypeModel tm = new TypeModel(type, seg, 0, i + 1);
} datatypes.add(tm);
}
public int getFolderIndex() { }
return this.folderIndex; } catch (SecurityException e) {
} // TODO Auto-generated catch block
e.printStackTrace();
public int getSubfolderIndex() { } catch (IllegalArgumentException e) {
return this.subfolderIndex; // TODO Auto-generated catch block
} e.printStackTrace();
} catch (IllegalAccessException e) {
@Override // TODO Auto-generated catch block
public boolean equals(Object obj) { e.printStackTrace();
if (obj instanceof SegmentModel) { } catch (InvocationTargetException e) {
return this.getSeg().getName().equals(((SegmentModel) obj).getSeg().getName()); // TODO Auto-generated catch block
} e.printStackTrace();
return super.equals(obj); }
} if (method == null) {
// use old code in case the reflection didn't work.
} // but it means it won't get optional fields.
try {
int lastNotEmptyFiledIndex = 0;
for (int i = 1; i < number; i++) {
Type[] reps = seg.getField(i);
if (reps.length > 0) {
lastNotEmptyFiledIndex = i;
}
}
for (int i = 1; i <= lastNotEmptyFiledIndex; i++) {
Type[] reps = seg.getField(i);
if (reps.length > 0) {
for (int j = 0; j < reps.length; j++) {
TypeModel tm = new TypeModel(reps[j], seg, j, i);
datatypes.add(tm);
}
} else {
// for empty column
TypeModel tm = new TypeModel(null, seg, 0, i);
datatypes.add(tm);
}
}
} catch (HL7Exception e) {
e.printStackTrace();
}
}
this.types = datatypes.toArray(new TypeModel[0]);
}
public TypeModel[] getTypes() {
return this.types;
}
public Segment getSeg() {
return this.seg;
}
public int getFolderIndex() {
return this.folderIndex;
}
public int getSubfolderIndex() {
return this.subfolderIndex;
}
@Override
public boolean equals(Object obj) {
if (obj instanceof SegmentModel) {
return this.getSeg().getName().equals(((SegmentModel) obj).getSeg().getName());
}
return super.equals(obj);
}
}

View File

@@ -1,150 +1,155 @@
// ============================================================================ // ============================================================================
// //
// Copyright (C) 2006-2013 Talend Inc. - www.talend.com // Copyright (C) 2006-2014 Talend Inc. - www.talend.com
// //
// This source code is available under agreement available at // This source code is available under agreement available at
// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt // %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt
// //
// You should have received a copy of the agreement // You should have received a copy of the agreement
// along with this program; if not, write to Talend SA // along with this program; if not, write to Talend SA
// 9 rue Pages 92150 Suresnes, France // 9 rue Pages 92150 Suresnes, France
// //
// ============================================================================ // ============================================================================
package org.talend.designer.hl7.model; package org.talend.designer.hl7.model;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.talend.core.model.utils.TalendTextUtils; import org.talend.core.model.utils.TalendTextUtils;
import ca.uhn.hl7v2.HL7Exception; import ca.uhn.hl7v2.HL7Exception;
import ca.uhn.hl7v2.model.Composite; import ca.uhn.hl7v2.model.Composite;
import ca.uhn.hl7v2.model.DataTypeException; import ca.uhn.hl7v2.model.DataTypeException;
import ca.uhn.hl7v2.model.GenericComposite; import ca.uhn.hl7v2.model.GenericComposite;
import ca.uhn.hl7v2.model.GenericPrimitive; import ca.uhn.hl7v2.model.GenericPrimitive;
import ca.uhn.hl7v2.model.Primitive; import ca.uhn.hl7v2.model.Primitive;
import ca.uhn.hl7v2.model.Structure; import ca.uhn.hl7v2.model.Structure;
import ca.uhn.hl7v2.model.Type; import ca.uhn.hl7v2.model.Type;
import ca.uhn.hl7v2.model.Varies; import ca.uhn.hl7v2.model.Varies;
import ca.uhn.hl7v2.util.Terser; import ca.uhn.hl7v2.util.Terser;
/** /**
* DOC Administrator class global comment. Detailled comment * DOC Administrator class global comment. Detailled comment
*/ */
public class TypeModel extends AbstractStructureModel { public class TypeModel extends AbstractStructureModel {
private Type type; private Type type;
private int index; private int index;
private int rep; private int rep;
private Terser terser; private Terser terser;
private PrimitiveModel[] primitives; private PrimitiveModel[] primitives;
public Type getType() { public Type getType() {
return this.type; return this.type;
} }
public TypeModel(Type type, Structure parent, int rep, int index) { public TypeModel(Type type, Structure parent, int rep, int index) {
this.type = type; this.type = type;
this.parent = parent; this.parent = parent;
this.rep = rep; this.rep = rep;
this.index = index; this.index = index;
generatePrimitive(); generatePrimitive();
} }
protected void generateDisplayName() { @Override
protected void generateDisplayName() {
this.displayName = getParent().getName() + "-" + index + "(" + (++rep) + ")" + TalendTextUtils.LBRACKET + type.getName() //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ String typeDisplay = type == null ? "" : TalendTextUtils.LBRACKET + this.type.getName() + TalendTextUtils.RBRACKET;
+ TalendTextUtils.RBRACKET; this.displayName = getParent().getName() + "-" + index + "(1)" + typeDisplay; //$NON-NLS-1$ //$NON-NLS-2$
}
}
private void generatePrimitive() {
List<PrimitiveModel> pms = new ArrayList<PrimitiveModel>(); private void generatePrimitive() {
int numComp = Terser.numComponents(this.type); if (type != null) {
for (int k = 1; k <= numComp; k++) { List<PrimitiveModel> pms = new ArrayList<PrimitiveModel>();
int numSubComp = Terser.numSubComponents(this.type, k); int numComp = Terser.numComponents(this.type);
for (int m = 1; m <= numSubComp; m++) { for (int k = 1; k <= numComp; k++) {
Primitive p = getPrimitive(this.type, k, m); int numSubComp = Terser.numSubComponents(this.type, k);
if (p.getValue() != null) { for (int m = 1; m <= numSubComp; m++) {
PrimitiveModel pm = new PrimitiveModel(this, p, k, m); Primitive p = getPrimitive(this.type, k, m);
pms.add(pm); PrimitiveModel pm = new PrimitiveModel(this, p, k, m);
} pms.add(pm);
} }
} }
primitives = pms.toArray(new PrimitiveModel[0]); primitives = pms.toArray(new PrimitiveModel[0]);
} } else {
PrimitiveModel pm = new PrimitiveModel(this, null, 1, 1);
public Primitive getPrimitive(Type type, int component, int subcomponent) { primitives = new PrimitiveModel[] { pm };
Type comp = getComponent(type, component); }
Type sub = getComponent(comp, subcomponent); }
return getPrimitive(sub);
} public Primitive getPrimitive(Type type, int component, int subcomponent) {
Type comp = getComponent(type, component);
private int numStandardComponents(Type t) { Type sub = getComponent(comp, subcomponent);
int n = 0; return getPrimitive(sub);
if (Varies.class.isAssignableFrom(t.getClass())) { }
n = numStandardComponents(((Varies) t).getData());
} else if (Composite.class.isAssignableFrom(t.getClass())) { private int numStandardComponents(Type t) {
n = ((Composite) t).getComponents().length; int n = 0;
} else { if (Varies.class.isAssignableFrom(t.getClass())) {
n = 1; n = numStandardComponents(((Varies) t).getData());
} } else if (Composite.class.isAssignableFrom(t.getClass())) {
return n; n = ((Composite) t).getComponents().length;
} } else {
n = 1;
private Type getComponent(Type type, int comp) { }
Type ret = null; return n;
if (Varies.class.isAssignableFrom(type.getClass())) { }
Varies v = (Varies) type;
private Type getComponent(Type type, int comp) {
try { Type ret = null;
if (comp > 1 && GenericPrimitive.class.isAssignableFrom(v.getData().getClass())) if (Varies.class.isAssignableFrom(type.getClass())) {
v.setData(new GenericComposite(v.getMessage())); Varies v = (Varies) type;
} catch (DataTypeException de) {
String message = "Unexpected exception copying data to generic composite: " + de.getMessage(); try {
throw new Error(message); if (comp > 1 && GenericPrimitive.class.isAssignableFrom(v.getData().getClass())) {
} v.setData(new GenericComposite(v.getMessage()));
}
ret = getComponent(v.getData(), comp); } catch (DataTypeException de) {
} else { String message = "Unexpected exception copying data to generic composite: " + de.getMessage();
if (Primitive.class.isAssignableFrom(type.getClass()) && comp == 1) { throw new Error(message);
ret = type; }
} else if (GenericComposite.class.isAssignableFrom(type.getClass())
|| (Composite.class.isAssignableFrom(type.getClass()) && comp <= numStandardComponents(type))) { ret = getComponent(v.getData(), comp);
// note that GenericComposite can return components > number of standard components } else {
if (Primitive.class.isAssignableFrom(type.getClass()) && comp == 1) {
try { ret = type;
ret = ((Composite) type).getComponent(comp - 1); } else if (GenericComposite.class.isAssignableFrom(type.getClass())
} catch (Exception e) { || (Composite.class.isAssignableFrom(type.getClass()) && comp <= numStandardComponents(type))) {
throw new Error("Internal error: HL7Exception thrown on getComponent(x) where x < # standard components.", e); // note that GenericComposite can return components > number of standard components
}
} else { try {
ret = type.getExtraComponents().getComponent(comp - numStandardComponents(type) - 1); ret = ((Composite) type).getComponent(comp - 1);
} } catch (Exception e) {
} throw new Error("Internal error: HL7Exception thrown on getComponent(x) where x < # standard components.", e);
return ret; }
} } else {
ret = type.getExtraComponents().getComponent(comp - numStandardComponents(type) - 1);
private Primitive getPrimitive(Type type) { }
Primitive p = null; }
if (Varies.class.isAssignableFrom(type.getClass())) { return ret;
p = getPrimitive(((Varies) type).getData()); }
} else if (Composite.class.isAssignableFrom(type.getClass())) {
try { private Primitive getPrimitive(Type type) {
p = getPrimitive(((Composite) type).getComponent(0)); Primitive p = null;
} catch (HL7Exception e) { if (Varies.class.isAssignableFrom(type.getClass())) {
throw new Error("Internal error: HL7Exception thrown on Composite.getComponent(0)."); p = getPrimitive(((Varies) type).getData());
} } else if (Composite.class.isAssignableFrom(type.getClass())) {
} else if (type instanceof Primitive) { try {
p = (Primitive) type; p = getPrimitive(((Composite) type).getComponent(0));
} } catch (HL7Exception e) {
return p; throw new Error("Internal error: HL7Exception thrown on Composite.getComponent(0).");
} }
} else if (type instanceof Primitive) {
public PrimitiveModel[] getPrimitives() { p = (Primitive) type;
return this.primitives; }
} return p;
} }
public PrimitiveModel[] getPrimitives() {
return this.primitives;
}
}

View File

@@ -1,390 +1,390 @@
// ============================================================================ // ============================================================================
// //
// Copyright (C) 2006-2013 Talend Inc. - www.talend.com // Copyright (C) 2006-2014 Talend Inc. - www.talend.com
// //
// This source code is available under agreement available at // This source code is available under agreement available at
// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt // %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt
// //
// You should have received a copy of the agreement // You should have received a copy of the agreement
// along with this program; if not, write to Talend SA // along with this program; if not, write to Talend SA
// 9 rue Pages 92150 Suresnes, France // 9 rue Pages 92150 Suresnes, France
// //
// ============================================================================ // ============================================================================
package org.talend.designer.hl7.ui.data; package org.talend.designer.hl7.ui.data;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.talend.core.model.metadata.IMetadataColumn; import org.talend.core.model.metadata.IMetadataColumn;
import org.talend.core.model.metadata.IMetadataTable; import org.talend.core.model.metadata.IMetadataTable;
/** /**
* DOC hwang class global comment. Detailled comment * DOC hwang class global comment. Detailled comment
*/ */
public abstract class HL7TreeNode { public abstract class HL7TreeNode {
private IMetadataTable table = null; private IMetadataTable table = null;
private IMetadataColumn column = null; private IMetadataColumn column = null;
private String row = null; private String row = null;
private String label; private String label;
private String defaultValue; private String defaultValue;
private List<HL7TreeNode> children = null; private List<HL7TreeNode> children = null;
private HL7TreeNode parent = null; private HL7TreeNode parent = null;
private boolean isRepetableNode = false; private boolean isRepetableNode = false;
private boolean isGroupNode = false; private boolean isGroupNode = false;
private boolean isMainNode = false; private boolean isMainNode = false;
private int order; private int order;
private boolean isAttribute = false; private boolean isAttribute = false;
private boolean isNameSpace = false; private boolean isNameSpace = false;
private String columnName = null; private String columnName = null;
public boolean hasLink() { public boolean hasLink() {
return column != null; return column != null;
} }
/** /**
* HL7TreeNode constructor comment. * HL7TreeNode constructor comment.
*/ */
public HL7TreeNode() { public HL7TreeNode() {
children = new ArrayList<HL7TreeNode>(); children = new ArrayList<HL7TreeNode>();
} }
/** /**
* HL7TreeNode constructor comment. * HL7TreeNode constructor comment.
*/ */
public HL7TreeNode(String label) { public HL7TreeNode(String label) {
children = new ArrayList<HL7TreeNode>(); children = new ArrayList<HL7TreeNode>();
this.label = label; this.label = label;
} }
/** /**
* HL7TreeNode constructor comment. * HL7TreeNode constructor comment.
*/ */
public HL7TreeNode(String label, String defaultValue) { public HL7TreeNode(String label, String defaultValue) {
children = new ArrayList<HL7TreeNode>(); children = new ArrayList<HL7TreeNode>();
this.label = label; this.label = label;
this.defaultValue = defaultValue; this.defaultValue = defaultValue;
} }
/** /**
* Getter for children. * Getter for children.
* *
* @return the children * @return the children
*/ */
public List<HL7TreeNode> getChildren() { public List<HL7TreeNode> getChildren() {
return this.children; return this.children;
} }
/** /**
* Getter for parent. * Getter for parent.
* *
* @return the parent * @return the parent
*/ */
public HL7TreeNode getParent() { public HL7TreeNode getParent() {
return this.parent; return this.parent;
} }
/** /**
* Sets the parent. * Sets the parent.
* *
* @param parent the parent to set * @param parent the parent to set
*/ */
public void setParent(HL7TreeNode parent) { public void setParent(HL7TreeNode parent) {
this.parent = parent; this.parent = parent;
} }
/** /**
* DOC ke Comment method "getColumnLabel". * DOC ke Comment method "getColumnLabel".
* *
* @return * @return
*/ */
public String getColumnLabel() { public String getColumnLabel() {
if (column != null) { if (column != null) {
if (getRow() != null) { if (getRow() != null) {
return getRow() + ":" + this.column.getLabel(); //$NON-NLS-1$ return getRow() + ":" + this.column.getLabel(); //$NON-NLS-1$
} }
return this.column.getLabel(); return this.column.getLabel();
} else if (columnName != null) { } else if (columnName != null) {
if (getRow() != null) { if (getRow() != null) {
return getRow() + ":" + this.getColumnName(); return getRow() + ":" + this.getColumnName();
} }
return this.getColumnName(); return this.getColumnName();
} else { } else {
if (getRow() != null) { if (getRow() != null) {
return getRow(); return getRow();
} }
return ""; //$NON-NLS-1$ return ""; //$NON-NLS-1$
} }
// if (column == null) { // if (column == null) {
// if (getRow() != null) { // if (getRow() != null) {
// return getRow(); // return getRow();
// } // }
// return ""; //$NON-NLS-1$ // return ""; //$NON-NLS-1$
// } else { // } else {
// if (getRow() != null) { // if (getRow() != null) {
// return getRow() + ":" + this.column.getLabel(); //$NON-NLS-1$ // return getRow() + ":" + this.column.getLabel(); //$NON-NLS-1$
// } // }
// return this.column.getLabel(); // return this.column.getLabel();
// } // }
} }
/** /**
* Getter for schema. * Getter for schema.
* *
* @return the schema * @return the schema
*/ */
public IMetadataColumn getColumn() { public IMetadataColumn getColumn() {
return column; return column;
} }
/** /**
* Sets the schema. * Sets the schema.
* *
* @param schema the schema to set * @param schema the schema to set
*/ */
public void setColumn(IMetadataColumn column) { public void setColumn(IMetadataColumn column) {
this.column = column; this.column = column;
} }
/** /**
* Getter for value. * Getter for value.
* *
* @return the value * @return the value
*/ */
public String getLabel() { public String getLabel() {
return this.label; return this.label;
} }
/** /**
* Getter for value. * Getter for value.
* *
* @return the value * @return the value
*/ */
public String getLabelForViewer() { public String getLabelForViewer() {
return this.label; return this.label;
} }
/** /**
* Getter for defaultValue. * Getter for defaultValue.
* *
* @return the value * @return the value
*/ */
public String getDefaultValue() { public String getDefaultValue() {
return this.defaultValue; return this.defaultValue;
} }
/** /**
* Sets the defaultValue. * Sets the defaultValue.
* *
* @param value the defaultValue to set * @param value the defaultValue to set
*/ */
public void setDefaultValue(String defaultValue) { public void setDefaultValue(String defaultValue) {
this.defaultValue = defaultValue; this.defaultValue = defaultValue;
} }
/** /**
* Sets the value. * Sets the value.
* *
* @param value the value to set * @param value the value to set
*/ */
public void setLabel(String label) { public void setLabel(String label) {
this.label = label; this.label = label;
} }
/** /**
* DOC ke Comment method "addChild". * DOC ke Comment method "addChild".
* *
* @param child * @param child
*/ */
public void addChild(HL7TreeNode child) { public void addChild(HL7TreeNode child) {
children.add(child); children.add(child);
child.setParent(this); child.setParent(this);
} }
/** /**
* *
* hwang Comment method "addChild". * hwang Comment method "addChild".
* *
* @param index * @param index
* @param child * @param child
*/ */
public void addChild(int index, HL7TreeNode child) { public void addChild(int index, HL7TreeNode child) {
if (index < children.size()) { if (index < children.size()) {
children.add(index, child); children.add(index, child);
} else { } else {
children.add(child); children.add(child);
} }
child.setParent(this); child.setParent(this);
} }
/** /**
* DOC ke Comment method "removeChild". * DOC ke Comment method "removeChild".
* *
* @param child * @param child
*/ */
public void removeChild(HL7TreeNode child) { public void removeChild(HL7TreeNode child) {
children.remove(child); children.remove(child);
child.setParent(null); child.setParent(null);
} }
/** /**
* DOC ke Comment method "hasChildren". * DOC ke Comment method "hasChildren".
* *
* @return * @return
*/ */
public boolean hasChildren() { public boolean hasChildren() {
return children.size() > 0; return children.size() > 0;
} }
public boolean isRepetable() { public boolean isRepetable() {
return this.isRepetableNode; return this.isRepetableNode;
} }
public void setRepetable(boolean b) { public void setRepetable(boolean b) {
this.isRepetableNode = b; this.isRepetableNode = b;
} }
/** /**
* DOC ke Comment method "isGroup". * DOC ke Comment method "isGroup".
* *
* @return * @return
*/ */
public boolean isGroup() { public boolean isGroup() {
return this.isGroupNode; return this.isGroupNode;
} }
/** /**
* DOC ke Comment method "setGroup". * DOC ke Comment method "setGroup".
* *
* @param b * @param b
*/ */
public void setGroup(boolean b) { public void setGroup(boolean b) {
this.isGroupNode = b; this.isGroupNode = b;
} }
/** /**
* Getter for isMainNode. * Getter for isMainNode.
* *
* @return the isMainNode * @return the isMainNode
*/ */
public boolean isMain() { public boolean isMain() {
return this.isMainNode; return this.isMainNode;
} }
/** /**
* Sets the isMainNode. * Sets the isMainNode.
* *
* @param isMainNode the isMainNode to set * @param isMainNode the isMainNode to set
*/ */
public void setMain(boolean isMainNode) { public void setMain(boolean isMainNode) {
this.isMainNode = isMainNode; this.isMainNode = isMainNode;
} }
/** /**
* *
* hwang Comment method "getTable". * hwang Comment method "getTable".
* *
* @return * @return
*/ */
public IMetadataTable getTable() { public IMetadataTable getTable() {
return this.table; return this.table;
} }
/** /**
* *
* hwang Comment method "setTable". * hwang Comment method "setTable".
* *
* @param table * @param table
*/ */
public void setTable(IMetadataTable table) { public void setTable(IMetadataTable table) {
this.table = table; this.table = table;
} }
/** /**
* *
* hwang Comment method "getRow". * hwang Comment method "getRow".
* *
* @return * @return
*/ */
public String getRow() { public String getRow() {
return this.row; return this.row;
} }
/** /**
* *
* hwang Comment method "setRow". * hwang Comment method "setRow".
* *
* @param row * @param row
*/ */
public void setRow(String row) { public void setRow(String row) {
this.row = row; this.row = row;
} }
/** /**
* hwang Comment method "getOrder". * hwang Comment method "getOrder".
* *
* @return * @return
*/ */
public int getOrder() { public int getOrder() {
return this.order; return this.order;
} }
/** /**
* hwang Comment method "setOrder". * hwang Comment method "setOrder".
* *
* @param order * @param order
*/ */
public void setOrder(int order) { public void setOrder(int order) {
this.order = order; this.order = order;
} }
public boolean isAttribute() { public boolean isAttribute() {
return this.isAttribute; return this.isAttribute;
} }
public void setAttribute(boolean isAttribute) { public void setAttribute(boolean isAttribute) {
this.isAttribute = isAttribute; this.isAttribute = isAttribute;
} }
public boolean isNameSpace() { public boolean isNameSpace() {
return this.isNameSpace; return this.isNameSpace;
} }
public void setNameSpace(boolean isNameSpace) { public void setNameSpace(boolean isNameSpace) {
this.isNameSpace = isNameSpace; this.isNameSpace = isNameSpace;
} }
/** /**
* Getter for columnName. * Getter for columnName.
* *
* @return the columnName * @return the columnName
*/ */
public String getColumnName() { public String getColumnName() {
return this.columnName; return this.columnName;
} }
/** /**
* Sets the columnName. * Sets the columnName.
* *
* @param columnName the columnName to set * @param columnName the columnName to set
*/ */
public void setColumnName(String columnName) { public void setColumnName(String columnName) {
this.columnName = columnName; this.columnName = columnName;
} }
} }

View File

@@ -21,6 +21,7 @@ import org.eclipse.swt.widgets.Composite;
import org.talend.core.model.metadata.builder.connection.HL7Connection; import org.talend.core.model.metadata.builder.connection.HL7Connection;
import org.talend.core.model.metadata.builder.connection.MetadataTable; import org.talend.core.model.metadata.builder.connection.MetadataTable;
import org.talend.core.model.properties.ConnectionItem; import org.talend.core.model.properties.ConnectionItem;
import org.talend.core.model.utils.RepositoryManagerHelper;
import org.talend.designer.hl7.ui.data.HL7TreeNode; import org.talend.designer.hl7.ui.data.HL7TreeNode;
import org.talend.repository.ui.swt.utils.AbstractForm; import org.talend.repository.ui.swt.utils.AbstractForm;
import org.talend.repository.ui.utils.FileConnectionContextUtils.EFileParamName; import org.talend.repository.ui.utils.FileConnectionContextUtils.EFileParamName;
@@ -31,6 +32,8 @@ import org.talend.repository.ui.utils.OtherConnectionContextUtils.EParamName;
*/ */
public abstract class AbstractHL7StepForm extends AbstractForm { public abstract class AbstractHL7StepForm extends AbstractForm {
protected int maximumRowsToPreview = RepositoryManagerHelper.getMaximumRowsToPreview();
protected HL7Connection connection; protected HL7Connection connection;
public AbstractHL7StepForm(Composite parent, ConnectionItem connectionItem, String[] existingNames) { public AbstractHL7StepForm(Composite parent, ConnectionItem connectionItem, String[] existingNames) {

View File

@@ -13,7 +13,6 @@
package org.talend.designer.hl7.ui.provider; package org.talend.designer.hl7.ui.provider;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection; import java.util.Collection;
import java.util.List; import java.util.List;
@@ -54,11 +53,9 @@ public class HL7MessageTreeContentProvider implements ITreeContentProvider {
values.add(childReps[j]); values.add(childReps[j]);
} }
if (childReps[j] instanceof Group) { if (childReps[j] instanceof Group) {
values.add(childReps[j]);
allSegmentFromGroup.clear(); allSegmentFromGroup.clear();
getAllSegmentsFromGroup((Group) childReps[j]); getAllSegmentsFromGroup((Group) childReps[j]);
if (allSegmentFromGroup.size() > 0) {
values.addAll(Arrays.asList(allSegmentFromGroup.toArray(new SegmentModel[0])));
}
} }
if (childReps[j] instanceof Segment) { if (childReps[j] instanceof Segment) {
SegmentModel sModel = new SegmentModel((Segment) childReps[j], messParent, i, j); SegmentModel sModel = new SegmentModel((Segment) childReps[j], messParent, i, j);

View File

@@ -62,7 +62,7 @@ public class HL7MessageTreeLabelProvider extends LabelProvider implements ITable
// } // }
if (element instanceof Group) { if (element instanceof Group) {
Group group = (Group) element; Group group = (Group) element;
String groupName = group.getClass().getName(); String groupName = group.getName();
groupName = groupName.substring(groupName.lastIndexOf('.') + 1, groupName.length()); groupName = groupName.substring(groupName.lastIndexOf('.') + 1, groupName.length());
return groupName; return groupName;
} }

View File

@@ -31,6 +31,7 @@ public class WebServiceTreeLabelProvider extends LabelProvider implements ITable
* *
* @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnImage(java.lang.Object, int) * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnImage(java.lang.Object, int)
*/ */
@Override
public Image getColumnImage(Object element, int columnIndex) { public Image getColumnImage(Object element, int columnIndex) {
return null; return null;
} }
@@ -40,6 +41,7 @@ public class WebServiceTreeLabelProvider extends LabelProvider implements ITable
* *
* @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnText(java.lang.Object, int) * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnText(java.lang.Object, int)
*/ */
@Override
public String getColumnText(Object element, int columnIndex) { public String getColumnText(Object element, int columnIndex) {
if (element instanceof ParameterInfo) { if (element instanceof ParameterInfo) {
ParameterInfo para = (ParameterInfo) element; ParameterInfo para = (ParameterInfo) element;
@@ -60,11 +62,6 @@ public class WebServiceTreeLabelProvider extends LabelProvider implements ITable
} else if (columnIndex == 1) { } else if (columnIndex == 1) {
if (para.getArraySize() != 0) { if (para.getArraySize() != 0) {
return para.getIndex() == null ? "*" : para.getIndex(); return para.getIndex() == null ? "*" : para.getIndex();
} else if (para.getParameterInfos().size() > 1) {
String index = para.getIndex() == null ? "*" : para.getIndex();
para.setArraySize(-1);
para.setIndex("*");
return index;
} else { } else {
return null; return null;
} }
@@ -79,6 +76,7 @@ public class WebServiceTreeLabelProvider extends LabelProvider implements ITable
* *
* @see org.eclipse.jface.viewers.ITableColorProvider#getBackground(java.lang.Object, int) * @see org.eclipse.jface.viewers.ITableColorProvider#getBackground(java.lang.Object, int)
*/ */
@Override
public Color getBackground(Object element, int columnIndex) { public Color getBackground(Object element, int columnIndex) {
if (element instanceof ParameterInfo) { if (element instanceof ParameterInfo) {
ParameterInfo para = (ParameterInfo) element; ParameterInfo para = (ParameterInfo) element;
@@ -94,6 +92,7 @@ public class WebServiceTreeLabelProvider extends LabelProvider implements ITable
* *
* @see org.eclipse.jface.viewers.ITableColorProvider#getForeground(java.lang.Object, int) * @see org.eclipse.jface.viewers.ITableColorProvider#getForeground(java.lang.Object, int)
*/ */
@Override
public Color getForeground(Object element, int columnIndex) { public Color getForeground(Object element, int columnIndex) {
if (element instanceof ParameterInfo) { if (element instanceof ParameterInfo) {
ParameterInfo para = (ParameterInfo) element; ParameterInfo para = (ParameterInfo) element;

View File

@@ -2,6 +2,5 @@
<classpath> <classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/> <classpathentry kind="output" path="bin"/>
</classpath> </classpath>

View File

@@ -2,6 +2,5 @@
<classpath> <classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/> <classpathentry kind="output" path="bin"/>
</classpath> </classpath>

View File

@@ -2,6 +2,5 @@
<classpath> <classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/> <classpathentry kind="output" path="bin"/>
</classpath> </classpath>

View File

@@ -3,6 +3,5 @@
<classpathentry exported="true" kind="lib" path="lib/sac-1.3.jar"/> <classpathentry exported="true" kind="lib" path="lib/sac-1.3.jar"/>
<classpathentry exported="true" kind="lib" path="lib/cssparser-0.9.5.jar"/> <classpathentry exported="true" kind="lib" path="lib/cssparser-0.9.5.jar"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/> <classpathentry kind="output" path="bin"/>
</classpath> </classpath>

View File

@@ -3,6 +3,5 @@
<classpathentry exported="true" kind="lib" path="lib/talend_file_enhanced_20070724.jar"/> <classpathentry exported="true" kind="lib" path="lib/talend_file_enhanced_20070724.jar"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/> <classpathentry kind="output" path="bin"/>
</classpath> </classpath>

View File

@@ -2,6 +2,5 @@
<classpath> <classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/> <classpathentry kind="output" path="bin"/>
</classpath> </classpath>

View File

@@ -2,6 +2,5 @@
<classpath> <classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/> <classpathentry kind="output" path="bin"/>
</classpath> </classpath>

View File

@@ -2,6 +2,5 @@
<classpath> <classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/> <classpathentry kind="output" path="bin"/>
</classpath> </classpath>

View File

@@ -5,6 +5,5 @@
<classpathentry exported="true" kind="lib" path="lib/poi-ooxml-schemas-3.9-20121203.jar"/> <classpathentry exported="true" kind="lib" path="lib/poi-ooxml-schemas-3.9-20121203.jar"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="class"/> <classpathentry kind="output" path="class"/>
</classpath> </classpath>

View File

@@ -2,6 +2,5 @@
<classpath> <classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/> <classpathentry kind="output" path="bin"/>
</classpath> </classpath>

View File

@@ -2,6 +2,5 @@
<classpath> <classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/> <classpathentry kind="output" path="bin"/>
</classpath> </classpath>

View File

@@ -2,6 +2,5 @@
<classpath> <classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/> <classpathentry kind="output" path="bin"/>
</classpath> </classpath>

View File

@@ -2,7 +2,6 @@
<classpath> <classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry exported="true" kind="lib" path="lib/hapi-base-1.0.1.jar"/> <classpathentry exported="true" kind="lib" path="lib/hapi-base-1.0.1.jar"/>
<classpathentry exported="true" kind="lib" path="lib/hapi-structures-v21-1.0.1.jar"/> <classpathentry exported="true" kind="lib" path="lib/hapi-structures-v21-1.0.1.jar"/>
<classpathentry exported="true" kind="lib" path="lib/hapi-structures-v22-1.0.1.jar"/> <classpathentry exported="true" kind="lib" path="lib/hapi-structures-v22-1.0.1.jar"/>

View File

@@ -2,6 +2,5 @@
<classpath> <classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/> <classpathentry kind="output" path="bin"/>
</classpath> </classpath>

View File

@@ -3,6 +3,5 @@
<classpathentry exported="true" kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> <classpathentry exported="true" kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry exported="true" kind="con" path="org.eclipse.pde.core.requiredPlugins"/> <classpathentry exported="true" kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry exported="true" kind="lib" path="lib/jboss-serialization.jar"/> <classpathentry exported="true" kind="lib" path="lib/jboss-serialization.jar"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/> <classpathentry kind="output" path="bin"/>
</classpath> </classpath>

View File

@@ -2,6 +2,5 @@
<classpath> <classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/> <classpathentry kind="output" path="bin"/>
</classpath> </classpath>

View File

@@ -2,6 +2,5 @@
<classpath> <classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/> <classpathentry kind="output" path="bin"/>
</classpath> </classpath>

View File

@@ -2,6 +2,5 @@
<classpath> <classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/> <classpathentry kind="output" path="bin"/>
</classpath> </classpath>

View File

@@ -2,6 +2,5 @@
<classpath> <classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/> <classpathentry kind="output" path="bin"/>
</classpath> </classpath>

View File

@@ -2,6 +2,5 @@
<classpath> <classpath>
<classpathentry exported="true" kind="lib" path="lib/ldapjdk.jar"/> <classpathentry exported="true" kind="lib" path="lib/ldapjdk.jar"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/> <classpathentry kind="output" path="bin"/>
</classpath> </classpath>

View File

@@ -2,6 +2,5 @@
<classpath> <classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/> <classpathentry kind="output" path="bin"/>
</classpath> </classpath>

View File

@@ -2,6 +2,5 @@
<classpath> <classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/> <classpathentry kind="output" path="bin"/>
</classpath> </classpath>

View File

@@ -2,6 +2,5 @@
<classpath> <classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/> <classpathentry kind="output" path="bin"/>
</classpath> </classpath>

View File

@@ -4,6 +4,5 @@
<classpathentry exported="true" kind="lib" path="lib/salesforce_enterprise.jar"/> <classpathentry exported="true" kind="lib" path="lib/salesforce_enterprise.jar"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src/main/java"/>
<classpathentry kind="output" path="class"/> <classpathentry kind="output" path="class"/>
</classpath> </classpath>

View File

@@ -2,6 +2,5 @@
<classpath> <classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/> <classpathentry kind="output" path="bin"/>
</classpath> </classpath>

View File

@@ -2,6 +2,5 @@
<classpath> <classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/> <classpathentry kind="output" path="bin"/>
</classpath> </classpath>

View File

@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<classpath> <classpath>
<classpathentry kind="src" path="src"/>
<classpathentry exported="true" kind="lib" path="lib/sequence-library.jar"/> <classpathentry exported="true" kind="lib" path="lib/sequence-library.jar"/>
<classpathentry exported="true" kind="lib" path="lib/svnkit-javahl.jar"/> <classpathentry exported="true" kind="lib" path="lib/svnkit-javahl.jar"/>
<classpathentry exported="true" kind="lib" path="lib/svnkit.jar"/> <classpathentry exported="true" kind="lib" path="lib/svnkit.jar"/>

View File

@@ -3,6 +3,5 @@
<classpathentry exported="true" kind="lib" path="lib/uniserv.jar"/> <classpathentry exported="true" kind="lib" path="lib/uniserv.jar"/>
<classpathentry exported="true" kind="lib" path="lib/talendUniservAPI.jar"/> <classpathentry exported="true" kind="lib" path="lib/talendUniservAPI.jar"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/> <classpathentry kind="output" path="bin"/>
</classpath> </classpath>

View File

@@ -2,6 +2,5 @@
<classpath> <classpath>
<classpathentry exported="true" kind="lib" path="lib/sac-1.3.jar"/> <classpathentry exported="true" kind="lib" path="lib/sac-1.3.jar"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/> <classpathentry kind="output" path="bin"/>
</classpath> </classpath>

View File

@@ -2,6 +2,5 @@
<classpath> <classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/> <classpathentry kind="output" path="bin"/>
</classpath> </classpath>

View File

@@ -81,13 +81,13 @@
<service ref="job"> <service ref="job">
<interfaces> <interfaces>
<value>routines.system.api.TalendJob</value> <value>routines.system.api.TalendJob</value>
</interfaces> </interfaces>
<service-properties> <service-properties>
<entry key="name" value="${endpoint.jobName}" /> <entry key="name" value="${endpoint.jobName}" />
<entry key="type" value="job" /> <entry key="type" value="job" />
</service-properties> </service-properties>
</service> </service>
<!-- Wiring the counter repository --> <!-- Wiring the counter repository -->
<bean class="org.apache.cxf.management.counters.CounterRepository"> <bean class="org.apache.cxf.management.counters.CounterRepository">

View File

@@ -737,6 +737,12 @@ ImportItemUtil.taskMonitor=apply migration task {0} on item {1}
ImportItemUtil.tdqErrorInfor=Can't import tdq item {0} ImportItemUtil.tdqErrorInfor=Can't import tdq item {0}
ImportItemUtil.unknowException=Unknow language: {0} ImportItemUtil.unknowException=Unknow language: {0}
ImportItemUtil.unsupportItem=Can not import the item, Please ensure the items are valid in current product. ImportItemUtil.unsupportItem=Can not import the item, Please ensure the items are valid in current product.
ImportItemUtil.ErrorCreateEmfResource=Load EMF Resource failed.
ImportItemUtil.MissingItemFile=missing item file.
ImportItemUtil.NotHrefCurrentItemFile=original item file has some errors, it has been recovered from file name, please recheck.
ImportItemUtil.MissingItemError={0};Missing '{1}' file!;{2}
ImportItemUtil.LoadEMFResourceError={0};Load EMF Resource failed;{1}
ImportItemWizardPage.0=The 2 following items haves the same ID, please unselect one of them : \n [{0}] [{1}] ImportItemWizardPage.0=The 2 following items haves the same ID, please unselect one of them : \n [{0}] [{1}]
ImportItemWizardPage.ItemsList=Items List ImportItemWizardPage.ItemsList=Items List
ImportItemWizardPage.ImportDescription=Import items from an archive file or directory. ImportItemWizardPage.ImportDescription=Import items from an archive file or directory.
@@ -785,4 +791,11 @@ UseDynamicJobSelectionDialog.downBtnText=Down
RepositoryService.projectNotFound=The project '{0}' is not found. RepositoryService.projectNotFound=The project '{0}' is not found.
RepositoryService.projectReadonlyTitle=Information RepositoryService.projectReadonlyTitle=Information
RepositoryService.projectReadonly=The current login project is readonly. RepositoryService.projectReadonly=The current login project is readonly.
JobScriptsManager.ResourceNotFoundForExport="Resource cannot be found for export: " {0}
ShowErrorsDuringImportItemsDialog_title=Errors during the import items
ShowErrorsDuringImportItemsDialog_exportLogButton_title=Export Log
ShowErrorsDuringImportItemsDialog_exportLogEntry=Export Log Entry
ShowErrorsDuringImportItemsDialog_confirmOverwrite_message = File " {0}" exists. Would you like to overwrite it?

View File

@@ -54,6 +54,7 @@ import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.EObject; import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EPackage; import org.eclipse.emf.ecore.EPackage;
import org.eclipse.emf.ecore.InternalEObject; import org.eclipse.emf.ecore.InternalEObject;
import org.eclipse.emf.ecore.impl.EObjectImpl;
import org.eclipse.emf.ecore.resource.Resource; import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.ResourceSet; import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.ecore.resource.URIConverter; import org.eclipse.emf.ecore.resource.URIConverter;
@@ -641,6 +642,9 @@ public class ImportItemUtil {
final IProgressMonitor monitor) { final IProgressMonitor monitor) {
monitor.subTask(Messages.getString("ImportItemWizardPage.Importing") + itemRecord.getItemName()); //$NON-NLS-1$ monitor.subTask(Messages.getString("ImportItemWizardPage.Importing") + itemRecord.getItemName()); //$NON-NLS-1$
resolveItem(manager, itemRecord); resolveItem(manager, itemRecord);
if (!itemRecord.isValid()) {
return;
}
int num = 0; int num = 0;
for (Object obj : itemRecord.getResourceSet().getResources()) { for (Object obj : itemRecord.getResourceSet().getResources()) {
@@ -1478,6 +1482,20 @@ public class ImportItemUtil {
return null; return null;
} }
/**
* get relative Path of the Item
*/
private IPath getValidItemRelativePath(ResourcesManager resManager, IPath path) {
IPath projectFilePath = getValidProjectFilePath(resManager, path, null);
if (projectFilePath != null) {
// remove the last segments "talend.project"
IPath projectRootPath = projectFilePath.removeLastSegments(1);
// relative to import project
return path.makeRelativeTo(projectRootPath);
}
return null;
}
private ItemRecord computeItemRecord(ResourcesManager collector, IPath path) { private ItemRecord computeItemRecord(ResourcesManager collector, IPath path) {
ItemRecord itemRecord = new ItemRecord(path); ItemRecord itemRecord = new ItemRecord(path);
computeProperty(collector, itemRecord); computeProperty(collector, itemRecord);
@@ -1538,6 +1556,16 @@ public class ImportItemUtil {
final Item item = itemRecord.getItem(); final Item item = itemRecord.getItem();
boolean byteArray = (item instanceof FileItem); boolean byteArray = (item instanceof FileItem);
IPath itemPath = getItemPath(itemRecord.getPath(), item); IPath itemPath = getItemPath(itemRecord.getPath(), item);
IPath itemRelativePath = getValidItemRelativePath(manager, itemPath);
Set<IPath> paths = manager.getPaths();
// check the item file
if (!paths.contains(itemPath)) {
itemRecord.addError(Messages.getString("ImportItemUtil.MissingItemError", itemRecord.getItemName(),
itemPath.lastSegment(), itemRelativePath));
log.error(itemRecord.getItemName()
+ " " + Messages.getString("ImportItemUtil.MissingItemFile") + " - " + itemPath); //$NON-NLS-1$
return;
}
stream = manager.getStream(itemPath); stream = manager.getStream(itemPath);
Resource resource = createResource(itemRecord, itemPath, byteArray); Resource resource = createResource(itemRecord, itemPath, byteArray);
@@ -1563,8 +1591,27 @@ public class ImportItemUtil {
Resource rfResource = createResource(itemRecord, itemPath, true); Resource rfResource = createResource(itemRecord, itemPath, true);
rfResource.load(stream, null); rfResource.load(stream, null);
} }
resetItemReference(itemRecord, resource);
// EcoreUtil.resolveAll(itemRecord.getResourceSet()); Iterator<EObject> itRef = item.eCrossReferences().iterator();
IPath parentPath = itemRecord.getPath().removeLastSegments(1);
while (itRef.hasNext()) {
EObject object = itRef.next();
String linkedFile = EcoreUtil.getURI(object).toFileString();
IPath linkedPath = parentPath.append(linkedFile);
if (!paths.contains(linkedPath)) {
if (linkedFile != null && !linkedFile.equals(itemPath.lastSegment())
&& linkedFile.endsWith(itemPath.getFileExtension())) {
if (object.eIsProxy()) {
// if original href of the item point to some missing item file
// and if we can get the original item file from the name, recover it, but add a warning
((EObjectImpl) object).eSetProxyURI(URI.createFileURI(itemPath.lastSegment()));
log.warn(itemRecord.getItemName()
+ " " + Messages.getString("ImportItemUtil.NotHrefCurrentItemFile") + " - " + itemRecord.getPath()); //$NON-NLS-1$
}
}
}
EcoreUtil.resolve(object, resource);
}
} catch (IOException e) { } catch (IOException e) {
// ignore // ignore
} finally { } finally {

View File

@@ -62,6 +62,7 @@ import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.DirectoryDialog; import org.eclipse.swt.widgets.DirectoryDialog;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.FileDialog; import org.eclipse.swt.widgets.FileDialog;
import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Shell;
@@ -1036,6 +1037,23 @@ class ImportItemWizardPage extends WizardPage {
} catch (InterruptedException e) { } catch (InterruptedException e) {
// //
} finally {
// Check Error Items
final List<String> errors = new ArrayList<String>();
for (ItemRecord itemRecord : checkedItemRecords) {
errors.addAll(itemRecord.getErrors());
}
Display.getDefault().asyncExec(new Runnable() {
@Override
public void run() {
if (!errors.isEmpty()) {
ShowErrorsDuringImportItemsDialog dialog = new ShowErrorsDuringImportItemsDialog(Display.getCurrent()
.getActiveShell(), errors);
dialog.open();
}
}
});
} }
ResourcesManager curManager = this.manager; ResourcesManager curManager = this.manager;
if (curManager instanceof ProviderManager) { if (curManager instanceof ProviderManager) {

View File

@@ -0,0 +1,270 @@
// ============================================================================
//
// Copyright (C) 2006-2013 Talend Inc. - www.talend.com
//
// This source code is available under agreement available at
// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt
//
// You should have received a copy of the agreement
// along with this program; if not, write to Talend SA
// 9 rue Pages 92150 Suresnes, France
//
// ============================================================================
package org.talend.repository.imports;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.Reader;
import java.io.Writer;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Platform;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.SWT;
import org.eclipse.swt.dnd.Clipboard;
import org.eclipse.swt.dnd.TextTransfer;
import org.eclipse.swt.dnd.Transfer;
import org.eclipse.swt.events.KeyEvent;
import org.eclipse.swt.events.KeyListener;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.FileDialog;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Menu;
import org.eclipse.swt.widgets.MenuItem;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.swt.widgets.TableItem;
import org.talend.commons.ui.runtime.image.EImage;
import org.talend.commons.ui.runtime.image.ImageProvider;
import org.talend.repository.i18n.Messages;
/**
* DOC hcyi class global comment. Detailled comment
*/
public class ShowErrorsDuringImportItemsDialog extends Dialog {
public List<String> errors = new ArrayList<String>();
public Table table;
private String fDirectory;
private File fInputFile;
public ShowErrorsDuringImportItemsDialog(Shell shell, List<String> errors) {
super(shell);
this.setShellStyle(this.getShellStyle() | SWT.MIN | SWT.MAX | SWT.RESIZE);
this.errors = errors;
fInputFile = Platform.getLogFileLocation().toFile();
}
@Override
protected void configureShell(Shell newShell) {
super.configureShell(newShell);
newShell.setText(Messages.getString("ShowErrorsDuringImportItemsDialog_title")); //$NON-NLS-1$
newShell.setImage(ImageProvider.getImage(EImage.ERROR_ICON));
}
@Override
protected void createButtonsForButtonBar(Composite parent) {
createButton(parent, IDialogConstants.OK_ID,
Messages.getString("ShowErrorsDuringImportItemsDialog_exportLogButton_title"), true);
createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CLOSE_LABEL, false);
}
@Override
protected void okPressed() {
handleExport(true);
super.okPressed();
}
@Override
protected Control createDialogArea(Composite parent) {
Composite tableComposite = new Composite(parent, SWT.NONE);
tableComposite.setLayout(new GridLayout());
GridData gd = new GridData(GridData.FILL_BOTH);
gd.heightHint = 500;
gd.widthHint = 900;
tableComposite.setLayoutData(gd);
// List Table
table = new Table(tableComposite, SWT.MULTI | SWT.BORDER | SWT.FULL_SELECTION);
table.setLayoutData(new GridData(GridData.FILL_BOTH));
table.setHeaderVisible(true);
table.setLinesVisible(true);
TableColumn itemName = new TableColumn(table, SWT.NONE);
itemName.setText("Item Name"); //$NON-NLS-1$
itemName.setWidth(230);
TableColumn errorLog = new TableColumn(table, SWT.NONE);
errorLog.setText("Error Log"); //$NON-NLS-1$
errorLog.setWidth(330);
TableColumn path = new TableColumn(table, SWT.NONE);
path.setText("Path"); //$NON-NLS-1$
path.setWidth(350);
setMenu(table);
addItemElements(errors);
return parent;
}
//
private void setMenu(final Table table) {
Listener popUpListener = new Listener() {
@Override
public void handleEvent(Event event) {
StringBuffer sbf = new StringBuffer();
for (int i : table.getSelectionIndices()) {
TableItem item = table.getItem(i);
sbf.append(item.getData());
sbf.append("\n");
}
Object[] data = { "" + sbf };
Clipboard clipboard = new Clipboard(Display.getCurrent());
Transfer[] transfers = new Transfer[] { TextTransfer.getInstance() };
clipboard.setContents(data, transfers);
}
};
Menu menu = new Menu(table);
MenuItem copy = new MenuItem(menu, SWT.PUSH);
copy.setText("Copy");
copy.setImage(ImageProvider.getImage(EImage.COPY_ICON));
copy.addListener(SWT.Selection, popUpListener);
table.setMenu(menu);
// add key Listener
table.addKeyListener(new KeyListener() {
@Override
public void keyReleased(KeyEvent arg0) {
}
@Override
public void keyPressed(KeyEvent e) {
if (e.keyCode == 99 && (e.stateMask & SWT.CTRL) != 0) {
StringBuffer sbf = new StringBuffer();
for (int i : table.getSelectionIndices()) {
TableItem item = table.getItem(i);
sbf.append(item.getData());
sbf.append("\n");
}
Object[] data = { "" + sbf };
Clipboard clipboard = new Clipboard(Display.getCurrent());
Transfer[] transfers = new Transfer[] { TextTransfer.getInstance() };
clipboard.setContents(data, transfers);
}
}
});
}
public void addItemElements(List<String> errors) {
table.setRedraw(false);
for (String error : errors) {
if (error != null) {
String[] messages = error.split(";");
if (messages.length != 3) {
continue;
}
TableItem tableItem = new TableItem(table, SWT.NONE);
tableItem.setData(error);
tableItem.setImage(0, ImageProvider.getImage(EImage.ERROR_SMALL));
tableItem.setText(0, messages[0]);
tableItem.setText(1, messages[1]);
tableItem.setText(2, messages[2]);
}
}
table.setRedraw(true);
}
private void handleExport(boolean exportWholeLog) {
FileDialog dialog = new FileDialog(getShell(), SWT.SAVE);
dialog.setFilterExtensions(new String[] { "*.log" }); //$NON-NLS-1$
if (fDirectory != null) {
dialog.setFilterPath(fDirectory);
}
String path = dialog.open();
if (path != null) {
if (path.indexOf('.') == -1 && !path.endsWith(".log")) {
path += ".log"; //$NON-NLS-1$
}
File outputFile = new Path(path).toFile();
fDirectory = outputFile.getParent();
if (outputFile.exists()) {
String message = NLS.bind(Messages.getString("ShowErrorsDuringImportItemsDialog_confirmOverwrite_message"),
outputFile.toString());
if (!MessageDialog.openQuestion(getShell(),
(exportWholeLog ? Messages.getString("ShowErrorsDuringImportItemsDialog_exportLogButton_title")
: Messages.getString("ShowErrorsDuringImportItemsDialog_exportLogEntry")), message)) {
;
}
return;
}
Reader in = null;
Writer out = null;
try {
out = new OutputStreamWriter(new FileOutputStream(outputFile), "UTF-8"); //$NON-NLS-1$
if (exportWholeLog) {
in = new InputStreamReader(new FileInputStream(fInputFile), "UTF-8"); //$NON-NLS-1$
}
copy(in, out);
} catch (IOException ex) {
try {
if (in != null) {
in.close();
}
if (out != null) {
out.close();
}
} catch (IOException e1) { // do nothing
}
}
}
}
private void copy(Reader input, Writer output) {
BufferedReader reader = null;
BufferedWriter writer = null;
try {
reader = new BufferedReader(input);
writer = new BufferedWriter(output);
String line;
while (reader.ready() && ((line = reader.readLine()) != null)) {
writer.write(line);
writer.newLine();
}
} catch (IOException e) { // do nothing
} finally {
try {
if (reader != null) {
reader.close();
}
if (writer != null) {
writer.close();
}
} catch (IOException e1) {
// do nothing
}
}
}
}

View File

@@ -375,7 +375,7 @@ public class RepositoryReviewDialog extends Dialog {
TimeMeasure.step(RepositoryReviewDialog.class.getSimpleName(), "finshed add Filters"); //$NON-NLS-1$ TimeMeasure.step(RepositoryReviewDialog.class.getSimpleName(), "finshed add Filters"); //$NON-NLS-1$
TimeMeasure.step(RepositoryReviewDialog.class.getSimpleName(), "set input"); //$NON-NLS-1$ TimeMeasure.step(RepositoryReviewDialog.class.getSimpleName(), "set input"); //$NON-NLS-1$
repositoryTreeViewer.expandAll(); repositoryTreeViewer.expandToLevel(2);
TimeMeasure.step(RepositoryReviewDialog.class.getSimpleName(), "expandAll"); //$NON-NLS-1$ TimeMeasure.step(RepositoryReviewDialog.class.getSimpleName(), "expandAll"); //$NON-NLS-1$
// see feature 0003664: tRunJob: When opening the tree dialog to select the job target, it could be useful to // see feature 0003664: tRunJob: When opening the tree dialog to select the job target, it could be useful to
@@ -610,7 +610,7 @@ class ViewerTextFilter extends ViewerFilter {
*/ */
class DatabaseTypeFilter extends ViewerFilter { class DatabaseTypeFilter extends ViewerFilter {
private String[] filterItems; private final String[] filterItems;
public DatabaseTypeFilter(String[] filterItems) { public DatabaseTypeFilter(String[] filterItems) {
this.filterItems = filterItems; this.filterItems = filterItems;

View File

@@ -825,22 +825,37 @@ public abstract class JobScriptsManager {
IPath itemFilePath; IPath itemFilePath;
String itemVersionString = (itemVersion == null) ? "" : "_" + itemVersion; String itemVersionString = (itemVersion == null) ? "" : "_" + itemVersion;
if (itemPath.startsWith(typeFolderPath.toString())) {
itemPath = itemPath.substring(typeFolderPath.toString().length());
}
if (item.getFileExtension() == null || "".equals(item.getFileExtension())) { //$NON-NLS-1$ if (item.getFileExtension() == null || "".equals(item.getFileExtension())) { //$NON-NLS-1$
itemFilePath = projectRootPath.append(typeFolderPath).append(itemPath) itemFilePath = projectRootPath.append(typeFolderPath).append(itemPath)
.append(itemName + itemVersionString + "." + FileConstants.ITEM_EXTENSION); //$NON-NLS-1$ //$NON-NLS-2$ .append(itemName + itemVersionString + "." + FileConstants.ITEM_EXTENSION); //$NON-NLS-1$
} else { } else {
itemFilePath = projectRootPath.append(typeFolderPath).append(itemPath) itemFilePath = projectRootPath.append(typeFolderPath).append(itemPath)
.append(itemName + itemVersionString + "." + item.getFileExtension()); //$NON-NLS-1$ //$NON-NLS-2$ .append(itemName + itemVersionString + "." + item.getFileExtension()); //$NON-NLS-1$
} }
IPath propertiesFilePath = projectRootPath.append(typeFolderPath).append(itemPath) IPath propertiesFilePath = projectRootPath.append(typeFolderPath).append(itemPath)
.append(itemName + itemVersionString + "." //$NON-NLS-1$ //$NON-NLS-2$ .append(itemName + itemVersionString + "." //$NON-NLS-1$
+ FileConstants.PROPERTIES_EXTENSION); + FileConstants.PROPERTIES_EXTENSION);
List<URL> metadataNameFileUrls = new ArrayList<URL>(); List<URL> metadataNameFileUrls = new ArrayList<URL>();
metadataNameFileUrls.add(FileLocator.toFileURL(itemFilePath.toFile().toURL())); File itemFile = itemFilePath.toFile();
metadataNameFileUrls.add(FileLocator.toFileURL(propertiesFilePath.toFile().toURL())); if (itemFile.exists()) {
metadataNameFileUrls.add(FileLocator.toFileURL(itemFile.toURI().toURL()));
} else {
ExceptionHandler.log(Messages.getString("JobScriptsManager.ResourceNotFoundForExport", itemFilePath));
}
File propertiesFile = propertiesFilePath.toFile();
if (propertiesFile.exists()) {
metadataNameFileUrls.add(FileLocator.toFileURL(propertiesFile.toURI().toURL()));
} else {
ExceptionHandler.log(Messages.getString("JobScriptsManager.ResourceNotFoundForExport", propertiesFilePath));
}
String basePath = JOB_ITEMS_FOLDER_NAME + PATH_SEPARATOR + projectName + PATH_SEPARATOR String basePath = JOB_ITEMS_FOLDER_NAME + PATH_SEPARATOR + projectName + PATH_SEPARATOR
+ typeFolderPath.toString(); + typeFolderPath.toString();

View File

@@ -12,10 +12,6 @@
// ============================================================================ // ============================================================================
package org.talend.repository.ui.wizards.exportjob.scriptsmanager.esb; package org.talend.repository.ui.wizards.exportjob.scriptsmanager.esb;
import aQute.bnd.osgi.Analyzer;
import aQute.bnd.osgi.FileResource;
import aQute.bnd.osgi.Jar;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.FileOutputStream; import java.io.FileOutputStream;
@@ -87,6 +83,10 @@ import org.talend.repository.ui.wizards.exportjob.scriptsmanager.JobJavaScriptsM
import org.talend.repository.utils.EmfModelUtils; import org.talend.repository.utils.EmfModelUtils;
import org.talend.repository.utils.TemplateProcessor; import org.talend.repository.utils.TemplateProcessor;
import aQute.bnd.osgi.Analyzer;
import aQute.bnd.osgi.FileResource;
import aQute.bnd.osgi.Jar;
/** /**
* DOC ycbai class global comment. Detailled comment * DOC ycbai class global comment. Detailled comment
*/ */
@@ -115,6 +115,9 @@ public class JobJavaScriptOSGIForESBManager extends JobJavaScriptsManager {
private final File classesLocation = new File(getTmpFolder() + File.separator + "classes"); //$NON-NLS-1$; private final File classesLocation = new File(getTmpFolder() + File.separator + "classes"); //$NON-NLS-1$;
//patch for TESB-12909
private boolean isRefJobBycTalendJob = false;
@Override @Override
public List<ExportFileResource> getExportResources(ExportFileResource[] processes, String... codeOptions) public List<ExportFileResource> getExportResources(ExportFileResource[] processes, String... codeOptions)
throws ProcessorException { throws ProcessorException {
@@ -589,6 +592,11 @@ public class JobJavaScriptOSGIForESBManager extends JobJavaScriptsManager {
// job OSGi DataSources // job OSGi DataSources
jobInfo.put("dataSources", DataSourceConfig.getAliases(processItem)); //$NON-NLS-1$ jobInfo.put("dataSources", DataSourceConfig.getAliases(processItem)); //$NON-NLS-1$
//patch for TESB-12909
if(isRefJobBycTalendJob && null != EmfModelUtils.getComponentByName(processItem, "tRouteInput")){
jobInfo.put("name", jobClassName); //$NON-NLS-1$
}
// velocity template context // velocity template context
Map<String, Object> contextParams = new HashMap<String, Object>(); Map<String, Object> contextParams = new HashMap<String, Object>();
contextParams.put("job", jobInfo); //$NON-NLS-1$ contextParams.put("job", jobInfo); //$NON-NLS-1$
@@ -1033,4 +1041,8 @@ public class JobJavaScriptOSGIForESBManager extends JobJavaScriptsManager {
} }
return providedModulesSet; return providedModulesSet;
} }
public void setIsRefJobByCTalendJob(boolean isRefJobBycTalendJob) {
this.isRefJobBycTalendJob = isRefJobBycTalendJob;
}
} }