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("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){
%>
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();
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[]{
<%
for(IMetadataColumn column:columnList){
@@ -154,6 +144,9 @@ if(("false").equals(useExistingConn)){
}
%>
});
<%
}
%>
searchCtls_<%=cid%>.setTimeLimit(<%=timeout%>*1000);
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){%>
// Set the page size and initialize the cookie that we pass back in subsequent pages
int pageSize_<%=cid%> = <%=pageSize %>;
@@ -190,6 +262,17 @@ if(("false").equals(useExistingConn)){
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%>);
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%>;
<%
}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()%>");
if(attr_<%=column.getLabel()%>_<%=cid%> != null){
@@ -297,6 +403,7 @@ do {
}
<%
}
}
}
}//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.DatabaseConnection;
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.MetadataTable;
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)) {
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) {

View File

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

View File

@@ -1260,7 +1260,7 @@ public class TalendEditorDropTargetListener extends TemplateTransferDropTargetLi
// fore HL7, by gcui
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,
table.getLabel(), ConvertionHelper.convert(table));
list.add(hl7Cmd);

View File

@@ -57,6 +57,7 @@ import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.PlatformUI;
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.SystemException;
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.runprocess.IRunProcessService;
import org.talend.repository.ProjectManager;
import org.talend.repository.RepositoryWorkUnit;
import org.talend.repository.model.IProxyRepositoryFactory;
import org.talend.repository.model.IRepositoryService;
import org.talend.repository.ui.views.IRepositoryView;
@@ -245,9 +247,11 @@ public class WSDL2JAVAController extends AbstractElementPropertySectionControlle
*/
private void generateJavaFile() {
final IWorkspaceRunnable op = new IWorkspaceRunnable() {
final IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
RepositoryWorkUnit<Object> workUnit = new RepositoryWorkUnit<Object>("", this) {//$NON-NLS-1$
public void run(IProgressMonitor monitor) throws CoreException {
@Override
protected void run() throws PersistenceException {
Node node = (Node) elem;
IProcess process = node.getProcess();
@@ -382,30 +386,9 @@ public class WSDL2JAVAController extends AbstractElementPropertySectionControlle
// }
FilesUtils.removeFolder(dir, true);
}
};
IRunnableWithProgress iRunnableWithProgress = new IRunnableWithProgress() {
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);
}
workUnit.setAvoidUnloadResources(true);
factory.executeRepositoryWorkUnit(workUnit);
}
private void refreshProject() {

View File

@@ -225,30 +225,6 @@ public class PropertiesTableEditorView<B> extends AbstractDataTableEditorView<B>
} else {
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;
};

View File

@@ -23,6 +23,10 @@ Bundle-Vendor: .Talend SA.
Bundle-ClassPath: .
Export-Package: org.talend.designer.hl7,
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.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.RootElementError.Title=Error
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,6 +1,6 @@
// ============================================================================
//
// 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
// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt
@@ -29,6 +29,7 @@ import org.talend.core.model.process.EParameterFieldType;
import org.talend.core.model.process.IComponentDocumentation;
import org.talend.core.model.process.IElementParameter;
import org.talend.core.model.process.IExternalData;
import org.talend.core.model.process.INode;
/**
* DOC Administrator class global comment. Detailled comment
@@ -63,6 +64,7 @@ public class HL7InputComponent extends AbstractExternalNode {
return null;
}
@Override
public IExternalData getExternalData() {
return null;
}
@@ -102,26 +104,24 @@ public class HL7InputComponent extends AbstractExternalNode {
}
public void renameInputConnection(String oldName, String newName) {
List<Map<String, String>> listRoot = (List<Map<String, String>>) this.getElementParameter(ROOT).getValue();
boolean flagRoot = false;
String schemaId = oldName + ":";
INode node = getOriginalNode();
if (oldName != null) {
IElementParameter elementParameter = this.getElementParameter("SCHEMAS");
if (elementParameter != null) {
Object listItemsValue = elementParameter.getValue();
if (listItemsValue instanceof List) {
for (Object obj : (List) listItemsValue) {
if (obj instanceof Map) {
Object row = ((Map) obj).get("PARENT_ROW");
if (oldName.equals(row)) {
((Map) obj).put("PARENT_ROW", newName);
}
for (Map<String, String> map : listRoot) {
String rowName = map.get(COLUMN);
if (rowName == null) {
continue;
}
}
}
}
if (rowName.equals(oldName)) {
map.put(COLUMN, newName);
flagRoot = true;
} else if (rowName.startsWith(schemaId)) {
rowName = newName + rowName.substring(rowName.indexOf(":"));
map.put(COLUMN, rowName);
flagRoot = true;
}
}
if (flagRoot) {
this.getElementParameter(ROOT).setValue(listRoot);
}
}
@@ -141,7 +141,7 @@ public class HL7InputComponent extends AbstractExternalNode {
}
}
@SuppressWarnings("unchecked")//$NON-NLS-1$
@SuppressWarnings("unchecked")
public List<Map<String, String>> getTableList(String paraName) {
List<Map<String, String>> list = new ArrayList<Map<String, String>>();
List<IElementParameter> eps = (List<IElementParameter>) this.getElementParameters();
@@ -159,14 +159,14 @@ public class HL7InputComponent extends AbstractExternalNode {
}
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() {
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) {
List<IElementParameter> eps = (List<IElementParameter>) this.getElementParameters();
boolean result = true;
@@ -190,7 +190,7 @@ public class HL7InputComponent extends AbstractExternalNode {
}
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) {
parameter.setValue(value);
}

View File

@@ -1,6 +1,6 @@
// ============================================================================
//
// 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
// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt
@@ -12,10 +12,18 @@
// ============================================================================
package org.talend.designer.hl7.action;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.eclipse.jface.dialogs.IInputValidator;
import org.eclipse.jface.dialogs.InputDialog;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.ui.actions.SelectionProviderAction;
import org.talend.core.model.metadata.IMetadataTable;
import org.talend.core.model.metadata.MetadataTable;
import org.talend.designer.hl7.managers.HL7OutputManager;
import org.talend.designer.hl7.ui.HL7UI;
import org.talend.designer.hl7.ui.data.Attribute;
import org.talend.designer.hl7.ui.data.Element;
@@ -93,13 +101,7 @@ public class CreateHL7ElementAction extends SelectionProviderAction {
@Override
public void run() {
HL7TreeNode node = (HL7TreeNode) this.getStructuredSelection().getFirstElement();
if (createChildNode(node)) {
if (hl7ui != null) {
hl7ui.redrawLinkers();
} else if (from != null) {
from.refreshLinks();
}
}
createChildNode(node);
}
/**
@@ -107,9 +109,11 @@ public class CreateHL7ElementAction extends SelectionProviderAction {
*
* @param node
*/
private boolean createChildNode(HL7TreeNode node) {
private boolean createChildNode(final HL7TreeNode node) {
if (node.getColumn() != null) {
if (!MessageDialog.openConfirm(xmlViewer.getControl().getShell(), "Warning",
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.getLabel() + "\"?")) {
return false;
@@ -119,8 +123,23 @@ public class CreateHL7ElementAction extends SelectionProviderAction {
String label = "";
final String nodeLabel = node.getLabel() + "-";
while (!StringUtil.validateLabelForXML(label)) {
// add validator
IInputValidator validator = new IInputValidator() {
public String isValid(String newText) {
if (newText != null) {
String text = newText.trim();
for (HL7TreeNode children : node.getChildren()) {
if (text.equals(children.getLabel())) {
return "The name already existed."; //$NON-NLS-1$
}
}
}
return null;
}
};
InputDialog dialog = new InputDialog(null, "Input element's label", "Input the new element's valid label", nodeLabel,
null) {
validator) {
/*
* (non-Javadoc)
@@ -129,13 +148,7 @@ public class CreateHL7ElementAction extends SelectionProviderAction {
*/
@Override
protected void okPressed() {
String eleName = this.getValue();
// if (eleName.startsWith(nodeLabel)) {
super.okPressed();
// } else {
// setErrorMessage("Element's label must start with " + "\"" + nodeLabel + "\"");
// }
}
};
@@ -149,10 +162,46 @@ public class CreateHL7ElementAction extends SelectionProviderAction {
}
}
HL7TreeNode child = new Element(label);
child.setRow(node.getRow());
// 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();
this.xmlViewer.expandAll();
return true;
}
}

View File

@@ -1,6 +1,6 @@
// ============================================================================
//
// 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
// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt
@@ -17,10 +17,8 @@ import java.util.List;
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.ui.actions.SelectionProviderAction;
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.HL7TreeNode;
import org.talend.designer.hl7.ui.data.NameSpaceNode;
import org.talend.repository.ui.swt.utils.AbstractForm;
/**
@@ -94,19 +92,7 @@ public class DeleteHL7NodeAction extends SelectionProviderAction {
disconnectSubTree(node);
}
parent.removeChild(node);
// if (TreeUtil.refreshTree((HL7TreeNode) xmlViewer.getTree().getItem(0).getData())) {
// xmlViewer.refresh();
// }
if (node.isRepetable() || node.isGroup()) {
// hl7ui.updateStatus();
}
xmlViewer.refresh(parent);
xmlViewer.expandAll();
if (hl7ui != null) {
hl7ui.redrawLinkers();
} else if (form != null) {
form.refreshLinks();
}
}
/**
@@ -121,12 +107,6 @@ public class DeleteHL7NodeAction extends SelectionProviderAction {
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,6 +1,6 @@
// ============================================================================
//
// 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
// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt
@@ -18,22 +18,34 @@ import java.util.List;
import java.util.Map;
import org.eclipse.emf.common.util.EList;
import org.eclipse.gef.commands.Command;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.swt.widgets.FileDialog;
import org.eclipse.swt.widgets.TreeItem;
import org.eclipse.ui.actions.SelectionProviderAction;
import org.talend.commons.exception.ExceptionHandler;
import org.talend.core.model.metadata.IHL7Constant;
import org.talend.core.model.metadata.IMetadataTable;
import org.talend.core.model.metadata.builder.ConvertionHelper;
import org.talend.core.model.metadata.builder.connection.ConnectionFactory;
import org.talend.core.model.metadata.builder.connection.HL7Connection;
import org.talend.core.model.metadata.builder.connection.HL7FileNode;
import org.talend.core.model.metadata.builder.connection.MetadataColumn;
import org.talend.core.model.metadata.builder.connection.MetadataTable;
import org.talend.core.model.process.IConnection;
import org.talend.core.model.process.IConnectionCategory;
import org.talend.core.model.utils.NodeUtil;
import org.talend.core.runtime.CoreRuntimePlugin;
import org.talend.core.ui.metadata.command.RepositoryChangeMetadataForHL7Command;
import org.talend.designer.hl7.managers.HL7OutputManager;
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.HL7TreeNode;
import org.talend.designer.hl7.ui.data.NameSpaceNode;
import org.talend.designer.hl7.ui.form.AbstractHL7StepForm;
import org.talend.designer.hl7.ui.header.HL7Parse;
import org.talend.designer.hl7.util.HL7PublicUtil;
import org.talend.repository.model.IProxyRepositoryFactory;
import ca.uhn.hl7v2.model.Message;
@@ -48,8 +60,6 @@ public class ImportHL7StructureAction extends SelectionProviderAction {
private AbstractHL7StepForm form;
private int order = 1;
private HL7Connection hl7Connection;
private HL7PublicUtil hl7Util = new HL7PublicUtil();
@@ -76,7 +86,7 @@ public class ImportHL7StructureAction extends SelectionProviderAction {
}
private List treeNodeAdapt() {
List<HL7TreeNode> list = new ArrayList<HL7TreeNode>();
List<HL7TreeNode> treeData = new ArrayList<HL7TreeNode>();
FileDialog f = null;
if (hl7ui != null) {
f = new FileDialog(hl7ui.getHl7UIParent().getShell());
@@ -85,7 +95,7 @@ public class ImportHL7StructureAction extends SelectionProviderAction {
}
String file = f.open();
if (file == null) {
return list;
return treeData;
}
HL7Parse hl7Parse = new HL7Parse();
List<String> msgContentList = new ArrayList<String>();
@@ -93,14 +103,6 @@ public class ImportHL7StructureAction extends SelectionProviderAction {
List<Message> messageList = hl7Parse.doParse(file, "'\\u000b'", "'\\u001c'");
List<HL7TreeNode> nodeList = hl7Util.getHL7TreeNodes(messageList);
List schemaList = new ArrayList();
for (Message message : messageList) {
schemaList.addAll(hl7Util.getFirstLevelChild(message));
}
// for (Object obj : schemaList) {
//
// }
if (!nodeList.isEmpty()) {
HL7TreeNode hl7TreeNode = nodeList.get(0);
List<HL7FileNode> table = new ArrayList<HL7FileNode>();
@@ -108,161 +110,181 @@ public class ImportHL7StructureAction extends SelectionProviderAction {
EList root = hl7Connection.getRoot();
root.clear();
if (hl7TreeNode != null) {
hl7Util.initNodeOrder(hl7TreeNode, orderMap, order);
hl7Util.initNodeOrder(hl7TreeNode, orderMap);
hl7Util.tableLoader((Element) hl7TreeNode, "", root, hl7TreeNode.getDefaultValue(), orderMap);
}
table.addAll(root);
} else {
if (hl7TreeNode != null) {
hl7Util.initNodeOrder(hl7TreeNode, orderMap, order);
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) {
String columnName = node.getRelatedColumn();
if (columnName.contains(":")) {
columnName = columnName.substring(0, columnName.indexOf(":"));
}
if (!schemaList.contains(columnName) && !"".equals(columnName)) {
schemaList.add(columnName);
}
}
initXmlTreeData(schemaList, table, treeData);
}
// try {
// ATreeNode treeNode = SchemaPopulationUtil.getSchemaTree(file, true, 0);
// String schemaName = getSelectedSchema();
// HL7TreeNode root = cloneATreeNode(treeNode, schemaName);
// root = ((Element) root).getElementChildren().get(0);
// root.setParent(null);
// list.add(root);
// } catch (Exception e) {
// // e.printStackTrace();
// ExceptionHandler.process(e);
// }
return list;
return treeData;
}
private void initXmlTreeData(List schemaList, List<HL7FileNode> root, List<HL7TreeNode> list) {
private void initXmlTreeData(List<String> schemaList, List<HL7FileNode> root, List<HL7TreeNode> treeData) {
Map<String, HL7TreeNode> mapNodes = new HashMap<String, HL7TreeNode>();
List<? extends IConnection> incomingConnections = new ArrayList<IConnection>();
if (hl7ui != null) {
if (hl7ui.gethl7Manager() instanceof HL7OutputManager) {
((HL7OutputManager) hl7ui.gethl7Manager()).getContents().clear();
incomingConnections = NodeUtil.getIncomingConnections(hl7ui.gethl7Manager().getHl7Component(),
IConnectionCategory.FLOW);
}
}
for (Object obj : schemaList) {
List<HL7TreeNode> treeNodes = null;
HL7TreeNode rootNode = null;
HL7TreeNode current = null;
HL7TreeNode temp = null;
HL7TreeNode mainNode = null;
String mainPath = null;
String currentPath = null;
String defaultValue = null;
int nodeOrder = 0;
boolean haveOrder = true;
String schemaId = hl7Util.getLabel(obj, true) + ":";//((MetadataTable) obj).getLabel() + ":"; //$NON-NLS-1$
if (hl7ui != null) {
if (hl7ui.gethl7Manager() instanceof HL7OutputManager) {
treeNodes = ((HL7OutputManager) hl7ui.gethl7Manager()).getTreeData(hl7Util.getLabel(obj, true));
}
}
if (treeNodes == null) {
treeNodes = new ArrayList<HL7TreeNode>();
}
// build root tree
for (int i = 0; i < root.size(); i++) {
HL7FileNode node = (HL7FileNode) root.get(i);
String newPath = node.getFilePath();
defaultValue = node.getDefaultValue();
String columnName = node.getRelatedColumn();
// String type = node.getType();
String orderValue = String.valueOf(node.getOrder());
if (orderValue == null || "".equals(orderValue)) {
haveOrder = false;
}
if (haveOrder) {
nodeOrder = node.getOrder();
}
String flag = columnName + ":"; //$NON-NLS-1$
if (columnName != null && columnName.length() > 0 && !flag.startsWith(schemaId)) {
continue;
}
if (node.getAttribute().equals("attri")) {
temp = new Attribute(newPath);
temp.setDefaultValue(defaultValue);
temp.setAttribute(true);
// temp.setDataType(type);
current.addChild(temp);
} else if (node.getAttribute().equals("ns")) {
temp = new NameSpaceNode(newPath);
temp.setDefaultValue(defaultValue);
temp.setNameSpace(true);
// temp.setDataType(type);
current.addChild(temp);
} else {
temp = this.addElement(current, currentPath, newPath, defaultValue);
// temp.setDataType(type);
if (rootNode == null) {
rootNode = temp;
}
if (node.getAttribute().equals("main")) {
temp.setMain(true);
mainNode = temp;
mainPath = newPath;
}
current = temp;
currentPath = newPath;
}
if (haveOrder) {
temp.setOrder(nodeOrder);
}
// if (columnName != null && columnName.length() > 0) {
// temp.setColumn(getColumn(columnName));
//
// }
temp.setRow(hl7Util.getLabel(obj, true));
if (columnName != null && columnName.length() > 0 && columnName.startsWith(schemaId)) {
columnName = columnName.replace(schemaId, ""); //$NON-NLS-1$
// IMetadataTable iTable = ConvertionHelper.convert((MetadataTable) obj);
// // temp.setColumn(iTable.getColumn(columnName));
// temp.setTable(iTable);
IProxyRepositoryFactory factory = CoreRuntimePlugin.getInstance().getProxyRepositoryFactory();
List<MetadataTable> iMetadataTables = new ArrayList<MetadataTable>();
HL7TreeNode rootNode = null;
Map<String, IMetadataTable> schemaNameToInputTable = new HashMap<String, IMetadataTable>();
Map<String, MetadataTable> schemaNameToOutputTable = new HashMap<String, MetadataTable>();
for (String schemaName : schemaList) {
IMetadataTable metadataTable = null;
for (IConnection connection : incomingConnections) {
if (connection.getUniqueName().equals(schemaName)) {
metadataTable = connection.getMetadataTable();
metadataTable.setLabel(connection.getUniqueName());
schemaNameToInputTable.put(schemaName, metadataTable);
break;
}
}
// build group tree
current = mainNode;
currentPath = mainPath;
boolean isFirst = true;
MetadataTable targetMetadataTable = ConnectionFactory.eINSTANCE.createMetadataTable();
targetMetadataTable.setId(factory.getNextId());
schemaNameToOutputTable.put(schemaName, targetMetadataTable);
targetMetadataTable.setLabel(schemaName);
iMetadataTables.add(targetMetadataTable);
}
// build loop tree
current = mainNode;
currentPath = mainPath;
isFirst = true;
if (rootNode == null) {
rootNode = new Element("rootTag");
HL7TreeNode current = null;
HL7TreeNode temp = null;
String currentPath = null;
String defaultValue = null;
int nodeOrder = 0;
boolean haveOrder = true;
// build root tree
for (int i = 0; i < root.size(); i++) {
HL7FileNode node = root.get(i);
String newPath = node.getFilePath();
defaultValue = node.getDefaultValue();
String columnName = node.getRelatedColumn();
// String type = node.getType();
String orderValue = String.valueOf(node.getOrder());
if (orderValue == null || "".equals(orderValue)) {
haveOrder = false;
}
// rootNode.setParent(null);
if (haveOrder) {
orderNode(rootNode);
nodeOrder = node.getOrder();
}
String rowName = columnName;
if (columnName != null && columnName.contains(":")) {
String[] names = columnName.split(":");
rowName = names[0];
columnName = names[1];
} else {
columnName = null;
}
temp = this.addElement(current, currentPath, newPath, defaultValue, mapNodes);
if (temp == null) {
// should not happen
continue;
}
// temp.setDataType(type);
if (rootNode == null) {
rootNode = temp;
}
if (node.getAttribute().equals("main")) {
temp.setMain(true);
}
current = temp;
currentPath = newPath;
if (haveOrder) {
temp.setOrder(nodeOrder);
}
if (rowName != null && rowName.length() > 0) {
temp.setRow(rowName);
}
list.add(rootNode);
rootNode.setRow(hl7Util.getLabel(obj, true));
// contents.put(((MetadataTable) obj).getLabel(), rootNode);
treeNodes.clear();
treeNodes.add(rootNode);
if (hl7ui != null) {
if (hl7ui.gethl7Manager() instanceof HL7OutputManager) {
((HL7OutputManager) hl7ui.gethl7Manager()).getContents().put(hl7Util.getLabel(obj, true), treeNodes);
}
} else if (form != null) {
for (HL7TreeNode hl7Node : treeNodes) {
form.getContents().put(hl7Util.getLabel(obj, true), hl7Node);
if (columnName != null) {
IMetadataTable metadataTable = schemaNameToInputTable.get(rowName);
// group node can not get the metadata table
if (metadataTable == null) {
IMetadataTable metadataTableTemp = null;
for (IConnection connection : incomingConnections) {
metadataTableTemp = connection.getMetadataTable();
String connectionName = metadataTableTemp.getLabel();
if (connectionName == null) {
connectionName = connection.getUniqueName();
}
if (columnName.startsWith(connectionName)) {
break;
}
}
temp.setColumnName(columnName);
if (metadataTableTemp != null) {
temp.setColumn(metadataTableTemp.getColumn(columnName));
temp.setTable(metadataTableTemp);
}
} else {
temp.setColumnName(columnName);
temp.setColumn(metadataTable.getColumn(columnName));
temp.setTable(metadataTable);
}
//
if (!temp.isMain()) {
MetadataColumn newColumn = ConnectionFactory.eINSTANCE.createMetadataColumn();
newColumn.setLabel(columnName);
newColumn.setName(temp.getLabel());
newColumn.setLength(226);
newColumn.setTalendType("id_String");
schemaNameToOutputTable.get(rowName).getColumns().add(newColumn);
}
}
}
if (rootNode == null) {
rootNode = new Element("rootTag");
}
if (haveOrder) {
orderNode(rootNode);
}
if (rootNode != null) {
treeData.add(rootNode);
}
if (hl7ui != null) {
if (hl7ui.gethl7Manager() instanceof HL7OutputManager) {
((HL7OutputManager) hl7ui.gethl7Manager()).getContents().put(rootNode.getColumnLabel(), treeData);
}
// if (haveOrder) {
// orderNode(rootNode);
// }
// treeData.add(rootNode);
// rootNode.setRow(metadataTable.getLabel());
//
} else if (form != null) {
for (HL7TreeNode hl7Node : treeData) {
form.getContents().put(rootNode.getColumnLabel(), hl7Node);
}
}
if (hl7ui != null) {
// execute the commands,initialize the propertiesView .
List<Command> commands = new ArrayList<Command>();
for (MetadataTable tableTemp : iMetadataTables) {
Command hl7Cmd = new RepositoryChangeMetadataForHL7Command(hl7ui.gethl7Manager().getHl7Component(),
IHL7Constant.TABLE_SCHEMAS, tableTemp.getLabel(), ConvertionHelper.convert(tableTemp));
commands.add(hl7Cmd);
}
for (Command command : commands) {
command.execute();
}
}
}
private void orderNode(HL7TreeNode node) {
@@ -316,40 +338,26 @@ public class ImportHL7StructureAction extends SelectionProviderAction {
}
protected HL7TreeNode addElement(HL7TreeNode current, String currentPath, String newPath, String defaultValue) {
String name = newPath.substring(newPath.lastIndexOf("/") + 1); //$NON-NLS-1$
String parentPath = newPath.substring(0, newPath.lastIndexOf("/")); //$NON-NLS-1$
HL7TreeNode temp = new Element(name, defaultValue);
if (current == null) {// root node
return temp;
}
if (currentPath.equals(parentPath)) {
current.addChild(temp);
} else {
String[] nods = currentPath.split("/"); //$NON-NLS-1$
String[] newNods = parentPath.split("/"); //$NON-NLS-1$
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;
}
protected HL7TreeNode addElement(HL7TreeNode current, String currentPath, String newPath, String defaultValue,
Map<String, HL7TreeNode> mapNodes) {
HL7TreeNode temp = mapNodes.get(newPath);
if (temp == null) {
// if node is not existing, create it.
String name = newPath.substring(newPath.lastIndexOf("/") + 1); //$NON-NLS-1$
temp = new Element(name, defaultValue);
if (current == null) {// root node
mapNodes.put(newPath, temp);
return temp;
}
HL7TreeNode parent = current;
for (int i = 0; i < nods.length - (parentLevel + 1); i++) {
HL7TreeNode tmpParent = parent.getParent();
if (tmpParent == null) {
break;
}
parent = tmpParent;
mapNodes.put(newPath, temp);
String parentPath = newPath.substring(0, newPath.lastIndexOf("/")); //$NON-NLS-1$
HL7TreeNode parentNode = mapNodes.get(parentPath);
if (parentNode != null) {
parentNode.addChild(temp);
} else {
ExceptionHandler.log("Error when parsing the HL7 data, parent not existing for:" + parentPath);
}
if (parent != null)
parent.addChild(temp);
}
return temp;
}

View File

@@ -1,6 +1,6 @@
// ============================================================================
//
// 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
// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt
@@ -14,11 +14,10 @@ package org.talend.designer.hl7.action;
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.ui.actions.SelectionProviderAction;
import org.talend.designer.hl7.i18n.Messages;
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.HL7TreeNode;
import org.talend.designer.hl7.ui.data.NameSpaceNode;
import org.talend.repository.ui.swt.utils.AbstractForm;
/**
@@ -29,32 +28,24 @@ import org.talend.repository.ui.swt.utils.AbstractForm;
*/
public class SetRepetableAction extends SelectionProviderAction {
/**
*
*/
private static final String REMOVE_REPEATABLE = Messages.getString("SetRepetableAction_removeRepeatable"); //$NON-NLS-1$
/**
*
*/
private static final String SET_AS_REPEATABLE_ELEMENT = Messages.getString("SetRepetableAction_setAsRepeatable"); //$NON-NLS-1$
// the xml viewer, see HL7UI.
private TreeViewer xmlViewer;
private HL7UI hl7ui;
private boolean value;
private AbstractForm form;
/**
* SetForLoopAction constructor comment.
*
* @param provider
* @param text
*/
public SetRepetableAction(TreeViewer xmlViewer, String text) {
super(xmlViewer, text);
public SetRepetableAction(TreeViewer xmlViewer, AbstractForm form) {
super(xmlViewer, SET_AS_REPEATABLE_ELEMENT);
this.xmlViewer = xmlViewer;
}
public SetRepetableAction(TreeViewer xmlViewer, String text, AbstractForm form) {
super(xmlViewer, text);
this.xmlViewer = xmlViewer;
this.form = form;
}
/**
*
* SetForLoopAction constructor comment.
@@ -66,39 +57,21 @@ public class SetRepetableAction extends SelectionProviderAction {
public SetRepetableAction(TreeViewer xmlViewer, HL7UI hl7ui, String text, boolean value) {
super(xmlViewer, text);
this.xmlViewer = xmlViewer;
this.hl7ui = hl7ui;
this.value = value;
}
public void init() {
setText(SET_AS_REPEATABLE_ELEMENT);
HL7TreeNode node = (HL7TreeNode) this.getStructuredSelection().getFirstElement();
if (node == null) {
this.setEnabled(false);
return;
}
if (node.getParent() == null) {
this.setEnabled(false);
return;
}
if (node.getParent().getParent() != null) {
this.setEnabled(false);
return;
}
if (node.isRepetable()) {
this.setEnabled(false);
this.setEnabled(true);
this.setText(REMOVE_REPEATABLE);
return;
}
if (!node.isMain()) {
this.setEnabled(false);
return;
}
if (node instanceof Attribute) {
this.setEnabled(false);
return;
}
if (node instanceof NameSpaceNode) {
if (node.getLabel().length() != 3) {
this.setEnabled(false);
return;
}
@@ -113,45 +86,18 @@ public class SetRepetableAction extends SelectionProviderAction {
@Override
public void run() {
HL7TreeNode node = (HL7TreeNode) this.getStructuredSelection().getFirstElement();
if (node.isRepetable()) {
return;
if (!node.isRepetable()) {
if (node.isGroup()) {
node.setGroup(false);
}
node.setRepetable(true);
node.setMain(true);
upsetMainNode(node);
} else {
node.setRepetable(false);
}
// 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) {

View File

@@ -1,6 +1,6 @@
// ============================================================================
//
// 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
// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt
@@ -20,6 +20,7 @@ import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import org.talend.commons.exception.ExceptionHandler;
import org.talend.core.model.metadata.IMetadataColumn;
import org.talend.core.model.metadata.IMetadataTable;
import org.talend.core.model.process.ElementParameterParser;
@@ -27,10 +28,8 @@ import org.talend.core.model.process.IConnection;
import org.talend.core.model.process.IConnectionCategory;
import org.talend.core.model.utils.NodeUtil;
import org.talend.designer.hl7.HL7InputComponent;
import org.talend.designer.hl7.ui.data.Attribute;
import org.talend.designer.hl7.ui.data.Element;
import org.talend.designer.hl7.ui.data.HL7TreeNode;
import org.talend.designer.hl7.ui.data.NameSpaceNode;
/**
* DOC hwang class global comment. Detailled comment
@@ -56,378 +55,139 @@ public class HL7OutputManager extends HL7Manager {
}
public void initModel() {
int i = 0;
List<? extends IConnection> incomingConnections = NodeUtil.getIncomingConnections(hl7Component, IConnectionCategory.FLOW);
// HL7Root root = new HL7Root("root");
List<Map<String, String>> maps = (List<Map<String, String>>) ElementParameterParser.getObjectValue(hl7Component,
"__SCHEMAS__"); //$NON-NLS-1$
List<String> schemaList = new ArrayList<String>();
List<Map<String, String>> rootTable = (List<Map<String, String>>) hl7Component.getTableList(HL7InputComponent.ROOT);
List<String> columnList = new ArrayList<String>();
if (rootTable != null && rootTable.size() > 0) {
for (Map<String, String> rootMap : rootTable) {
String columnName = rootMap.get(HL7InputComponent.COLUMN);
if (columnName.contains(":")) {
columnName = columnName.substring(0, columnName.indexOf(":"));
}
if (!columnList.contains(columnName)) {
columnList.add(columnName);
}
}
for (String rowName : columnList) {
IMetadataTable metadataTable = null;
String metadataTableName = rowName;
for (IConnection connection : incomingConnections) {
if (connection.getUniqueName().equals(rowName)) {
metadataTable = connection.getMetadataTable();
metadataTable.setLabel(connection.getUniqueName());
metadataTableName = metadataTable.getLabel();
}
}
// for (Map<String, String> map : maps) {
// if (map.containsValue(rowName)) {
// if (map.get("PARENT_ROW") != null && map.get("PARENT_ROW").equals(rowName)) {
// String schemaName = map.get("SCHEMA");
// int first = schemaName.indexOf("_");
// int second = schemaName.lastIndexOf("_");
// if (first > 0 && first < second) {
// schemaName = schemaName.substring(first + 1, second);
// }
// if (!schemaList.contains(schemaName)) {
// schemaList.add(schemaName);
// rowName = schemaName;// map.get(rowName);
// schemaMap.put(metadataTableName, rowName);
// break;
// }
//
// }
//
// }
// }
treeData = new ArrayList<HL7TreeNode>();
if (i == 0)// the first schema as current
currentSchema = metadataTableName;// metadataTable.getLabel();
HL7TreeNode rootNode = null;
HL7TreeNode current = null;
HL7TreeNode temp = null;
HL7TreeNode mainNode = null;
String mainPath = null;
String currentPath = null;
String defaultValue = null;
int nodeOrder = 0;
boolean haveOrder = true;
String schemaId = rowName + ":";
for (Map<String, String> rootMap : rootTable) {
String newPath = rootMap.get(HL7InputComponent.PATH);
String columnName = rootMap.get(HL7InputComponent.COLUMN);
defaultValue = rootMap.get(HL7InputComponent.VALUE);
String orderValue = rootMap.get(HL7InputComponent.ORDER);
boolean repeatable = Boolean.valueOf(rootMap.get("REPEATABLE"));
if (orderValue == null || "".equals(orderValue)) {
haveOrder = false;
}
if (haveOrder) {
nodeOrder = Integer.valueOf(rootMap.get(HL7InputComponent.ORDER)).intValue();
}
String flag = columnName + ":"; //$NON-NLS-1$
if (columnName != null && columnName.length() > 0 && !flag.startsWith(rowName + ":")) { //$NON-NLS-1$
continue;
}
if (rootMap.get(HL7InputComponent.ATTRIBUTE).equals("attri")) { //$NON-NLS-1$
temp = new Attribute(newPath);
temp.setDefaultValue(defaultValue);
current.addChild(temp);
} else if (rootMap.get(HL7InputComponent.ATTRIBUTE).equals("ns")) { //$NON-NLS-1$
temp = new NameSpaceNode(newPath);
temp.setDefaultValue(defaultValue);
current.addChild(temp);
} else {
temp = addElement(current, currentPath, newPath, defaultValue);
if (rootNode == null) {
rootNode = temp;
}
if (rootMap.get(HL7InputComponent.ATTRIBUTE).equals("main")) { //$NON-NLS-1$
temp.setMain(true);
mainNode = temp;
mainPath = newPath;
}
current = temp;
currentPath = newPath;
}
if (haveOrder) {
temp.setOrder(nodeOrder);
}
temp.setRepetable(repeatable);
temp.setRow(rowName);
if (columnName != null && columnName.length() > 0 && columnName.startsWith(schemaId)) {
columnName = columnName.replace(schemaId, ""); // $!=Nnull-1$
if (metadataTable != null) {
temp.setColumn(metadataTable.getColumn(columnName));
temp.setTable(metadataTable);
}
}
}
if (rootNode == null) {
rootNode = new Element("rootTag"); //$NON-NLS-1$
// rootNode.setParent(root);
// root.addChild(rootNode);
}
if (haveOrder) {
orderNode(rootNode);
}
treeData.add(rootNode);
rootNode.setRow(rowName);
contents.put(metadataTableName, treeData);
i++;
}
initCurrentSchema();
} else if (rootTable != null && rootTable.size() <= 0) {
for (IConnection connection : incomingConnections) {
IMetadataTable metadataTable = connection.getMetadataTable();
metadataTable.setLabel(connection.getUniqueName());
String metadataTableName = metadataTable.getLabel();
String rowName = metadataTable.getLabel();
for (Map<String, String> map : maps) {
if (map.containsValue(rowName)) {
if (map.get("PARENT_ROW") != null && map.get("PARENT_ROW").equals(rowName)) {
String schemaName = map.get("SCHEMA");
int first = schemaName.indexOf("_");
int second = schemaName.lastIndexOf("_");
if (first > 0 && first < second) {
schemaName = schemaName.substring(first + 1, second);
}
if (!schemaList.contains(schemaName)) {
schemaList.add(schemaName);
rowName = schemaName;// map.get(rowName);
schemaMap.put(metadataTableName, rowName);
break;
}
}
}
}
treeData = new ArrayList<HL7TreeNode>();
if (i == 0)// the first schema as current
currentSchema = metadataTableName;// metadataTable.getLabel();
HL7TreeNode rootNode = null;
HL7TreeNode current = null;
HL7TreeNode temp = null;
HL7TreeNode mainNode = null;
String mainPath = null;
String currentPath = null;
String defaultValue = null;
int nodeOrder = 0;
boolean haveOrder = true;
String schemaId = rowName + ":";//metadataTable.getLabel() + ":"; //$NON-NLS-1$
// build root tree
// List<Map<String, String>> rootTable = (List<Map<String, String>>)
// hl7Component.getTableList(HL7InputComponent.ROOT);
if (rootTable != null) {
for (Map<String, String> rootMap : rootTable) {
String newPath = rootMap.get(HL7InputComponent.PATH);
String columnName = rootMap.get(HL7InputComponent.COLUMN);
defaultValue = rootMap.get(HL7InputComponent.VALUE);
String orderValue = rootMap.get(HL7InputComponent.ORDER);
boolean repeatable = Boolean.valueOf(rootMap.get("REPEATABLE"));
if (orderValue == null || "".equals(orderValue)) {
haveOrder = false;
}
if (haveOrder) {
nodeOrder = Integer.valueOf(rootMap.get(HL7InputComponent.ORDER)).intValue();
}
String flag = columnName + ":"; //$NON-NLS-1$
if (columnName != null && columnName.length() > 0 && !flag.startsWith(rowName + ":")) { //$NON-NLS-1$
continue;
}
if (rootMap.get(HL7InputComponent.ATTRIBUTE).equals("attri")) { //$NON-NLS-1$
temp = new Attribute(newPath);
temp.setDefaultValue(defaultValue);
current.addChild(temp);
} else if (rootMap.get(HL7InputComponent.ATTRIBUTE).equals("ns")) { //$NON-NLS-1$
temp = new NameSpaceNode(newPath);
temp.setDefaultValue(defaultValue);
current.addChild(temp);
} else {
temp = addElement(current, currentPath, newPath, defaultValue);
if (rootNode == null) {
rootNode = temp;
}
if (rootMap.get(HL7InputComponent.ATTRIBUTE).equals("main")) { //$NON-NLS-1$
temp.setMain(true);
mainNode = temp;
mainPath = newPath;
}
current = temp;
currentPath = newPath;
}
if (haveOrder) {
temp.setOrder(nodeOrder);
}
temp.setRepetable(repeatable);
temp.setRow(rowName);
if (columnName != null && columnName.length() > 0 && columnName.startsWith(schemaId)) {
columnName = columnName.replace(schemaId, ""); //$NON-NLS-1$
temp.setColumn(metadataTable.getColumn(columnName));
temp.setTable(metadataTable);
}
}
if (rootNode == null) {
rootNode = new Element("rootTag"); //$NON-NLS-1$
// rootNode.setParent(root);
// root.addChild(rootNode);
}
if (haveOrder) {
orderNode(rootNode);
}
treeData.add(rootNode);
rootNode.setRow(rowName);
contents.put(metadataTableName, treeData);
i++;
}
for (IMetadataTable table : hl7Component.getMetadataList()) {
if (table.getLabel() != null) {
schemaList.add(table.getLabel());
}
}
}
List<Map<String, String>> rootTable = hl7Component.getTableList(HL7InputComponent.ROOT);
Map<String, IMetadataTable> schemaNameToInputTable = new HashMap<String, IMetadataTable>();
// // build group tree
// current = mainNode;
// currentPath = mainPath;
// boolean isFirst = true;
// List<Map<String, String>> groupTable = (List<Map<String, String>>)
// hl7Component.getTableList(HL7InputComponent.GROUP);
// if (groupTable != null) {
// for (Map<String, String> groupMap : groupTable) {
// String newPath = groupMap.get(HL7InputComponent.PATH);
// String columnName = groupMap.get(HL7InputComponent.COLUMN);
// defaultValue = groupMap.get(HL7InputComponent.VALUE);
// String orderValue = groupMap.get(HL7InputComponent.ORDER);
// if (orderValue == null || "".equals(orderValue)) {
// haveOrder = false;
// }
// if (haveOrder) {
// nodeOrder = Integer.valueOf(groupMap.get(HL7InputComponent.ORDER)).intValue();
// }
// String flag = columnName + ":"; //$NON-NLS-1$
// if (columnName != null && columnName.length() > 0 && !flag.startsWith(rowName + ":")) { //$NON-NLS-1$
// continue;
// }
// if (groupMap.get(HL7InputComponent.ATTRIBUTE).equals("attri")) { //$NON-NLS-1$
// temp = new Attribute(newPath);
// temp.setDefaultValue(defaultValue);
// current.addChild(temp);
// } else if (groupMap.get(HL7InputComponent.ATTRIBUTE).equals("ns")) { //$NON-NLS-1$
// temp = new NameSpaceNode(newPath);
// temp.setDefaultValue(defaultValue);
// current.addChild(temp);
// } else {
// temp = this.addElement(current, currentPath, newPath, defaultValue);
// if (groupMap.get(HL7InputComponent.ATTRIBUTE).equals("main")) { //$NON-NLS-1$
// temp.setMain(true);
// mainNode = temp;
// mainPath = newPath;
// }
// if (isFirst) {
// temp.setGroup(true);
// isFirst = false;
// }
// current = temp;
// currentPath = newPath;
// }
// if (haveOrder) {
// temp.setOrder(nodeOrder);
// }
// temp.setRow(rowName);
// if (columnName != null && columnName.length() > 0 && columnName.startsWith(schemaId)) {
// columnName = columnName.replace(schemaId, ""); //$NON-NLS-1$
// temp.setColumn(metadataTable.getColumn(columnName));
// temp.setTable(metadataTable);
// }
// }
// }
//
// // build loop tree
// current = mainNode;
// currentPath = mainPath;
// isFirst = true;
// List<Map<String, String>> loopTable = (List<Map<String, String>>)
// hl7Component.getTableList(HL7InputComponent.LOOP);
// if (loopTable != null) {
// for (Map<String, String> loopMap : loopTable) {
// String newPath = loopMap.get(HL7InputComponent.PATH);
// String columnName = loopMap.get(HL7InputComponent.COLUMN);
// defaultValue = loopMap.get(HL7InputComponent.VALUE);
// String orderValue = loopMap.get(HL7InputComponent.ORDER);
// if (orderValue == null || "".equals(orderValue)) {
// haveOrder = false;
// }
// if (haveOrder) {
// nodeOrder = Integer.valueOf(loopMap.get(HL7InputComponent.ORDER)).intValue();
// }
// String flag = columnName + ":"; //$NON-NLS-1$
// if (columnName != null && columnName.length() > 0 && !flag.startsWith(rowName + ":")) { //$NON-NLS-1$
// continue;
// }
// if (loopMap.get(HL7InputComponent.ATTRIBUTE).equals("attri")) { //$NON-NLS-1$
// temp = new Attribute(newPath);
// temp.setDefaultValue(defaultValue);
// current.addChild(temp);
// } else if (loopMap.get(HL7InputComponent.ATTRIBUTE).equals("ns")) { //$NON-NLS-1$
// temp = new NameSpaceNode(newPath);
// temp.setDefaultValue(defaultValue);
// current.addChild(temp);
// } else {
// temp = this.addElement(current, currentPath, newPath, defaultValue);
// if (loopMap.get(HL7InputComponent.ATTRIBUTE).equals("main")) { //$NON-NLS-1$
// temp.setMain(true);
// }
// if (isFirst) {
// temp.setRepetable(true);
// isFirst = false;
// }
// current = temp;
// currentPath = newPath;
// }
// if (haveOrder) {
// temp.setOrder(nodeOrder);
// }
// temp.setRow(rowName);
// if (columnName != null && columnName.length() > 0 && columnName.startsWith(schemaId)) {
// columnName = columnName.replace(schemaId, ""); //$NON-NLS-1$
// temp.setColumn(metadataTable.getColumn(columnName));
// temp.setTable(metadataTable);
// }
// }
//
// if (rootNode == null) {
// rootNode = new Element("rootTag"); //$NON-NLS-1$
// // rootNode.setParent(root);
// // root.addChild(rootNode);
// }
//
// if (haveOrder) {
// orderNode(rootNode);
// }
// treeData.add(rootNode);
// rootNode.setRow(rowName);
// contents.put(metadataTableName, treeData);
// i++;
// }
// }
// this.setTreeRoot(root);
// }
if (!maps.isEmpty()) {
for (Map<String, String> map : maps) {
String schemaName = map.get("SCHEMA");
int first = schemaName.indexOf("_");
int second = schemaName.lastIndexOf("_");
if (first > 0 && first < second) {
schemaName = schemaName.substring(first + 1, second);
}
IMetadataTable metadataTable = null;
for (IConnection connection : incomingConnections) {
if (connection.getUniqueName().equals(map.get("PARENT_ROW"))) {
metadataTable = connection.getMetadataTable();
metadataTable.setLabel(connection.getUniqueName());
schemaNameToInputTable.put(schemaName, metadataTable);
break;
}
}
}
} else {
for (String schemaName : schemaList) {
IMetadataTable metadataTable = null;
for (IConnection connection : incomingConnections) {
if (connection.getUniqueName().equals(schemaName)) {
metadataTable = connection.getMetadataTable();
metadataTable.setLabel(connection.getUniqueName());
schemaNameToInputTable.put(schemaName, metadataTable);
}
}
}
}
Map<String, HL7TreeNode> mapNodes = new HashMap<String, HL7TreeNode>();
treeData = new ArrayList<HL7TreeNode>();
HL7TreeNode rootNode = null;
HL7TreeNode current = null;
HL7TreeNode temp = null;
String currentPath = null;
String defaultValue = null;
int nodeOrder = 0;
boolean haveOrder = true;
// build root tree
for (Map<String, String> rootMap : rootTable) {
String newPath = rootMap.get(HL7InputComponent.PATH);
String columnName = rootMap.get(HL7InputComponent.COLUMN);
defaultValue = rootMap.get(HL7InputComponent.VALUE);
String orderValue = rootMap.get(HL7InputComponent.ORDER);
boolean repeatable = Boolean.valueOf(rootMap.get("REPEATABLE"));
if (orderValue == null || "".equals(orderValue)) {
haveOrder = false;
}
String rowName = columnName;
if (columnName != null && columnName.contains(":")) {
String[] names = columnName.split(":");
rowName = names[0];
columnName = names[1];
} else {
columnName = null;
}
temp = this.addElement(current, currentPath, newPath, defaultValue, mapNodes);
if (temp == null) {
// should not happen
continue;
}
if (rootNode == null) {
rootNode = temp;
}
if (rootMap.get(HL7InputComponent.ATTRIBUTE).equals("main")) { //$NON-NLS-1$
temp.setMain(true);
}
current = temp;
currentPath = newPath;
if (haveOrder) {
temp.setOrder(nodeOrder);
}
if (rowName != null && rowName.length() > 0) {
temp.setRow(rowName);
}
if (columnName != null) {
IMetadataTable metadataTable = schemaNameToInputTable.get(rowName);
// group node can not get the metadata table
if (metadataTable == null) {
IMetadataTable metadataTableTemp = null;
for (IConnection connection : incomingConnections) {
metadataTableTemp = connection.getMetadataTable();
String connectionName = metadataTableTemp.getLabel();
if (connectionName == null) {
connectionName = connection.getUniqueName();
}
if (columnName.startsWith(connectionName)) {
break;
}
}
temp.setColumnName(columnName);
if (metadataTableTemp != null) {
temp.setColumn(metadataTableTemp.getColumn(columnName));
temp.setTable(metadataTableTemp);
}
} else {
temp.setColumnName(columnName);
temp.setColumn(metadataTable.getColumn(columnName));
temp.setTable(metadataTable);
}
}
}
if (rootNode == null) {
rootNode = new Element("rootTag");
}
if (haveOrder) {
orderNode(rootNode);
}
// the root node should not set the ColumnLabel
if (rootNode.getRow() != null) {
rootNode.setRow(null);
}
treeData.add(rootNode);
contents.put(rootNode.getColumnLabel(), treeData);
initCurrentSchema();
}
public List<Map<String, String>> getRootTable() {
List<Map<String, String>> result = new ArrayList<Map<String, String>>();
@@ -519,7 +279,7 @@ public class HL7OutputManager extends HL7Manager {
newMap.put(HL7InputComponent.PATH, att.getLabel());
newMap.put(HL7InputComponent.COLUMN, att.getColumnLabel());
newMap.put(HL7InputComponent.ATTRIBUTE, "attri"); //$NON-NLS-1$
newMap.put(HL7InputComponent.VALUE, att.getDefaultValue()); //$NON-NLS-1$
newMap.put(HL7InputComponent.VALUE, att.getDefaultValue());
newMap.put(HL7InputComponent.ORDER, String.valueOf(getNodeOrder(att)));
newMap.put("REPEATABLE", String.valueOf(att.isRepetable()));
table.add(newMap);
@@ -529,7 +289,7 @@ public class HL7OutputManager extends HL7Manager {
newMap.put(HL7InputComponent.PATH, att.getLabel());
newMap.put(HL7InputComponent.COLUMN, att.getColumnLabel());
newMap.put(HL7InputComponent.ATTRIBUTE, "ns"); //$NON-NLS-1$
newMap.put(HL7InputComponent.VALUE, att.getDefaultValue()); //$NON-NLS-1$
newMap.put(HL7InputComponent.VALUE, att.getDefaultValue());
newMap.put("REPEATABLE", String.valueOf(att.isRepetable()));
newMap.put(HL7InputComponent.ORDER, String.valueOf(getNodeOrder(att)));
table.add(newMap);
@@ -608,6 +368,7 @@ public class HL7OutputManager extends HL7Manager {
return null;
}
@Override
public List<HL7TreeNode> getTreeData(String curSchema) {
if (currentSchema == null) {
if (treeData == null) {
@@ -694,6 +455,7 @@ public class HL7OutputManager extends HL7Manager {
}
}
@Override
public String getCurrentSchema(boolean sign) {
if (sign && schemaMap.get(currentSchema) != null && !"".equals(schemaMap.get(currentSchema))) {
return schemaMap.get(currentSchema);
@@ -717,44 +479,26 @@ public class HL7OutputManager extends HL7Manager {
return this.currentSchema;
}
protected HL7TreeNode addElement(HL7TreeNode current, String currentPath, String newPath, String defaultValue) {
String name = newPath.substring(newPath.lastIndexOf("/") + 1); //$NON-NLS-1$
String parentPath = "";
if (newPath.contains("/")) {
parentPath = newPath.substring(0, newPath.lastIndexOf("/")); //$NON-NLS-1$
}
// String parentPath = newPath.substring(0, newPath.lastIndexOf("/")); //$NON-NLS-1$
HL7TreeNode temp = new Element(name, defaultValue);
if (current == null) {// root node
return temp;
}
if (currentPath.equals(parentPath)) {
current.addChild(temp);
} else {
String[] nods = currentPath.split("/"); //$NON-NLS-1$
String[] newNods = parentPath.split("/"); //$NON-NLS-1$
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;
}
protected HL7TreeNode addElement(HL7TreeNode current, String currentPath, String newPath, String defaultValue,
Map<String, HL7TreeNode> mapNodes) {
HL7TreeNode temp = mapNodes.get(newPath);
if (temp == null) {
// if node is not existing, create it.
String name = newPath.substring(newPath.lastIndexOf("/") + 1); //$NON-NLS-1$
temp = new Element(name, defaultValue);
if (current == null) {// root node
mapNodes.put(newPath, temp);
return temp;
}
HL7TreeNode parent = current;
for (int i = 0; i < nods.length - (parentLevel + 1); i++) {
HL7TreeNode tmpParent = parent.getParent();
if (tmpParent == null) {
break;
}
parent = tmpParent;
mapNodes.put(newPath, temp);
String parentPath = newPath.substring(0, newPath.lastIndexOf("/")); //$NON-NLS-1$
HL7TreeNode parentNode = mapNodes.get(parentPath);
if (parentNode != null) {
parentNode.addChild(temp);
} else {
ExceptionHandler.log("Error when parsing the HL7 data, parent not existing for:" + parentPath);
}
if (parent != null)
parent.addChild(temp);
}
return temp;
}
@@ -811,6 +555,7 @@ public class HL7OutputManager extends HL7Manager {
return this.contents;
}
@Override
public List<IMetadataColumn> getSchemaData(String currentSchema) {
List<? extends IConnection> incomingConnections = NodeUtil.getIncomingConnections(hl7Component, IConnectionCategory.FLOW);
for (IConnection connection : incomingConnections) {

View File

@@ -15,7 +15,11 @@ package org.talend.designer.hl7.model;
import org.talend.core.model.utils.TalendTextUtils;
import ca.uhn.hl7v2.model.Primitive;
import ca.uhn.hl7v2.model.Type;
/**
* DOC gcui class global comment. Detailled comment
*/
public class PrimitiveModel extends AbstractStructureModel {
private int componentindex;
@@ -37,18 +41,24 @@ public class PrimitiveModel extends AbstractStructureModel {
@Override
protected void generateDisplayName() {
String parentName = "";
String parentName = ""; //$NON-NLS-1$
if (parent instanceof TypeModel) {
TypeModel tm = (TypeModel) parent;
String extensionName = tm.getType().getName();
Type type = tm.getType();
String parentDisplayName = tm.getDisplayName();
// int extensionIndex = parentDisplayName.indexOf(extensionName);
int extensionIndex = parentDisplayName.lastIndexOf(extensionName);// changed for bug TDI-19467
parentName = parentDisplayName.substring(0, extensionIndex - 1);
parentName = parentDisplayName;
if (type != null) {
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,6 +1,6 @@
// ============================================================================
//
// 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
// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt
@@ -12,6 +12,8 @@
// ============================================================================
package org.talend.designer.hl7.model;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;
import ca.uhn.hl7v2.HL7Exception;
@@ -38,6 +40,7 @@ public class SegmentModel extends AbstractStructureModel {
generateDataTypes();
}
@Override
protected void generateDisplayName() {
this.displayName = seg.getName();
}
@@ -45,13 +48,64 @@ public class SegmentModel extends AbstractStructureModel {
private void generateDataTypes() {
int number = this.seg.numFields();
ArrayList<TypeModel> datatypes = new ArrayList<TypeModel>();
for (int i = 1; i < number; i++) {
try {
Type[] reps = seg.getField(i);
for (int j = 0; j < reps.length; j++) {
TypeModel tm = new TypeModel(reps[j], seg, j, i);
Method method = null;
try {
for (Method curMethod : seg.getClass().getDeclaredMethods()) {
if (curMethod.getName().equals("createNewTypeWithoutReflection")) {
method = curMethod;
method.setAccessible(true);
break;
}
}
if (method != null) {
// only access we have to get all the types is reflection (protected method).
// 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++) {
Type type = (Type) method.invoke(seg, i);
TypeModel tm = new TypeModel(type, seg, 0, i + 1);
datatypes.add(tm);
}
}
} catch (SecurityException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IllegalArgumentException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IllegalAccessException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (InvocationTargetException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
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();
}

View File

@@ -1,6 +1,6 @@
// ============================================================================
//
// 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
// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt
@@ -55,26 +55,30 @@ public class TypeModel extends AbstractStructureModel {
generatePrimitive();
}
@Override
protected void generateDisplayName() {
String typeDisplay = type == null ? "" : TalendTextUtils.LBRACKET + this.type.getName() + TalendTextUtils.RBRACKET;
this.displayName = getParent().getName() + "-" + index + "(1)" + typeDisplay; //$NON-NLS-1$ //$NON-NLS-2$
this.displayName = getParent().getName() + "-" + index + "(" + (++rep) + ")" + TalendTextUtils.LBRACKET + type.getName() //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ TalendTextUtils.RBRACKET;
}
private void generatePrimitive() {
List<PrimitiveModel> pms = new ArrayList<PrimitiveModel>();
int numComp = Terser.numComponents(this.type);
for (int k = 1; k <= numComp; k++) {
int numSubComp = Terser.numSubComponents(this.type, k);
for (int m = 1; m <= numSubComp; m++) {
Primitive p = getPrimitive(this.type, k, m);
if (p.getValue() != null) {
if (type != null) {
List<PrimitiveModel> pms = new ArrayList<PrimitiveModel>();
int numComp = Terser.numComponents(this.type);
for (int k = 1; k <= numComp; k++) {
int numSubComp = Terser.numSubComponents(this.type, k);
for (int m = 1; m <= numSubComp; m++) {
Primitive p = getPrimitive(this.type, k, m);
PrimitiveModel pm = new PrimitiveModel(this, p, k, m);
pms.add(pm);
}
}
primitives = pms.toArray(new PrimitiveModel[0]);
} else {
PrimitiveModel pm = new PrimitiveModel(this, null, 1, 1);
primitives = new PrimitiveModel[] { pm };
}
primitives = pms.toArray(new PrimitiveModel[0]);
}
public Primitive getPrimitive(Type type, int component, int subcomponent) {
@@ -101,8 +105,9 @@ public class TypeModel extends AbstractStructureModel {
Varies v = (Varies) type;
try {
if (comp > 1 && GenericPrimitive.class.isAssignableFrom(v.getData().getClass()))
if (comp > 1 && GenericPrimitive.class.isAssignableFrom(v.getData().getClass())) {
v.setData(new GenericComposite(v.getMessage()));
}
} catch (DataTypeException de) {
String message = "Unexpected exception copying data to generic composite: " + de.getMessage();
throw new Error(message);

View File

@@ -1,6 +1,6 @@
// ============================================================================
//
// 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
// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt
@@ -54,7 +54,6 @@ import org.talend.core.model.process.IElementParameter;
import org.talend.core.model.utils.NodeUtil;
import org.talend.designer.core.model.components.EParameterName;
import org.talend.designer.hl7.HL7InputComponent;
import org.talend.designer.hl7.action.CreateHL7AttributeAction;
import org.talend.designer.hl7.action.CreateHL7ElementAction;
import org.talend.designer.hl7.action.DeleteHL7NodeAction;
import org.talend.designer.hl7.action.HL7DisconnectAction;
@@ -64,7 +63,6 @@ import org.talend.designer.hl7.action.SetRepetableAction;
import org.talend.designer.hl7.action.StringUtil;
import org.talend.designer.hl7.managers.HL7Manager;
import org.talend.designer.hl7.managers.HL7OutputManager;
import org.talend.designer.hl7.ui.data.Element;
import org.talend.designer.hl7.ui.data.HL7TreeNode;
import org.talend.designer.hl7.ui.data.NameSpaceNode;
import org.talend.designer.hl7.ui.edit.HL7OutputTableViewerProvider;
@@ -102,8 +100,6 @@ public class HL7OutputUI extends HL7UI {
private HL7FixValueAction fixValueAction;
private CreateHL7AttributeAction createAttributeAction;
private ImportHL7StructureAction importAction;
private SetRepetableAction setRepetableAction;
@@ -137,6 +133,7 @@ public class HL7OutputUI extends HL7UI {
/**
* bqian Comment method "init".
*/
@Override
public void init() {
createContent(hl7UIParent);
}
@@ -175,17 +172,10 @@ public class HL7OutputUI extends HL7UI {
linker.setManager(hl7Manager);
initSchemaTable();
new FooterComposite(mainComposite, SWT.NONE, hl7Manager);
Tree xmlTree = xmlViewer.getTree();
if (xmlTree.getItems().length > 0) {
TreeItem root = xmlTree.getItem(0);
TableItem[] tableItems = schemaViewer.getTable().getItems();
redrawLinkers();
// initLinker(root, tableItems);
}
redrawLinkers();
}
@Override
protected void createCombo(Composite mainComposite) {
}
@@ -199,62 +189,35 @@ public class HL7OutputUI extends HL7UI {
if (column != null) {
if (this.gethl7Manager().getHl7Component().isHL7Output() && treeNode.getChildren().size() <= 0) {
for (int i = 0; i < tableItems.length; i++) {
IMetadataColumn mColumn = (IMetadataColumn) tableItems[i].getData();
for (TableItem tableItem : tableItems) {
IMetadataColumn mColumn = (IMetadataColumn) tableItem.getData();
if (mColumn.getLabel().equals(column.getLabel())) {
linker.addLoopLink(tableItems[i], tableItems[i].getData(), xmlViewer.getTree(), treeNode, true);
linker.addLoopLink(tableItem, tableItem.getData(), xmlViewer.getTree(), treeNode, true);
break;
}
}
}
for (int i = 0; i < tableItems.length; i++) {
IMetadataColumn mColumn = (IMetadataColumn) tableItems[i].getData();
for (TableItem tableItem : tableItems) {
IMetadataColumn mColumn = (IMetadataColumn) tableItem.getData();
if (mColumn.getLabel().equals(column.getLabel())) {
linker.addLoopLink(tableItems[i], tableItems[i].getData(), xmlViewer.getTree(), treeNode, true);
linker.addLoopLink(tableItem, tableItem.getData(), xmlViewer.getTree(), treeNode, true);
break;
}
}
}
TreeItem[] children = node.getItems();
for (int i = 0; i < children.length; i++) {
initLinker(children[i], tableItems);
for (TreeItem element : children) {
initLinker(element, tableItems);
}
}
@Override
public void redrawLinkers() {
linker.removeAllLinks();
if (xmlViewer.getTree().getItems().length <= 0) {
return;
}
TreeItem root = xmlViewer.getTree().getItem(0);
if (this.gethl7Manager().getHl7Component().isHL7Output()) {
if (this.hl7Manager != null) {
List<HL7TreeNode> treeData = this.hl7Manager.getTreeData(this.hl7Manager.getCurrentSchema(false));
if (treeData != null && treeData.size() > 0) {
HL7TreeNode rootTreeData = treeData.get(0);
if (rootTreeData != null) {
for (TreeItem item : xmlViewer.getTree().getItems()) {
if (rootTreeData == item.getData()) {
root = item;
break;
} else if (item.getData() instanceof Element) {
if (((Element) item.getData()).getRow().equals(rootTreeData.getRow())) {
root = item;
break;
}
}
}
}
}
}
}
TableItem[] tableItems = schemaViewer.getTable().getItems();
initLinker(root, tableItems);
if (linker.linkSize() == 0) {
linker.updateLinksStyleAndControlsSelection(xmlViewer.getTree(), true);
}
xmlViewer.refresh();
linker.createLinks();
}
public void refreshXMLViewer(HL7TreeNode targetNode) {
@@ -436,8 +399,6 @@ public class HL7OutputUI extends HL7UI {
if (!xmlViewer.getSelection().isEmpty()) {
manager.add(createAction);
createAction.init();
manager.add(createAttributeAction);
createAttributeAction.init();
manager.add(new Separator());
manager.add(deleteAction);
deleteAction.init();
@@ -464,7 +425,6 @@ public class HL7OutputUI extends HL7UI {
private void createAction() {
createAction = new CreateHL7ElementAction(xmlViewer, this, "Add Sub-element");
createAttributeAction = new CreateHL7AttributeAction(xmlViewer, this, "Add Attribute");
deleteAction = new DeleteHL7NodeAction(xmlViewer, this, "Delete");
disconnectAction = new HL7DisconnectAction(xmlViewer, this, "Disconnect Linker");
fixValueAction = new HL7FixValueAction(xmlViewer, this, "Set A Fix Value");
@@ -505,6 +465,7 @@ public class HL7OutputUI extends HL7UI {
return this.hl7UIParent;
}
@Override
public HL7Manager gethl7Manager() {
return this.hl7Manager;
}

View File

@@ -1,6 +1,6 @@
// ============================================================================
//
// 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
// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt

View File

@@ -1,6 +1,6 @@
// ============================================================================
//
// 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
// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt
@@ -215,12 +215,15 @@ public class SchemaXMLDragAndDropHandler {
Item targetItem = (Item) event.item;
if (targetItem != null) {
Object data = targetItem.getData();
if (data instanceof HL7TreeNode) {
HL7TreeNode rootElement = getRootElement((HL7TreeNode) data);
if (rootElement != null) {// && !(rootElement instanceof HL7Root)
return currentSchema.equals(rootElement.getRow());
if (data != null && data instanceof HL7TreeNode) {
HL7TreeNode treeNode = ((HL7TreeNode) data);
if (treeNode.getParent() == null) {
MessageDialog.openConfirm(event.display.getActiveShell(), "Warning", "\"" + treeNode.getLabel()
+ "\" " + "is root, can not have linker,you should create sub-elements or attributes.");
return false;
}
String columnLabel = treeNode.getRow();
return columnLabel != null ? columnLabel.startsWith(currentSchema) : false;
}
}
}
@@ -232,7 +235,7 @@ public class SchemaXMLDragAndDropHandler {
// System.out.println("\n>>drop");
DropTarget dropTarget = (DropTarget) event.getSource();
Item targetItem = (Item) event.item;
if (targetItem == null || !isEnabled(event)) {
if (targetItem == null) {
event.detail = DND.DROP_NONE;
return;
}
@@ -279,7 +282,7 @@ public class SchemaXMLDragAndDropHandler {
// System.out.println("\n>>drop");
DropTarget dropTarget = (DropTarget) event.getSource();
Item targetItem = (Item) event.item;
if (targetItem == null) {
if (targetItem == null || !isEnabled(event)) {
return;
}
@@ -466,8 +469,9 @@ public class SchemaXMLDragAndDropHandler {
// reset all the treeNode add row to relative column
private void setTreeNodeRow(HL7TreeNode root, String row) {
if (root == null)
if (root == null) {
return;
}
root.setRow(row);
if (root instanceof Element) {
Element element = (Element) root;

View File

@@ -1,6 +1,6 @@
// ============================================================================
//
// 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
// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt
@@ -167,48 +167,44 @@ public class SchemaXMLLinker extends TableToTreeLinker<Object, Object> {
public void run(IProgressMonitor monitor) {
TreeItem root = xmlViewer.getTree().getItem(0);
//
List<HL7TreeNode> mappableNodes = new ArrayList<HL7TreeNode>();
if (getManager().getHl7Component().isHL7Output()) {
if (getManager() instanceof HL7OutputManager) {
List<HL7TreeNode> treeData = ((HL7OutputManager) getManager())
.getTreeData(((HL7OutputManager) getManager()).getCurrentSchema(false));
if (treeData != null && treeData.size() > 0) {
HL7TreeNode rootTreeData = treeData.get(0);
for (TreeItem item : xmlViewer.getTree().getItems()) {
if (rootTreeData == item.getData()) {
root = item;
break;
}
}
mappableNodes = ((HL7OutputManager) getManager()).getTreeData(""); //$NON-NLS-1$
createLoopLinks(mappableNodes);
xmlViewer.refresh();
getBackgroundRefresher().refreshBackground();
}
} else {
List<TreeItem> allItems = TreeUtils.collectAllItems(root);
monitorWrap = new EventLoopProgressMonitor(monitor);
String taskName = Messages.getString("XmlToXPathLinker.Loop"); //$NON-NLS-1$
int totalWork = allItems.size();
monitorWrap.beginTask(taskName, totalWork);
for (int i = 0; i < totalWork; i++) {
if (monitorWrap.isCanceled()) {
return;
}
TreeItem treeItem = allItems.get(i);
HL7TreeNode node = (HL7TreeNode) treeItem.getData();
if (node.getColumn() == null) {
continue;
}
// add now parameter for bug 9279
createLoopLinks(node.getColumn().getLabel(), treeItem, monitorWrap, i == totalWork - 1);
monitorWrap.worked(1);
}
monitorWrap.done();
}
List<TreeItem> allItems = TreeUtils.collectAllItems(root);
monitorWrap = new EventLoopProgressMonitor(monitor);
String taskName = Messages.getString("XmlToXPathLinker.Loop"); //$NON-NLS-1$
int totalWork = allItems.size();
monitorWrap.beginTask(taskName, totalWork); //$NON-NLS-1$
for (int i = 0; i < totalWork; i++) {
if (monitorWrap.isCanceled()) {
return;
}
TreeItem treeItem = allItems.get(i);
HL7TreeNode node = (HL7TreeNode) treeItem.getData();
if (node.getColumn() == null) { //$NON-NLS-1$
continue;
}
// add now parameter for bug 9279
createLoopLinks(node.getColumn().getLabel(), treeItem, monitorWrap, i == totalWork - 1);
monitorWrap.worked(1);
}
monitorWrap.done();
}
};
@@ -320,11 +316,36 @@ public class SchemaXMLLinker extends TableToTreeLinker<Object, Object> {
TableItem treeItemFromAbsoluteXPath = getItem(xPathExpression);
if (treeItemFromAbsoluteXPath != null) {
addLoopLink(treeItemFromAbsoluteXPath, (Object) treeItemFromAbsoluteXPath.getData(), tableItemTarget.getParent(),
addLoopLink(treeItemFromAbsoluteXPath, treeItemFromAbsoluteXPath.getData(), tableItemTarget.getParent(),
(HL7TreeNode) tableItemTarget.getData(), lastOne);
}
}
private void createLoopLinks(List<HL7TreeNode> treeData) {
for (HL7TreeNode treeNode : treeData) {
if (treeNode.getColumn() != null) {
TableItem tableItem = null;
for (TableItem curTableItem : getSource().getItems()) {
if (curTableItem.getText().equals(treeNode.getColumn().getLabel())) {
tableItem = curTableItem;
break;
}
}
if (tableItem == null) {
continue;
}
String path = tableItem.getText();
if (path != null) {
TreeItem treeItem = getTreeItem(treeNode);
if (treeItem != null) {
addLoopLink(tableItem, tableItem.getData(), xmlViewer.getTree(), (HL7TreeNode) treeItem.getData(), false);
}
}
}
createLoopLinks(treeNode.getChildren());
}
}
private TableItem getItem(String path) {
this.getSource().getItems();
for (int i = 0; i < this.getSource().getItems().length; i++) {
@@ -346,7 +367,7 @@ public class SchemaXMLLinker extends TableToTreeLinker<Object, Object> {
return this.xmlViewer;
}
@SuppressWarnings("unchecked")//$NON-NLS-1$
@SuppressWarnings("unchecked")
public void updateLinksStyleAndControlsSelection(Control currentControl, boolean lastOne) {
// super.updateLinksStyleAndControlsSelection(currentControl);
boolean isTarget = false;
@@ -363,14 +384,12 @@ public class SchemaXMLLinker extends TableToTreeLinker<Object, Object> {
getTarget().deselectAll();
TreeItem[] selection = getTarget().getSelection();
for (int i = 0; i < selection.length; i++) {
TreeItem tableItem = selection[i];
for (TreeItem tableItem : selection) {
selectedItems.add(tableItem.getData());
}
} else {
TableItem[] selection = getSource().getSelection();
for (int i = 0; i < selection.length; i++) {
TableItem treeItem = selection[i];
for (TableItem treeItem : selection) {
selectedItems.add(treeItem.getData());
}
}
@@ -398,7 +417,7 @@ public class SchemaXMLLinker extends TableToTreeLinker<Object, Object> {
styleLink = getSelectedStyleLink();
if (isTarget) {
itemsToSelect.put((TableItem) otherExtremity.getGraphicalObject(), null);
itemsToSelect.put(otherExtremity.getGraphicalObject(), null);
} else {
@@ -430,7 +449,7 @@ public class SchemaXMLLinker extends TableToTreeLinker<Object, Object> {
for (Table table : set) {
ArrayList<TableItem> tableItemsToSelect = (ArrayList<TableItem>) itemsToSelect.get(table);
table.deselectAll();
TableItem[] tableItems = (TableItem[]) tableItemsToSelect.toArray(new TableItem[0]);
TableItem[] tableItems = tableItemsToSelect.toArray(new TableItem[0]);
table.setSelection(tableItems);
}
} else {
@@ -532,4 +551,58 @@ public class SchemaXMLLinker extends TableToTreeLinker<Object, Object> {
return false;
}
private boolean containsTreeNode(HL7TreeNode currentNode, HL7TreeNode leafNode) {
HL7TreeNode parentOfLeafNode = leafNode.getParent();
if (parentOfLeafNode != null) {
if (parentOfLeafNode.equals(currentNode)) {
return true;
}
return containsTreeNode(currentNode, parentOfLeafNode);
}
return false;
}
public TreeItem getTreeItem(TreeItem[] items, HL7TreeNode treeNode, boolean expandedOnly) {
TreeItem item = null;
for (TreeItem curItem : items) {
// call getText method since we are in a lazy tree.
// it will force to load this item in the GUI (since it should be displayed in all cases)
// without this, the data will be null, and we can't retrieve anything
curItem.getText();
if (curItem.getData() != null) {
if (curItem.getData().equals(treeNode)) {
return curItem;
}
// will check if one of the parent of the treeNode is this one.
if (containsTreeNode((HL7TreeNode) curItem.getData(), treeNode)) {
if (!expandedOnly || curItem.getExpanded()) {
return getTreeItem(curItem.getItems(), treeNode, expandedOnly);
} else {
return curItem;
}
}
}
}
return item;
}
public TreeItem getTreeItem(HL7TreeNode hl7TreeNode) {
TreeItem[] items = xmlViewer.getTree().getItems();
return getTreeItem(items, hl7TreeNode, false);
}
public TreeItem getFirstVisibleTreeItemOfPath(HL7TreeNode hl7TreeNode) {
TreeItem[] items = xmlViewer.getTree().getItems();
return getTreeItem(items, hl7TreeNode, true);
}
/*
* (non-Javadoc)
*
* @see org.talend.commons.ui.swt.linking.TableToTreeLinker#getFirstVisibleTreeItemOfPath(java.lang.Object)
*/
@Override
protected TreeItem getFirstVisibleTreeItemOfPath(Object dataItem) {
return getFirstVisibleTreeItemOfPath((HL7TreeNode) dataItem);
}
}

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.MetadataTable;
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.repository.ui.swt.utils.AbstractForm;
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 {
protected int maximumRowsToPreview = RepositoryManagerHelper.getMaximumRowsToPreview();
protected HL7Connection connection;
public AbstractHL7StepForm(Composite parent, ConnectionItem connectionItem, String[] existingNames) {

View File

@@ -13,7 +13,6 @@
package org.talend.designer.hl7.ui.provider;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
@@ -54,11 +53,9 @@ public class HL7MessageTreeContentProvider implements ITreeContentProvider {
values.add(childReps[j]);
}
if (childReps[j] instanceof Group) {
values.add(childReps[j]);
allSegmentFromGroup.clear();
getAllSegmentsFromGroup((Group) childReps[j]);
if (allSegmentFromGroup.size() > 0) {
values.addAll(Arrays.asList(allSegmentFromGroup.toArray(new SegmentModel[0])));
}
}
if (childReps[j] instanceof Segment) {
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) {
Group group = (Group) element;
String groupName = group.getClass().getName();
String groupName = group.getName();
groupName = groupName.substring(groupName.lastIndexOf('.') + 1, groupName.length());
return groupName;
}

View File

@@ -1,6 +1,6 @@
// ============================================================================
//
// 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
// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt
@@ -39,25 +39,28 @@ import ca.uhn.hl7v2.model.Structure;
*/
public class HL7PublicUtil {
public void initNodeOrder(HL7TreeNode node, Map<String, Integer> orderMap, int order) {
private int curOrder;
public void initNodeOrder(HL7TreeNode node, Map<String, Integer> orderMap) {
if (node == null) {
return;
}
HL7TreeNode parent = node.getParent();
if (parent == null) {
curOrder = 1;
node.setOrder(1);
String path = getPath(node);
orderMap.put(path, order);
order++;
orderMap.put(path, curOrder);
curOrder++;
}
List<HL7TreeNode> childNode = node.getChildren();
for (HL7TreeNode child : childNode) {
child.setOrder(order);
child.setOrder(curOrder);
String path = getPath(child);
orderMap.put(path, order);
order++;
orderMap.put(path, curOrder);
curOrder++;
if (child.getChildren().size() > 0) {
initNodeOrder(child, orderMap, order);
initNodeOrder(child, orderMap);
}
}
@@ -144,9 +147,6 @@ public class HL7PublicUtil {
HL7TreeNode node = new Element();
String nodeLabel = getLabel(treeNode, true);
node.setLabel(nodeLabel);
// if (node instanceof Element) {
// ((Element) node).setRow(nodeLabel);
// }
node.setMain(true);
List children = getFirstLevelChild(treeNode);
if (children != null) {
@@ -155,7 +155,7 @@ public class HL7PublicUtil {
HL7TreeNode childEle = cloneATreeNode(child, label);
childEle.setLabel(label);
if (childEle instanceof Element) {
if (!(child instanceof Group)) {
((Element) childEle).setRow(label);
}
@@ -169,8 +169,12 @@ public class HL7PublicUtil {
HL7TreeNode node = new Element();
String nodeLabel = getLabel(treeNode, true);
node.setLabel(nodeLabel);
if (node instanceof Element) {
((Element) node).setRow(label);
String rowLabel = label;
if (treeNode instanceof SegmentModel) {
((Element) node).setRow(nodeLabel);
rowLabel = nodeLabel;
} else if (!(treeNode instanceof Group)) {
((Element) node).setRow(rowLabel);
}
node.setMain(true);
Object[] children = getChildList(treeNode);// treeNode.getChildren();
@@ -178,11 +182,15 @@ public class HL7PublicUtil {
for (Object element : children) {
if (getChildList(element).length > 0) {
HL7TreeNode childEle = cloneATreeNode(element, label);
String tlabel = getLabel(element, true);
String childLabel = rowLabel;
HL7TreeNode childEle = cloneATreeNode(element, rowLabel);
if (element instanceof SegmentModel) {
childLabel = tlabel;
}
childEle.setLabel(tlabel);
if (childEle instanceof Element) {
((Element) childEle).setRow(label);
((Element) childEle).setRow(childLabel);
}
node.addChild(childEle);
@@ -197,12 +205,6 @@ public class HL7PublicUtil {
childEle.setMain(false);
node.addChild(childEle);
}
// if (children[i] instanceof ATreeNode) {
// ATreeNode child = (ATreeNode) children[i];
// HL7TreeNode HL7Child = cloneATreeNode(child);
// // HL7Child.setRow(schemaName);
// node.addChild(HL7Child);
// }
}
}
return node;
@@ -341,16 +343,9 @@ public class HL7PublicUtil {
}
}
if (childReps[j] instanceof Group) {
values.add(childReps[j]);
allSegmentFromGroup.clear();
getAllSegmentsFromGroup((Group) childReps[j]);
if (allSegmentFromGroup.size() > 0) {
values.addAll(Arrays.asList(allSegmentFromGroup.toArray(new SegmentModel[0])));
for (SegmentModel sm : Arrays.asList(allSegmentFromGroup.toArray(new SegmentModel[0]))) {
if (getChildren(sm).size() > 0) {
values.add(getChildren(sm));
}
}
}
}
if (childReps[j] instanceof Segment) {
SegmentModel sModel = new SegmentModel((Segment) childReps[j], messParent, i, j);
@@ -463,11 +458,9 @@ public class HL7PublicUtil {
values.add(childReps[j]);
}
if (childReps[j] instanceof Group) {
values.add(childReps[j]);
allSegmentFromGroup.clear();
getAllSegmentsFromGroup((Group) childReps[j]);
if (allSegmentFromGroup.size() > 0) {
values.addAll(Arrays.asList(allSegmentFromGroup.toArray(new SegmentModel[0])));
}
}
if (childReps[j] instanceof Segment) {
SegmentModel sModel = new SegmentModel((Segment) childReps[j], messParent, i, j);

View File

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

View File

@@ -2,6 +2,5 @@
<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.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View File

@@ -2,6 +2,5 @@
<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.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View File

@@ -2,6 +2,5 @@
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/>
</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/cssparser-0.9.5.jar"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View File

@@ -3,6 +3,5 @@
<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.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View File

@@ -2,6 +2,5 @@
<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.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View File

@@ -2,6 +2,5 @@
<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.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View File

@@ -2,6 +2,5 @@
<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.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View File

@@ -5,6 +5,5 @@
<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.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="class"/>
</classpath>

View File

@@ -2,6 +2,5 @@
<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.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View File

@@ -2,6 +2,5 @@
<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.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View File

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

View File

@@ -2,7 +2,6 @@
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<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-structures-v21-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>
<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="src" path="src"/>
<classpathentry kind="output" path="bin"/>
</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.pde.core.requiredPlugins"/>
<classpathentry exported="true" kind="lib" path="lib/jboss-serialization.jar"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View File

@@ -2,6 +2,5 @@
<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.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View File

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

View File

@@ -2,6 +2,5 @@
<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.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View File

@@ -2,6 +2,5 @@
<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.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View File

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

View File

@@ -2,6 +2,5 @@
<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.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View File

@@ -2,6 +2,5 @@
<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.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View File

@@ -2,6 +2,5 @@
<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.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View File

@@ -4,6 +4,5 @@
<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.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src/main/java"/>
<classpathentry kind="output" path="class"/>
</classpath>

View File

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

View File

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

View File

@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<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.jar"/>

View File

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

View File

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

View File

@@ -2,6 +2,5 @@
<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.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View File

@@ -737,6 +737,12 @@ ImportItemUtil.taskMonitor=apply migration task {0} on item {1}
ImportItemUtil.tdqErrorInfor=Can't import tdq item {0}
ImportItemUtil.unknowException=Unknow language: {0}
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.ItemsList=Items List
ImportItemWizardPage.ImportDescription=Import items from an archive file or directory.
@@ -786,3 +792,10 @@ UseDynamicJobSelectionDialog.downBtnText=Down
RepositoryService.projectNotFound=The project '{0}' is not found.
RepositoryService.projectReadonlyTitle=Information
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.EPackage;
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.ResourceSet;
import org.eclipse.emf.ecore.resource.URIConverter;
@@ -641,6 +642,9 @@ public class ImportItemUtil {
final IProgressMonitor monitor) {
monitor.subTask(Messages.getString("ImportItemWizardPage.Importing") + itemRecord.getItemName()); //$NON-NLS-1$
resolveItem(manager, itemRecord);
if (!itemRecord.isValid()) {
return;
}
int num = 0;
for (Object obj : itemRecord.getResourceSet().getResources()) {
@@ -1478,6 +1482,20 @@ public class ImportItemUtil {
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) {
ItemRecord itemRecord = new ItemRecord(path);
computeProperty(collector, itemRecord);
@@ -1538,6 +1556,16 @@ public class ImportItemUtil {
final Item item = itemRecord.getItem();
boolean byteArray = (item instanceof FileItem);
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);
Resource resource = createResource(itemRecord, itemPath, byteArray);
@@ -1563,8 +1591,27 @@ public class ImportItemUtil {
Resource rfResource = createResource(itemRecord, itemPath, true);
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) {
// ignore
} finally {

View File

@@ -62,6 +62,7 @@ import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.DirectoryDialog;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.FileDialog;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
@@ -1036,6 +1037,23 @@ class ImportItemWizardPage extends WizardPage {
} 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;
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(), "set input"); //$NON-NLS-1$
repositoryTreeViewer.expandAll();
repositoryTreeViewer.expandToLevel(2);
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
@@ -610,7 +610,7 @@ class ViewerTextFilter extends ViewerFilter {
*/
class DatabaseTypeFilter extends ViewerFilter {
private String[] filterItems;
private final String[] filterItems;
public DatabaseTypeFilter(String[] filterItems) {
this.filterItems = filterItems;

View File

@@ -825,22 +825,37 @@ public abstract class JobScriptsManager {
IPath itemFilePath;
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$
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 {
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)
.append(itemName + itemVersionString + "." //$NON-NLS-1$ //$NON-NLS-2$
.append(itemName + itemVersionString + "." //$NON-NLS-1$
+ FileConstants.PROPERTIES_EXTENSION);
List<URL> metadataNameFileUrls = new ArrayList<URL>();
metadataNameFileUrls.add(FileLocator.toFileURL(itemFilePath.toFile().toURL()));
metadataNameFileUrls.add(FileLocator.toFileURL(propertiesFilePath.toFile().toURL()));
File itemFile = itemFilePath.toFile();
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
+ typeFolderPath.toString();

View File

@@ -12,10 +12,6 @@
// ============================================================================
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.FileInputStream;
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.TemplateProcessor;
import aQute.bnd.osgi.Analyzer;
import aQute.bnd.osgi.FileResource;
import aQute.bnd.osgi.Jar;
/**
* 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$;
//patch for TESB-12909
private boolean isRefJobBycTalendJob = false;
@Override
public List<ExportFileResource> getExportResources(ExportFileResource[] processes, String... codeOptions)
throws ProcessorException {
@@ -589,6 +592,11 @@ public class JobJavaScriptOSGIForESBManager extends JobJavaScriptsManager {
// job OSGi DataSources
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
Map<String, Object> contextParams = new HashMap<String, Object>();
contextParams.put("job", jobInfo); //$NON-NLS-1$
@@ -1033,4 +1041,8 @@ public class JobJavaScriptOSGIForESBManager extends JobJavaScriptsManager {
}
return providedModulesSet;
}
public void setIsRefJobByCTalendJob(boolean isRefJobBycTalendJob) {
this.isRefJobBycTalendJob = isRefJobBycTalendJob;
}
}