Compare commits
12 Commits
master
...
patch/5.3.
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
36f40e47c7 | ||
|
|
5a57a533c1 | ||
|
|
6659a31f24 | ||
|
|
60f0ca72a9 | ||
|
|
4e4b936c4b | ||
|
|
ab112c658c | ||
|
|
f4bf3a8efc | ||
|
|
3e32d94637 | ||
|
|
4ed1c20d19 | ||
|
|
439990117b | ||
|
|
d6d3883e15 | ||
|
|
c8659a0c0f |
@@ -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
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -81,7 +81,10 @@ public class ConnectionFigure extends PolylineConnection {
|
||||
|
||||
if (PluginChecker.isAutoParalelPluginLoaded()) {
|
||||
addParallelFigure();
|
||||
initFigureMap();
|
||||
// TDI-26611
|
||||
if (connection != null) {
|
||||
initFigureMap();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
@@ -244,10 +246,12 @@ public class WSDL2JAVAController extends AbstractElementPropertySectionControlle
|
||||
* org.talend.designer.core.ui.editor.properties2.editors.AbstractElementPropertySectionController#createCommand()
|
||||
*/
|
||||
private void generateJavaFile() {
|
||||
|
||||
final IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
|
||||
RepositoryWorkUnit<Object> workUnit = new RepositoryWorkUnit<Object>("", this) {//$NON-NLS-1$
|
||||
|
||||
final IWorkspaceRunnable op = new IWorkspaceRunnable() {
|
||||
|
||||
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() {
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -1,230 +1,230 @@
|
||||
// ============================================================================
|
||||
//
|
||||
// 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.designer.hl7;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.swt.widgets.Display;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
import org.talend.commons.ui.runtime.exception.ExceptionHandler;
|
||||
import org.talend.core.model.components.IODataComponent;
|
||||
import org.talend.core.model.metadata.ColumnNameChanged;
|
||||
import org.talend.core.model.metadata.IMetadataTable;
|
||||
import org.talend.core.model.process.AbstractExternalNode;
|
||||
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;
|
||||
|
||||
/**
|
||||
* DOC Administrator class global comment. Detailled comment
|
||||
*/
|
||||
public class HL7InputComponent extends AbstractExternalNode {
|
||||
|
||||
public static final String ROOT = "ROOT"; //$NON-NLS-1$
|
||||
|
||||
public static final String GROUP = "GROUP"; //$NON-NLS-1$
|
||||
|
||||
public static final String LOOP = "LOOP"; //$NON-NLS-1$
|
||||
|
||||
public static final String PATH = "PATH"; //$NON-NLS-1$
|
||||
|
||||
public static final String VALUE = "VALUE"; //$NON-NLS-1$
|
||||
|
||||
public static final String TYPE = "TYPE"; //$NON-NLS-1$
|
||||
|
||||
public static final String COLUMN = "COLUMN"; //$NON-NLS-1$
|
||||
|
||||
public static final String ATTRIBUTE = "ATTRIBUTE"; //$NON-NLS-1$s
|
||||
|
||||
public static final String ORDER = "ORDER"; //$NON-NLS-1$
|
||||
|
||||
private HL7Main hl7main;
|
||||
|
||||
@Override
|
||||
protected void renameMetadataColumnName(String conectionName, String oldColumnName, String newColumnName) {
|
||||
}
|
||||
|
||||
public IComponentDocumentation getComponentDocumentation(String componentName, String tempFolderPath) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public IExternalData getExternalData() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public IExternalData getTMapExternalData() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void initialize() {
|
||||
|
||||
}
|
||||
|
||||
public int open(Display display) {
|
||||
hl7main = new HL7Main(this);
|
||||
Shell shell = hl7main.createUI(display);
|
||||
while (!shell.isDisposed()) {
|
||||
try {
|
||||
if (!display.readAndDispatch()) {
|
||||
display.sleep();
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
if (hl7main.isStandAloneMode()) {
|
||||
e.printStackTrace();
|
||||
} else {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (hl7main.isStandAloneMode()) {
|
||||
display.dispose();
|
||||
}
|
||||
return hl7main.getHl7Manager().getUiManager().getUiResponse();
|
||||
}
|
||||
|
||||
public int open(Composite parent) {
|
||||
return open(parent.getDisplay());
|
||||
}
|
||||
|
||||
public void renameInputConnection(String oldName, String newName) {
|
||||
List<Map<String, String>> listRoot = (List<Map<String, String>>) this.getElementParameter(ROOT).getValue();
|
||||
boolean flagRoot = false;
|
||||
String schemaId = oldName + ":";
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
public void renameOutputConnection(String oldName, String newName) {
|
||||
|
||||
}
|
||||
|
||||
public void setExternalData(IExternalData persistentData) {
|
||||
|
||||
}
|
||||
|
||||
public IMetadataTable getMetadataTable() {
|
||||
try {
|
||||
return getMetadataList().get(0);
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")//$NON-NLS-1$
|
||||
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();
|
||||
if (eps == null) {
|
||||
return list;
|
||||
}
|
||||
for (int i = 0; i < eps.size(); i++) {
|
||||
IElementParameter parameter = eps.get(i);
|
||||
if (parameter.getFieldType() == EParameterFieldType.TABLE && parameter.getName().equals(paraName)) {
|
||||
list = (List<Map<String, String>>) parameter.getValue();
|
||||
break;
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public boolean istFileInputHL7() {
|
||||
return getComponent().getName().equals("tFileInputHL7"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
}
|
||||
|
||||
public boolean isHL7Output() {
|
||||
return getComponent().getName().equals("tHL7Output");//$NON-NLS-1$
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")//$NON-NLS-1$
|
||||
public boolean setTableElementParameter(List<Map<String, String>> epsl, String paraName) {
|
||||
List<IElementParameter> eps = (List<IElementParameter>) this.getElementParameters();
|
||||
boolean result = true;
|
||||
for (int i = 0; i < eps.size(); i++) {
|
||||
IElementParameter parameter = eps.get(i);
|
||||
if (parameter.getFieldType() == EParameterFieldType.TABLE && parameter.getName().equals(paraName)) {
|
||||
List<Map<String, String>> newValues = new ArrayList<Map<String, String>>();
|
||||
for (Map<String, String> map : epsl) {
|
||||
Map<String, String> newMap = new HashMap<String, String>();
|
||||
newMap.putAll(map);
|
||||
newValues.add(newMap);
|
||||
}
|
||||
|
||||
if (result) {
|
||||
parameter.setValue(newValues);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public void setValueToParameter(String paraName, Object value) {
|
||||
IElementParameter parameter = this.getElementParameter(paraName); //$NON-NLS-N$
|
||||
if (parameter != null && value != null) {
|
||||
parameter.setValue(value);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @seeorg.talend.core.model.process.AbstractExternalNode#metadataInputChanged(org.talend.core.model.components.
|
||||
* IODataComponent, java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public void metadataInputChanged(IODataComponent dataComponent, String connectionToApply) {
|
||||
super.metadataInputChanged(dataComponent, connectionToApply);
|
||||
List<Map<String, String>> listRoot = (List<Map<String, String>>) this.getElementParameter(ROOT).getValue();
|
||||
boolean flagRoot = false;
|
||||
|
||||
String schemaId = ""; //$NON-NLS-1$
|
||||
if (isHL7Output()) {
|
||||
schemaId = dataComponent.getConnection().getMetadataTable().getLabel() + ":"; //$NON-NLS-1$
|
||||
}
|
||||
|
||||
for (ColumnNameChanged col : dataComponent.getColumnNameChanged()) {
|
||||
for (Map<String, String> map : listRoot) {
|
||||
if (map.get(COLUMN).equals(schemaId + col.getOldName())) {
|
||||
map.put(COLUMN, schemaId + col.getNewName());
|
||||
flagRoot = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (flagRoot) {
|
||||
this.getElementParameter(ROOT).setValue(listRoot);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
// ============================================================================
|
||||
//
|
||||
// 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
|
||||
//
|
||||
// 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.designer.hl7;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.swt.widgets.Display;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
import org.talend.commons.ui.runtime.exception.ExceptionHandler;
|
||||
import org.talend.core.model.components.IODataComponent;
|
||||
import org.talend.core.model.metadata.ColumnNameChanged;
|
||||
import org.talend.core.model.metadata.IMetadataTable;
|
||||
import org.talend.core.model.process.AbstractExternalNode;
|
||||
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
|
||||
*/
|
||||
public class HL7InputComponent extends AbstractExternalNode {
|
||||
|
||||
public static final String ROOT = "ROOT"; //$NON-NLS-1$
|
||||
|
||||
public static final String GROUP = "GROUP"; //$NON-NLS-1$
|
||||
|
||||
public static final String LOOP = "LOOP"; //$NON-NLS-1$
|
||||
|
||||
public static final String PATH = "PATH"; //$NON-NLS-1$
|
||||
|
||||
public static final String VALUE = "VALUE"; //$NON-NLS-1$
|
||||
|
||||
public static final String TYPE = "TYPE"; //$NON-NLS-1$
|
||||
|
||||
public static final String COLUMN = "COLUMN"; //$NON-NLS-1$
|
||||
|
||||
public static final String ATTRIBUTE = "ATTRIBUTE"; //$NON-NLS-1$s
|
||||
|
||||
public static final String ORDER = "ORDER"; //$NON-NLS-1$
|
||||
|
||||
private HL7Main hl7main;
|
||||
|
||||
@Override
|
||||
protected void renameMetadataColumnName(String conectionName, String oldColumnName, String newColumnName) {
|
||||
}
|
||||
|
||||
public IComponentDocumentation getComponentDocumentation(String componentName, String tempFolderPath) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IExternalData getExternalData() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public IExternalData getTMapExternalData() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void initialize() {
|
||||
|
||||
}
|
||||
|
||||
public int open(Display display) {
|
||||
hl7main = new HL7Main(this);
|
||||
Shell shell = hl7main.createUI(display);
|
||||
while (!shell.isDisposed()) {
|
||||
try {
|
||||
if (!display.readAndDispatch()) {
|
||||
display.sleep();
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
if (hl7main.isStandAloneMode()) {
|
||||
e.printStackTrace();
|
||||
} else {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (hl7main.isStandAloneMode()) {
|
||||
display.dispose();
|
||||
}
|
||||
return hl7main.getHl7Manager().getUiManager().getUiResponse();
|
||||
}
|
||||
|
||||
public int open(Composite parent) {
|
||||
return open(parent.getDisplay());
|
||||
}
|
||||
|
||||
public void renameInputConnection(String oldName, String newName) {
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void renameOutputConnection(String oldName, String newName) {
|
||||
|
||||
}
|
||||
|
||||
public void setExternalData(IExternalData persistentData) {
|
||||
|
||||
}
|
||||
|
||||
public IMetadataTable getMetadataTable() {
|
||||
try {
|
||||
return getMetadataList().get(0);
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@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();
|
||||
if (eps == null) {
|
||||
return list;
|
||||
}
|
||||
for (int i = 0; i < eps.size(); i++) {
|
||||
IElementParameter parameter = eps.get(i);
|
||||
if (parameter.getFieldType() == EParameterFieldType.TABLE && parameter.getName().equals(paraName)) {
|
||||
list = (List<Map<String, String>>) parameter.getValue();
|
||||
break;
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public boolean istFileInputHL7() {
|
||||
return getComponent().getName().equals("tFileInputHL7"); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
public boolean isHL7Output() {
|
||||
return getComponent().getName().equals("tHL7Output");//$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;
|
||||
for (int i = 0; i < eps.size(); i++) {
|
||||
IElementParameter parameter = eps.get(i);
|
||||
if (parameter.getFieldType() == EParameterFieldType.TABLE && parameter.getName().equals(paraName)) {
|
||||
List<Map<String, String>> newValues = new ArrayList<Map<String, String>>();
|
||||
for (Map<String, String> map : epsl) {
|
||||
Map<String, String> newMap = new HashMap<String, String>();
|
||||
newMap.putAll(map);
|
||||
newValues.add(newMap);
|
||||
}
|
||||
|
||||
if (result) {
|
||||
parameter.setValue(newValues);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public void setValueToParameter(String paraName, Object value) {
|
||||
IElementParameter parameter = this.getElementParameter(paraName);
|
||||
if (parameter != null && value != null) {
|
||||
parameter.setValue(value);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @seeorg.talend.core.model.process.AbstractExternalNode#metadataInputChanged(org.talend.core.model.components.
|
||||
* IODataComponent, java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public void metadataInputChanged(IODataComponent dataComponent, String connectionToApply) {
|
||||
super.metadataInputChanged(dataComponent, connectionToApply);
|
||||
List<Map<String, String>> listRoot = (List<Map<String, String>>) this.getElementParameter(ROOT).getValue();
|
||||
boolean flagRoot = false;
|
||||
|
||||
String schemaId = ""; //$NON-NLS-1$
|
||||
if (isHL7Output()) {
|
||||
schemaId = dataComponent.getConnection().getMetadataTable().getLabel() + ":"; //$NON-NLS-1$
|
||||
}
|
||||
|
||||
for (ColumnNameChanged col : dataComponent.getColumnNameChanged()) {
|
||||
for (Map<String, String> map : listRoot) {
|
||||
if (map.get(COLUMN).equals(schemaId + col.getOldName())) {
|
||||
map.put(COLUMN, schemaId + col.getNewName());
|
||||
flagRoot = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (flagRoot) {
|
||||
this.getElementParameter(ROOT).setValue(listRoot);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,158 +1,207 @@
|
||||
// ============================================================================
|
||||
//
|
||||
// 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.designer.hl7.action;
|
||||
|
||||
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.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;
|
||||
|
||||
/**
|
||||
* bqian Create a xml node. <br/>
|
||||
*
|
||||
* $Id: CreateElementAction.java,v 1.1 2007/06/12 07:20:38 gke Exp $
|
||||
*
|
||||
*/
|
||||
public class CreateHL7ElementAction extends SelectionProviderAction {
|
||||
|
||||
// ============================================================================
|
||||
//
|
||||
// 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
|
||||
//
|
||||
// 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.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;
|
||||
import org.talend.designer.hl7.ui.data.HL7TreeNode;
|
||||
import org.talend.designer.hl7.ui.data.NameSpaceNode;
|
||||
import org.talend.repository.ui.swt.utils.AbstractForm;
|
||||
|
||||
/**
|
||||
* bqian Create a xml node. <br/>
|
||||
*
|
||||
* $Id: CreateElementAction.java,v 1.1 2007/06/12 07:20:38 gke Exp $
|
||||
*
|
||||
*/
|
||||
public class CreateHL7ElementAction extends SelectionProviderAction {
|
||||
|
||||
// the xml viewer, see HL7UI.
|
||||
private TreeViewer xmlViewer;
|
||||
|
||||
private HL7UI hl7ui;
|
||||
|
||||
private AbstractForm from;
|
||||
|
||||
/**
|
||||
* CreateNode constructor comment.
|
||||
*
|
||||
* @param provider
|
||||
* @param text
|
||||
*/
|
||||
public CreateHL7ElementAction(TreeViewer xmlViewer, String text) {
|
||||
super(xmlViewer, text);
|
||||
this.xmlViewer = xmlViewer;
|
||||
}
|
||||
|
||||
public CreateHL7ElementAction(TreeViewer xmlViewer, String text, AbstractForm from) {
|
||||
super(xmlViewer, text);
|
||||
this.xmlViewer = xmlViewer;
|
||||
this.from = from;
|
||||
}
|
||||
|
||||
public CreateHL7ElementAction(TreeViewer xmlViewer, HL7UI hl7ui, String text) {
|
||||
super(xmlViewer, text);
|
||||
this.xmlViewer = xmlViewer;
|
||||
this.hl7ui = hl7ui;
|
||||
}
|
||||
|
||||
public void init() {
|
||||
HL7TreeNode node = (HL7TreeNode) this.getStructuredSelection().getFirstElement();
|
||||
|
||||
if (node == null) {
|
||||
this.setEnabled(false);
|
||||
return;
|
||||
}
|
||||
// if (node.getParent() == null) {
|
||||
// this.setEnabled(false);
|
||||
// return;
|
||||
// }
|
||||
|
||||
if (node instanceof Attribute) {
|
||||
this.setEnabled(false);
|
||||
return;
|
||||
}
|
||||
|
||||
if (node instanceof NameSpaceNode) {
|
||||
this.setEnabled(false);
|
||||
return;
|
||||
}
|
||||
this.setEnabled(true);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.jface.action.Action#run()
|
||||
*/
|
||||
@Override
|
||||
public void run() {
|
||||
HL7TreeNode node = (HL7TreeNode) this.getStructuredSelection().getFirstElement();
|
||||
if (createChildNode(node)) {
|
||||
if (hl7ui != null) {
|
||||
hl7ui.redrawLinkers();
|
||||
} else if (from != null) {
|
||||
from.refreshLinks();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the child node of the input node
|
||||
*
|
||||
* @param node
|
||||
*/
|
||||
private boolean createChildNode(HL7TreeNode node) {
|
||||
if (node.getColumn() != null) {
|
||||
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;
|
||||
}
|
||||
node.setColumn(null);
|
||||
}
|
||||
String label = "";
|
||||
final String nodeLabel = node.getLabel() + "-";
|
||||
while (!StringUtil.validateLabelForXML(label)) {
|
||||
InputDialog dialog = new InputDialog(null, "Input element's label", "Input the new element's valid label", nodeLabel,
|
||||
null) {
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.jface.dialogs.Dialog#okPressed()
|
||||
*/
|
||||
@Override
|
||||
protected void okPressed() {
|
||||
String eleName = this.getValue();
|
||||
// if (eleName.startsWith(nodeLabel)) {
|
||||
super.okPressed();
|
||||
// } else {
|
||||
// setErrorMessage("Element's label must start with " + "\"" + nodeLabel + "\"");
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
dialog.setErrorMessage("name is error");
|
||||
int status = dialog.open();
|
||||
if (status == InputDialog.OK) {
|
||||
label = dialog.getValue().trim();
|
||||
}
|
||||
if (status == InputDialog.CANCEL) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
HL7TreeNode child = new Element(label);
|
||||
child.setRow(node.getRow());
|
||||
node.addChild(child);
|
||||
this.xmlViewer.refresh();
|
||||
this.xmlViewer.expandAll();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
private TreeViewer xmlViewer;
|
||||
|
||||
private HL7UI hl7ui;
|
||||
|
||||
private AbstractForm from;
|
||||
|
||||
/**
|
||||
* CreateNode constructor comment.
|
||||
*
|
||||
* @param provider
|
||||
* @param text
|
||||
*/
|
||||
public CreateHL7ElementAction(TreeViewer xmlViewer, String text) {
|
||||
super(xmlViewer, text);
|
||||
this.xmlViewer = xmlViewer;
|
||||
}
|
||||
|
||||
public CreateHL7ElementAction(TreeViewer xmlViewer, String text, AbstractForm from) {
|
||||
super(xmlViewer, text);
|
||||
this.xmlViewer = xmlViewer;
|
||||
this.from = from;
|
||||
}
|
||||
|
||||
public CreateHL7ElementAction(TreeViewer xmlViewer, HL7UI hl7ui, String text) {
|
||||
super(xmlViewer, text);
|
||||
this.xmlViewer = xmlViewer;
|
||||
this.hl7ui = hl7ui;
|
||||
}
|
||||
|
||||
public void init() {
|
||||
HL7TreeNode node = (HL7TreeNode) this.getStructuredSelection().getFirstElement();
|
||||
|
||||
if (node == null) {
|
||||
this.setEnabled(false);
|
||||
return;
|
||||
}
|
||||
// if (node.getParent() == null) {
|
||||
// this.setEnabled(false);
|
||||
// return;
|
||||
// }
|
||||
|
||||
if (node instanceof Attribute) {
|
||||
this.setEnabled(false);
|
||||
return;
|
||||
}
|
||||
|
||||
if (node instanceof NameSpaceNode) {
|
||||
this.setEnabled(false);
|
||||
return;
|
||||
}
|
||||
this.setEnabled(true);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.jface.action.Action#run()
|
||||
*/
|
||||
@Override
|
||||
public void run() {
|
||||
HL7TreeNode node = (HL7TreeNode) this.getStructuredSelection().getFirstElement();
|
||||
createChildNode(node);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the child node of the input node
|
||||
*
|
||||
* @param node
|
||||
*/
|
||||
private boolean createChildNode(final HL7TreeNode node) {
|
||||
if (node.getColumn() != null) {
|
||||
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;
|
||||
}
|
||||
node.setColumn(null);
|
||||
}
|
||||
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,
|
||||
validator) {
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.jface.dialogs.Dialog#okPressed()
|
||||
*/
|
||||
@Override
|
||||
protected void okPressed() {
|
||||
super.okPressed();
|
||||
}
|
||||
|
||||
};
|
||||
dialog.setErrorMessage("name is error");
|
||||
int status = dialog.open();
|
||||
if (status == InputDialog.OK) {
|
||||
label = dialog.getValue().trim();
|
||||
}
|
||||
if (status == InputDialog.CANCEL) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
HL7TreeNode child = new Element(label);
|
||||
// if the root not have CurSchema
|
||||
if (node.getRow() == null || node.getRow().equals("")) {
|
||||
if (hl7ui != null && hl7ui.gethl7Manager() instanceof HL7OutputManager) {
|
||||
if (label.length() == 3) {
|
||||
child.setRow(label);
|
||||
IMetadataTable table = null;
|
||||
for (IMetadataTable curTable : hl7ui.gethl7Manager().getHl7Component().getMetadataList()) {
|
||||
if (label.equals(curTable.getLabel())) {
|
||||
table = curTable;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (table == null) {
|
||||
table = new MetadataTable();
|
||||
table.setLabel(label);
|
||||
table.setTableName(label);
|
||||
hl7ui.gethl7Manager().getHl7Component().getMetadataList().add(table);
|
||||
}
|
||||
List<Map<String, String>> maps = (List<Map<String, String>>) hl7ui.gethl7Manager().getHl7Component()
|
||||
.getElementParameter("SCHEMAS").getValue(); //$NON-NLS-1$
|
||||
boolean found = false;
|
||||
for (Map<String, String> map : maps) {
|
||||
if (map.get("SCHEMA").equals(table.getTableName())) {
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
if (!found) {
|
||||
Map<String, String> hl7Schema = new HashMap<String, String>();
|
||||
maps.add(hl7Schema);
|
||||
hl7Schema.put("SCHEMA", table.getTableName());
|
||||
}
|
||||
}
|
||||
} else if (label.length() == 3) {
|
||||
child.setRow(label);
|
||||
}
|
||||
} else {
|
||||
child.setRow(node.getRow());
|
||||
}
|
||||
node.addChild(child);
|
||||
this.xmlViewer.refresh();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,136 +1,116 @@
|
||||
// ============================================================================
|
||||
//
|
||||
// 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.designer.hl7.action;
|
||||
|
||||
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;
|
||||
|
||||
/**
|
||||
* bqian Create a xml node. <br/>
|
||||
*
|
||||
* $Id: DeleteNodeAction.java,v 1.1 2007/06/12 07:20:38 gke Exp $
|
||||
*
|
||||
*/
|
||||
public class DeleteHL7NodeAction extends SelectionProviderAction {
|
||||
|
||||
// the xml viewer, see HL7UI.
|
||||
private TreeViewer xmlViewer;
|
||||
|
||||
private HL7UI hl7ui;
|
||||
|
||||
private AbstractForm form;
|
||||
|
||||
/**
|
||||
* CreateNode constructor comment.
|
||||
*
|
||||
* @param provider
|
||||
* @param text
|
||||
*/
|
||||
public DeleteHL7NodeAction(TreeViewer xmlViewer, String text) {
|
||||
super(xmlViewer, text);
|
||||
this.xmlViewer = xmlViewer;
|
||||
}
|
||||
|
||||
public DeleteHL7NodeAction(TreeViewer xmlViewer, String text, AbstractForm form) {
|
||||
super(xmlViewer, text);
|
||||
this.xmlViewer = xmlViewer;
|
||||
this.form = form;
|
||||
}
|
||||
|
||||
public DeleteHL7NodeAction(TreeViewer xmlViewer, HL7UI hl7ui, String text) {
|
||||
super(xmlViewer, text);
|
||||
this.xmlViewer = xmlViewer;
|
||||
this.hl7ui = hl7ui;
|
||||
}
|
||||
|
||||
public void init() {
|
||||
HL7TreeNode node = (HL7TreeNode) this.getStructuredSelection().getFirstElement();
|
||||
if (node == null) {
|
||||
this.setEnabled(false);
|
||||
} else {
|
||||
if (node.getParent() == null) {
|
||||
this.setEnabled(false);
|
||||
} else {
|
||||
this.setEnabled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.jface.action.Action#run()
|
||||
*/
|
||||
@Override
|
||||
public void run() {
|
||||
HL7TreeNode node = (HL7TreeNode) this.getStructuredSelection().getFirstElement();
|
||||
if (node == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
HL7TreeNode parent = node.getParent();
|
||||
if (parent == null) {
|
||||
return;
|
||||
}
|
||||
if (node instanceof Element) {
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* DOC ke Comment method "disconnectSubTree".
|
||||
*
|
||||
* @param node
|
||||
*/
|
||||
private void disconnectSubTree(HL7TreeNode node) {
|
||||
if (node == null) {
|
||||
return;
|
||||
}
|
||||
if (node.hasLink()) {
|
||||
node.setColumn(null);
|
||||
}
|
||||
if (node instanceof Attribute) {
|
||||
return;
|
||||
}
|
||||
if (node instanceof NameSpaceNode) {
|
||||
return;
|
||||
}
|
||||
List<HL7TreeNode> children = node.getChildren();
|
||||
for (HL7TreeNode child : children) {
|
||||
disconnectSubTree(child);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
// ============================================================================
|
||||
//
|
||||
// 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
|
||||
//
|
||||
// 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.designer.hl7.action;
|
||||
|
||||
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.Element;
|
||||
import org.talend.designer.hl7.ui.data.HL7TreeNode;
|
||||
import org.talend.repository.ui.swt.utils.AbstractForm;
|
||||
|
||||
/**
|
||||
* bqian Create a xml node. <br/>
|
||||
*
|
||||
* $Id: DeleteNodeAction.java,v 1.1 2007/06/12 07:20:38 gke Exp $
|
||||
*
|
||||
*/
|
||||
public class DeleteHL7NodeAction extends SelectionProviderAction {
|
||||
|
||||
// the xml viewer, see HL7UI.
|
||||
private TreeViewer xmlViewer;
|
||||
|
||||
private HL7UI hl7ui;
|
||||
|
||||
private AbstractForm form;
|
||||
|
||||
/**
|
||||
* CreateNode constructor comment.
|
||||
*
|
||||
* @param provider
|
||||
* @param text
|
||||
*/
|
||||
public DeleteHL7NodeAction(TreeViewer xmlViewer, String text) {
|
||||
super(xmlViewer, text);
|
||||
this.xmlViewer = xmlViewer;
|
||||
}
|
||||
|
||||
public DeleteHL7NodeAction(TreeViewer xmlViewer, String text, AbstractForm form) {
|
||||
super(xmlViewer, text);
|
||||
this.xmlViewer = xmlViewer;
|
||||
this.form = form;
|
||||
}
|
||||
|
||||
public DeleteHL7NodeAction(TreeViewer xmlViewer, HL7UI hl7ui, String text) {
|
||||
super(xmlViewer, text);
|
||||
this.xmlViewer = xmlViewer;
|
||||
this.hl7ui = hl7ui;
|
||||
}
|
||||
|
||||
public void init() {
|
||||
HL7TreeNode node = (HL7TreeNode) this.getStructuredSelection().getFirstElement();
|
||||
if (node == null) {
|
||||
this.setEnabled(false);
|
||||
} else {
|
||||
if (node.getParent() == null) {
|
||||
this.setEnabled(false);
|
||||
} else {
|
||||
this.setEnabled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.jface.action.Action#run()
|
||||
*/
|
||||
@Override
|
||||
public void run() {
|
||||
HL7TreeNode node = (HL7TreeNode) this.getStructuredSelection().getFirstElement();
|
||||
if (node == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
HL7TreeNode parent = node.getParent();
|
||||
if (parent == null) {
|
||||
return;
|
||||
}
|
||||
if (node instanceof Element) {
|
||||
disconnectSubTree(node);
|
||||
}
|
||||
parent.removeChild(node);
|
||||
xmlViewer.refresh(parent);
|
||||
}
|
||||
|
||||
/**
|
||||
* DOC ke Comment method "disconnectSubTree".
|
||||
*
|
||||
* @param node
|
||||
*/
|
||||
private void disconnectSubTree(HL7TreeNode node) {
|
||||
if (node == null) {
|
||||
return;
|
||||
}
|
||||
if (node.hasLink()) {
|
||||
node.setColumn(null);
|
||||
}
|
||||
List<HL7TreeNode> children = node.getChildren();
|
||||
for (HL7TreeNode child : children) {
|
||||
disconnectSubTree(child);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,429 +1,437 @@
|
||||
// ============================================================================
|
||||
//
|
||||
// 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.designer.hl7.action;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.eclipse.emf.common.util.EList;
|
||||
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.core.model.metadata.builder.connection.HL7Connection;
|
||||
import org.talend.core.model.metadata.builder.connection.HL7FileNode;
|
||||
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 ca.uhn.hl7v2.model.Message;
|
||||
|
||||
/**
|
||||
* DOC hwang class global comment. Detailled comment
|
||||
*/
|
||||
public class ImportHL7StructureAction extends SelectionProviderAction {
|
||||
|
||||
private TreeViewer xmlViewer;
|
||||
|
||||
private HL7UI hl7ui;
|
||||
|
||||
private AbstractHL7StepForm form;
|
||||
|
||||
private int order = 1;
|
||||
|
||||
private HL7Connection hl7Connection;
|
||||
|
||||
private HL7PublicUtil hl7Util = new HL7PublicUtil();
|
||||
|
||||
private Map<String, Integer> orderMap = new HashMap<String, Integer>();
|
||||
|
||||
/**
|
||||
* Create constructor comment.
|
||||
*
|
||||
* @param provider
|
||||
* @param text
|
||||
*/
|
||||
public ImportHL7StructureAction(HL7Connection hl7Connection, TreeViewer xmlViewer, String text, AbstractHL7StepForm form) {
|
||||
super(xmlViewer, text);
|
||||
this.xmlViewer = xmlViewer;
|
||||
this.form = form;
|
||||
this.hl7Connection = hl7Connection;
|
||||
}
|
||||
|
||||
public ImportHL7StructureAction(TreeViewer xmlViewer, HL7UI hl7ui, String text) {
|
||||
super(xmlViewer, text);
|
||||
this.xmlViewer = xmlViewer;
|
||||
this.hl7ui = hl7ui;
|
||||
}
|
||||
|
||||
private List treeNodeAdapt() {
|
||||
List<HL7TreeNode> list = new ArrayList<HL7TreeNode>();
|
||||
FileDialog f = null;
|
||||
if (hl7ui != null) {
|
||||
f = new FileDialog(hl7ui.getHl7UIParent().getShell());
|
||||
} else if (form != null) {
|
||||
f = new FileDialog(form.getShell());
|
||||
}
|
||||
String file = f.open();
|
||||
if (file == null) {
|
||||
return list;
|
||||
}
|
||||
HL7Parse hl7Parse = new HL7Parse();
|
||||
List<String> msgContentList = new ArrayList<String>();
|
||||
|
||||
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>();
|
||||
if (hl7Connection != null) {
|
||||
EList root = hl7Connection.getRoot();
|
||||
root.clear();
|
||||
if (hl7TreeNode != null) {
|
||||
hl7Util.initNodeOrder(hl7TreeNode, orderMap, order);
|
||||
hl7Util.tableLoader((Element) hl7TreeNode, "", root, hl7TreeNode.getDefaultValue(), orderMap);
|
||||
}
|
||||
table.addAll(root);
|
||||
} else {
|
||||
if (hl7TreeNode != null) {
|
||||
hl7Util.initNodeOrder(hl7TreeNode, orderMap, order);
|
||||
hl7Util.tableLoader((Element) hl7TreeNode, "", table, hl7TreeNode.getDefaultValue(), orderMap);
|
||||
}
|
||||
}
|
||||
|
||||
// list.add(hl7TreeNode);
|
||||
initXmlTreeData(schemaList, table, list);
|
||||
}
|
||||
|
||||
// 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;
|
||||
}
|
||||
|
||||
private void initXmlTreeData(List schemaList, List<HL7FileNode> root, List<HL7TreeNode> list) {
|
||||
if (hl7ui != null) {
|
||||
if (hl7ui.gethl7Manager() instanceof HL7OutputManager) {
|
||||
((HL7OutputManager) hl7ui.gethl7Manager()).getContents().clear();
|
||||
}
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
// build group tree
|
||||
current = mainNode;
|
||||
currentPath = mainPath;
|
||||
boolean isFirst = true;
|
||||
|
||||
// build loop tree
|
||||
current = mainNode;
|
||||
currentPath = mainPath;
|
||||
isFirst = true;
|
||||
|
||||
if (rootNode == null) {
|
||||
rootNode = new Element("rootTag");
|
||||
}
|
||||
// rootNode.setParent(null);
|
||||
if (haveOrder) {
|
||||
orderNode(rootNode);
|
||||
}
|
||||
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 (haveOrder) {
|
||||
// orderNode(rootNode);
|
||||
// }
|
||||
// treeData.add(rootNode);
|
||||
// rootNode.setRow(metadataTable.getLabel());
|
||||
//
|
||||
}
|
||||
|
||||
private void orderNode(HL7TreeNode node) {
|
||||
// reset the order.
|
||||
if (node != null) {
|
||||
List<HL7TreeNode> firstSubChildren = node.getChildren();
|
||||
HL7TreeNode foundNode = null;
|
||||
for (HL7TreeNode childen : firstSubChildren) {
|
||||
if (childen.isRepetable()) {
|
||||
foundNode = childen;
|
||||
sortOrder(foundNode, node);
|
||||
break;
|
||||
} else if (childen.isGroup()) {
|
||||
foundNode = childen;
|
||||
sortOrder(foundNode, node);
|
||||
orderNode(childen);
|
||||
} else {
|
||||
orderNode(childen);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void sortOrder(HL7TreeNode treeNode, HL7TreeNode node) {
|
||||
if (node != null) {
|
||||
List<HL7TreeNode> children = node.getChildren();
|
||||
if (treeNode != null) {
|
||||
int tmpOrder = 0;
|
||||
int attrNsCount = 0;
|
||||
for (HL7TreeNode child : children) {
|
||||
if (child.getOrder() < treeNode.getOrder()) {
|
||||
tmpOrder++;
|
||||
}
|
||||
if (child.isAttribute() || child.isNameSpace()) {
|
||||
attrNsCount++;
|
||||
}
|
||||
}
|
||||
if (tmpOrder > -1) {
|
||||
int oldOrder = children.indexOf(treeNode);
|
||||
if (oldOrder != -1 && oldOrder != tmpOrder) {
|
||||
node.removeChild(treeNode);
|
||||
if (children.size() > tmpOrder) {
|
||||
node.addChild(tmpOrder - attrNsCount, treeNode);
|
||||
} else {
|
||||
node.addChild(treeNode);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
HL7TreeNode parent = current;
|
||||
for (int i = 0; i < nods.length - (parentLevel + 1); i++) {
|
||||
HL7TreeNode tmpParent = parent.getParent();
|
||||
if (tmpParent == null) {
|
||||
break;
|
||||
}
|
||||
parent = tmpParent;
|
||||
}
|
||||
|
||||
if (parent != null)
|
||||
parent.addChild(temp);
|
||||
}
|
||||
|
||||
return temp;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* wzhang Comment method "getSelectedSchema".
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
private String getSelectedSchema() {
|
||||
TreeItem[] selection = xmlViewer.getTree().getSelection();
|
||||
if (selection.length > 0) {
|
||||
Object data = selection[0].getData();
|
||||
if (data instanceof HL7TreeNode) {
|
||||
return ((HL7TreeNode) data).getRow();
|
||||
}
|
||||
}
|
||||
return "";// hl7ui.gethl7Manager().getCurrentSchema();
|
||||
}
|
||||
|
||||
public void init() {
|
||||
this.setEnabled(true);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.jface.action.Action#run()
|
||||
*/
|
||||
@Override
|
||||
public void run() {
|
||||
List<HL7TreeNode> newInput = treeNodeAdapt();
|
||||
if (newInput.size() == 0) {
|
||||
return;
|
||||
}
|
||||
List<HL7TreeNode> treeData = null;
|
||||
if (form != null) {
|
||||
treeData = form.getTreeData();
|
||||
|
||||
} else if (hl7ui != null) {
|
||||
if (hl7ui.gethl7Manager() instanceof HL7OutputManager) {
|
||||
treeData = ((HL7OutputManager) hl7ui.gethl7Manager()).getTreeData();
|
||||
}
|
||||
}
|
||||
treeData.clear();
|
||||
treeData.addAll(newInput);
|
||||
xmlViewer.setInput(treeData);
|
||||
// TreeUtil.guessAndSetLoopNode((HL7TreeNode) xmlViewer.getTree().getItem(0).getData());
|
||||
xmlViewer.refresh();
|
||||
xmlViewer.expandAll();
|
||||
// hl7ui.updateStatus();
|
||||
// hl7ui.redrawLinkers();
|
||||
if (hl7ui != null) {
|
||||
hl7ui.redrawLinkers();
|
||||
} else if (form != null) {
|
||||
form.refreshLinks();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* org.eclipse.ui.actions.SelectionProviderAction#selectionChanged(org.eclipse.jface.viewers.IStructuredSelection)
|
||||
*/
|
||||
@Override
|
||||
public void selectionChanged(IStructuredSelection selection) {
|
||||
this.setEnabled(true);
|
||||
HL7TreeNode node = (HL7TreeNode) this.getStructuredSelection().getFirstElement();
|
||||
if (node != null && form != null) {
|
||||
// hl7ui.setSelectedText(node.getLabel());
|
||||
// Added by Marvin Wang on Sep. 11, 2012 for bug TDI-20702.
|
||||
form.setSelectedText(node.getLabel());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
// ============================================================================
|
||||
//
|
||||
// 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
|
||||
//
|
||||
// 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.designer.hl7.action;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
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.Element;
|
||||
import org.talend.designer.hl7.ui.data.HL7TreeNode;
|
||||
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;
|
||||
|
||||
/**
|
||||
* DOC hwang class global comment. Detailled comment
|
||||
*/
|
||||
public class ImportHL7StructureAction extends SelectionProviderAction {
|
||||
|
||||
private TreeViewer xmlViewer;
|
||||
|
||||
private HL7UI hl7ui;
|
||||
|
||||
private AbstractHL7StepForm form;
|
||||
|
||||
private HL7Connection hl7Connection;
|
||||
|
||||
private HL7PublicUtil hl7Util = new HL7PublicUtil();
|
||||
|
||||
private Map<String, Integer> orderMap = new HashMap<String, Integer>();
|
||||
|
||||
/**
|
||||
* Create constructor comment.
|
||||
*
|
||||
* @param provider
|
||||
* @param text
|
||||
*/
|
||||
public ImportHL7StructureAction(HL7Connection hl7Connection, TreeViewer xmlViewer, String text, AbstractHL7StepForm form) {
|
||||
super(xmlViewer, text);
|
||||
this.xmlViewer = xmlViewer;
|
||||
this.form = form;
|
||||
this.hl7Connection = hl7Connection;
|
||||
}
|
||||
|
||||
public ImportHL7StructureAction(TreeViewer xmlViewer, HL7UI hl7ui, String text) {
|
||||
super(xmlViewer, text);
|
||||
this.xmlViewer = xmlViewer;
|
||||
this.hl7ui = hl7ui;
|
||||
}
|
||||
|
||||
private List treeNodeAdapt() {
|
||||
List<HL7TreeNode> treeData = new ArrayList<HL7TreeNode>();
|
||||
FileDialog f = null;
|
||||
if (hl7ui != null) {
|
||||
f = new FileDialog(hl7ui.getHl7UIParent().getShell());
|
||||
} else if (form != null) {
|
||||
f = new FileDialog(form.getShell());
|
||||
}
|
||||
String file = f.open();
|
||||
if (file == null) {
|
||||
return treeData;
|
||||
}
|
||||
HL7Parse hl7Parse = new HL7Parse();
|
||||
List<String> msgContentList = new ArrayList<String>();
|
||||
|
||||
List<Message> messageList = hl7Parse.doParse(file, "'\\u000b'", "'\\u001c'");
|
||||
List<HL7TreeNode> nodeList = hl7Util.getHL7TreeNodes(messageList);
|
||||
|
||||
if (!nodeList.isEmpty()) {
|
||||
HL7TreeNode hl7TreeNode = nodeList.get(0);
|
||||
List<HL7FileNode> table = new ArrayList<HL7FileNode>();
|
||||
if (hl7Connection != null) {
|
||||
EList root = hl7Connection.getRoot();
|
||||
root.clear();
|
||||
if (hl7TreeNode != null) {
|
||||
hl7Util.initNodeOrder(hl7TreeNode, orderMap);
|
||||
hl7Util.tableLoader((Element) hl7TreeNode, "", root, hl7TreeNode.getDefaultValue(), orderMap);
|
||||
}
|
||||
table.addAll(root);
|
||||
} else {
|
||||
if (hl7TreeNode != null) {
|
||||
hl7Util.initNodeOrder(hl7TreeNode, orderMap);
|
||||
hl7Util.tableLoader((Element) hl7TreeNode, "", table, hl7TreeNode.getDefaultValue(), orderMap);
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
return treeData;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
MetadataTable targetMetadataTable = ConnectionFactory.eINSTANCE.createMetadataTable();
|
||||
targetMetadataTable.setId(factory.getNextId());
|
||||
schemaNameToOutputTable.put(schemaName, targetMetadataTable);
|
||||
targetMetadataTable.setLabel(schemaName);
|
||||
iMetadataTables.add(targetMetadataTable);
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
if (haveOrder) {
|
||||
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);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
} 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) {
|
||||
// reset the order.
|
||||
if (node != null) {
|
||||
List<HL7TreeNode> firstSubChildren = node.getChildren();
|
||||
HL7TreeNode foundNode = null;
|
||||
for (HL7TreeNode childen : firstSubChildren) {
|
||||
if (childen.isRepetable()) {
|
||||
foundNode = childen;
|
||||
sortOrder(foundNode, node);
|
||||
break;
|
||||
} else if (childen.isGroup()) {
|
||||
foundNode = childen;
|
||||
sortOrder(foundNode, node);
|
||||
orderNode(childen);
|
||||
} else {
|
||||
orderNode(childen);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void sortOrder(HL7TreeNode treeNode, HL7TreeNode node) {
|
||||
if (node != null) {
|
||||
List<HL7TreeNode> children = node.getChildren();
|
||||
if (treeNode != null) {
|
||||
int tmpOrder = 0;
|
||||
int attrNsCount = 0;
|
||||
for (HL7TreeNode child : children) {
|
||||
if (child.getOrder() < treeNode.getOrder()) {
|
||||
tmpOrder++;
|
||||
}
|
||||
if (child.isAttribute() || child.isNameSpace()) {
|
||||
attrNsCount++;
|
||||
}
|
||||
}
|
||||
if (tmpOrder > -1) {
|
||||
int oldOrder = children.indexOf(treeNode);
|
||||
if (oldOrder != -1 && oldOrder != tmpOrder) {
|
||||
node.removeChild(treeNode);
|
||||
if (children.size() > tmpOrder) {
|
||||
node.addChild(tmpOrder - attrNsCount, treeNode);
|
||||
} else {
|
||||
node.addChild(treeNode);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
return temp;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* wzhang Comment method "getSelectedSchema".
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
private String getSelectedSchema() {
|
||||
TreeItem[] selection = xmlViewer.getTree().getSelection();
|
||||
if (selection.length > 0) {
|
||||
Object data = selection[0].getData();
|
||||
if (data instanceof HL7TreeNode) {
|
||||
return ((HL7TreeNode) data).getRow();
|
||||
}
|
||||
}
|
||||
return "";// hl7ui.gethl7Manager().getCurrentSchema();
|
||||
}
|
||||
|
||||
public void init() {
|
||||
this.setEnabled(true);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.jface.action.Action#run()
|
||||
*/
|
||||
@Override
|
||||
public void run() {
|
||||
List<HL7TreeNode> newInput = treeNodeAdapt();
|
||||
if (newInput.size() == 0) {
|
||||
return;
|
||||
}
|
||||
List<HL7TreeNode> treeData = null;
|
||||
if (form != null) {
|
||||
treeData = form.getTreeData();
|
||||
|
||||
} else if (hl7ui != null) {
|
||||
if (hl7ui.gethl7Manager() instanceof HL7OutputManager) {
|
||||
treeData = ((HL7OutputManager) hl7ui.gethl7Manager()).getTreeData();
|
||||
}
|
||||
}
|
||||
treeData.clear();
|
||||
treeData.addAll(newInput);
|
||||
xmlViewer.setInput(treeData);
|
||||
// TreeUtil.guessAndSetLoopNode((HL7TreeNode) xmlViewer.getTree().getItem(0).getData());
|
||||
xmlViewer.refresh();
|
||||
xmlViewer.expandAll();
|
||||
// hl7ui.updateStatus();
|
||||
// hl7ui.redrawLinkers();
|
||||
if (hl7ui != null) {
|
||||
hl7ui.redrawLinkers();
|
||||
} else if (form != null) {
|
||||
form.refreshLinks();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* org.eclipse.ui.actions.SelectionProviderAction#selectionChanged(org.eclipse.jface.viewers.IStructuredSelection)
|
||||
*/
|
||||
@Override
|
||||
public void selectionChanged(IStructuredSelection selection) {
|
||||
this.setEnabled(true);
|
||||
HL7TreeNode node = (HL7TreeNode) this.getStructuredSelection().getFirstElement();
|
||||
if (node != null && form != null) {
|
||||
// hl7ui.setSelectedText(node.getLabel());
|
||||
// Added by Marvin Wang on Sep. 11, 2012 for bug TDI-20702.
|
||||
form.setSelectedText(node.getLabel());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,167 +1,113 @@
|
||||
// ============================================================================
|
||||
//
|
||||
// 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.designer.hl7.action;
|
||||
|
||||
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;
|
||||
|
||||
/**
|
||||
* bqian Create a xml node. <br/>
|
||||
*
|
||||
* $Id: CreateElementAction.java,v 1.1 2007/06/12 07:20:38 gke Exp $
|
||||
*
|
||||
*/
|
||||
public class SetRepetableAction extends SelectionProviderAction {
|
||||
|
||||
// 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);
|
||||
this.xmlViewer = xmlViewer;
|
||||
}
|
||||
|
||||
public SetRepetableAction(TreeViewer xmlViewer, String text, AbstractForm form) {
|
||||
super(xmlViewer, text);
|
||||
this.xmlViewer = xmlViewer;
|
||||
this.form = form;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* SetForLoopAction constructor comment.
|
||||
*
|
||||
* @param xmlViewer
|
||||
* @param text
|
||||
* @param hl7ui
|
||||
*/
|
||||
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() {
|
||||
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);
|
||||
return;
|
||||
}
|
||||
if (!node.isMain()) {
|
||||
this.setEnabled(false);
|
||||
return;
|
||||
}
|
||||
|
||||
if (node instanceof Attribute) {
|
||||
this.setEnabled(false);
|
||||
return;
|
||||
}
|
||||
|
||||
if (node instanceof NameSpaceNode) {
|
||||
this.setEnabled(false);
|
||||
return;
|
||||
}
|
||||
this.setEnabled(true);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.jface.action.Action#run()
|
||||
*/
|
||||
@Override
|
||||
public void run() {
|
||||
HL7TreeNode node = (HL7TreeNode) this.getStructuredSelection().getFirstElement();
|
||||
if (node.isRepetable()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// HL7Manager hl7Manager = hl7ui.gethl7Manager();
|
||||
|
||||
// HL7TreeNode rootTreeData = hl7Manager.getRootHL7TreeNode(node);
|
||||
// TreeUtil.clearSubGroupNode(node);
|
||||
// // make sure group element is a ancestor of loop, or no group element.
|
||||
// if (TreeUtil.findUpGroupNode(node) == null) {
|
||||
// TreeUtil.clearSubGroupNode(rootTreeData);
|
||||
// }
|
||||
// TreeUtil.clearLoopNode(rootTreeData);
|
||||
// TreeUtil.clearMainNode(rootTreeData);
|
||||
|
||||
if (node.isGroup()) {
|
||||
node.setGroup(false);
|
||||
}
|
||||
node.setRepetable(true);
|
||||
// if (this.value) {
|
||||
// if (hl7ui != null && node.isGroup()) {
|
||||
// // hl7ui.updateStatus();
|
||||
// }
|
||||
// // TreeUtil.upsetMainNode(node);
|
||||
// // xmlViewer.refresh();
|
||||
// } else {
|
||||
// // if (hl7ui != null) {
|
||||
// // hl7ui.updateStatus();
|
||||
// // }
|
||||
// // upsetMainNode(node);
|
||||
// // xmlViewer.refresh();
|
||||
// }
|
||||
upsetMainNode(node);
|
||||
xmlViewer.refresh();
|
||||
if (form != null) {
|
||||
form.refreshLinks();
|
||||
}
|
||||
|
||||
// this.hl7ui.updateStatus();
|
||||
}
|
||||
|
||||
public void upsetMainNode(HL7TreeNode node) {
|
||||
if (node instanceof Element) {
|
||||
HL7TreeNode parent = node;
|
||||
while (parent != null) {
|
||||
parent.setMain(true);
|
||||
parent = parent.getParent();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
// ============================================================================
|
||||
//
|
||||
// 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
|
||||
//
|
||||
// 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.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.Element;
|
||||
import org.talend.designer.hl7.ui.data.HL7TreeNode;
|
||||
import org.talend.repository.ui.swt.utils.AbstractForm;
|
||||
|
||||
/**
|
||||
* bqian Create a xml node. <br/>
|
||||
*
|
||||
* $Id: CreateElementAction.java,v 1.1 2007/06/12 07:20:38 gke Exp $
|
||||
*
|
||||
*/
|
||||
public class 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;
|
||||
|
||||
public SetRepetableAction(TreeViewer xmlViewer, AbstractForm form) {
|
||||
super(xmlViewer, SET_AS_REPEATABLE_ELEMENT);
|
||||
this.xmlViewer = xmlViewer;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* SetForLoopAction constructor comment.
|
||||
*
|
||||
* @param xmlViewer
|
||||
* @param text
|
||||
* @param hl7ui
|
||||
*/
|
||||
public SetRepetableAction(TreeViewer xmlViewer, HL7UI hl7ui, String text, boolean value) {
|
||||
super(xmlViewer, text);
|
||||
this.xmlViewer = xmlViewer;
|
||||
}
|
||||
|
||||
public void init() {
|
||||
setText(SET_AS_REPEATABLE_ELEMENT);
|
||||
HL7TreeNode node = (HL7TreeNode) this.getStructuredSelection().getFirstElement();
|
||||
if (node == null) {
|
||||
this.setEnabled(false);
|
||||
return;
|
||||
}
|
||||
if (node.isRepetable()) {
|
||||
this.setEnabled(true);
|
||||
this.setText(REMOVE_REPEATABLE);
|
||||
return;
|
||||
}
|
||||
if (node.getLabel().length() != 3) {
|
||||
this.setEnabled(false);
|
||||
return;
|
||||
}
|
||||
this.setEnabled(true);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.jface.action.Action#run()
|
||||
*/
|
||||
@Override
|
||||
public void run() {
|
||||
HL7TreeNode node = (HL7TreeNode) this.getStructuredSelection().getFirstElement();
|
||||
|
||||
if (!node.isRepetable()) {
|
||||
if (node.isGroup()) {
|
||||
node.setGroup(false);
|
||||
}
|
||||
node.setRepetable(true);
|
||||
node.setMain(true);
|
||||
upsetMainNode(node);
|
||||
} else {
|
||||
node.setRepetable(false);
|
||||
}
|
||||
xmlViewer.refresh();
|
||||
}
|
||||
|
||||
public void upsetMainNode(HL7TreeNode node) {
|
||||
if (node instanceof Element) {
|
||||
HL7TreeNode parent = node;
|
||||
while (parent != null) {
|
||||
parent.setMain(true);
|
||||
parent = parent.getParent();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,86 +1,140 @@
|
||||
// ============================================================================
|
||||
//
|
||||
// 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.designer.hl7.model;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import ca.uhn.hl7v2.HL7Exception;
|
||||
import ca.uhn.hl7v2.model.Segment;
|
||||
import ca.uhn.hl7v2.model.Structure;
|
||||
import ca.uhn.hl7v2.model.Type;
|
||||
|
||||
/**
|
||||
* DOC Administrator class global comment. Detailled comment
|
||||
*/
|
||||
public class SegmentModel extends AbstractStructureModel {
|
||||
|
||||
private Segment seg;
|
||||
|
||||
private int folderIndex, subfolderIndex;
|
||||
|
||||
private TypeModel[] types;
|
||||
|
||||
public SegmentModel(Segment seg, Structure parent, int folderIndex, int subfolderIndex) {
|
||||
this.seg = seg;
|
||||
this.parent = parent;
|
||||
this.folderIndex = folderIndex;
|
||||
this.subfolderIndex = subfolderIndex;
|
||||
generateDataTypes();
|
||||
}
|
||||
|
||||
protected void generateDisplayName() {
|
||||
this.displayName = seg.getName();
|
||||
}
|
||||
|
||||
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);
|
||||
datatypes.add(tm);
|
||||
}
|
||||
} catch (HL7Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
this.types = datatypes.toArray(new TypeModel[0]);
|
||||
}
|
||||
|
||||
public TypeModel[] getTypes() {
|
||||
return this.types;
|
||||
}
|
||||
|
||||
public Segment getSeg() {
|
||||
return this.seg;
|
||||
}
|
||||
|
||||
public int getFolderIndex() {
|
||||
return this.folderIndex;
|
||||
}
|
||||
|
||||
public int getSubfolderIndex() {
|
||||
return this.subfolderIndex;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj instanceof SegmentModel) {
|
||||
return this.getSeg().getName().equals(((SegmentModel) obj).getSeg().getName());
|
||||
}
|
||||
return super.equals(obj);
|
||||
}
|
||||
|
||||
}
|
||||
// ============================================================================
|
||||
//
|
||||
// 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
|
||||
//
|
||||
// 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.designer.hl7.model;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import ca.uhn.hl7v2.HL7Exception;
|
||||
import ca.uhn.hl7v2.model.Segment;
|
||||
import ca.uhn.hl7v2.model.Structure;
|
||||
import ca.uhn.hl7v2.model.Type;
|
||||
|
||||
/**
|
||||
* DOC Administrator class global comment. Detailled comment
|
||||
*/
|
||||
public class SegmentModel extends AbstractStructureModel {
|
||||
|
||||
private Segment seg;
|
||||
|
||||
private int folderIndex, subfolderIndex;
|
||||
|
||||
private TypeModel[] types;
|
||||
|
||||
public SegmentModel(Segment seg, Structure parent, int folderIndex, int subfolderIndex) {
|
||||
this.seg = seg;
|
||||
this.parent = parent;
|
||||
this.folderIndex = folderIndex;
|
||||
this.subfolderIndex = subfolderIndex;
|
||||
generateDataTypes();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void generateDisplayName() {
|
||||
this.displayName = seg.getName();
|
||||
}
|
||||
|
||||
private void generateDataTypes() {
|
||||
int number = this.seg.numFields();
|
||||
ArrayList<TypeModel> datatypes = new ArrayList<TypeModel>();
|
||||
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();
|
||||
}
|
||||
}
|
||||
this.types = datatypes.toArray(new TypeModel[0]);
|
||||
}
|
||||
|
||||
public TypeModel[] getTypes() {
|
||||
return this.types;
|
||||
}
|
||||
|
||||
public Segment getSeg() {
|
||||
return this.seg;
|
||||
}
|
||||
|
||||
public int getFolderIndex() {
|
||||
return this.folderIndex;
|
||||
}
|
||||
|
||||
public int getSubfolderIndex() {
|
||||
return this.subfolderIndex;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj instanceof SegmentModel) {
|
||||
return this.getSeg().getName().equals(((SegmentModel) obj).getSeg().getName());
|
||||
}
|
||||
return super.equals(obj);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,150 +1,155 @@
|
||||
// ============================================================================
|
||||
//
|
||||
// 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.designer.hl7.model;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.talend.core.model.utils.TalendTextUtils;
|
||||
|
||||
import ca.uhn.hl7v2.HL7Exception;
|
||||
import ca.uhn.hl7v2.model.Composite;
|
||||
import ca.uhn.hl7v2.model.DataTypeException;
|
||||
import ca.uhn.hl7v2.model.GenericComposite;
|
||||
import ca.uhn.hl7v2.model.GenericPrimitive;
|
||||
import ca.uhn.hl7v2.model.Primitive;
|
||||
import ca.uhn.hl7v2.model.Structure;
|
||||
import ca.uhn.hl7v2.model.Type;
|
||||
import ca.uhn.hl7v2.model.Varies;
|
||||
import ca.uhn.hl7v2.util.Terser;
|
||||
|
||||
/**
|
||||
* DOC Administrator class global comment. Detailled comment
|
||||
*/
|
||||
public class TypeModel extends AbstractStructureModel {
|
||||
|
||||
private Type type;
|
||||
|
||||
private int index;
|
||||
|
||||
private int rep;
|
||||
|
||||
private Terser terser;
|
||||
|
||||
private PrimitiveModel[] primitives;
|
||||
|
||||
public Type getType() {
|
||||
return this.type;
|
||||
}
|
||||
|
||||
public TypeModel(Type type, Structure parent, int rep, int index) {
|
||||
this.type = type;
|
||||
this.parent = parent;
|
||||
this.rep = rep;
|
||||
this.index = index;
|
||||
generatePrimitive();
|
||||
}
|
||||
|
||||
protected void generateDisplayName() {
|
||||
|
||||
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) {
|
||||
PrimitiveModel pm = new PrimitiveModel(this, p, k, m);
|
||||
pms.add(pm);
|
||||
}
|
||||
}
|
||||
}
|
||||
primitives = pms.toArray(new PrimitiveModel[0]);
|
||||
}
|
||||
|
||||
public Primitive getPrimitive(Type type, int component, int subcomponent) {
|
||||
Type comp = getComponent(type, component);
|
||||
Type sub = getComponent(comp, subcomponent);
|
||||
return getPrimitive(sub);
|
||||
}
|
||||
|
||||
private int numStandardComponents(Type t) {
|
||||
int n = 0;
|
||||
if (Varies.class.isAssignableFrom(t.getClass())) {
|
||||
n = numStandardComponents(((Varies) t).getData());
|
||||
} else if (Composite.class.isAssignableFrom(t.getClass())) {
|
||||
n = ((Composite) t).getComponents().length;
|
||||
} else {
|
||||
n = 1;
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
private Type getComponent(Type type, int comp) {
|
||||
Type ret = null;
|
||||
if (Varies.class.isAssignableFrom(type.getClass())) {
|
||||
Varies v = (Varies) type;
|
||||
|
||||
try {
|
||||
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);
|
||||
}
|
||||
|
||||
ret = getComponent(v.getData(), comp);
|
||||
} else {
|
||||
if (Primitive.class.isAssignableFrom(type.getClass()) && comp == 1) {
|
||||
ret = type;
|
||||
} else if (GenericComposite.class.isAssignableFrom(type.getClass())
|
||||
|| (Composite.class.isAssignableFrom(type.getClass()) && comp <= numStandardComponents(type))) {
|
||||
// note that GenericComposite can return components > number of standard components
|
||||
|
||||
try {
|
||||
ret = ((Composite) type).getComponent(comp - 1);
|
||||
} catch (Exception e) {
|
||||
throw new Error("Internal error: HL7Exception thrown on getComponent(x) where x < # standard components.", e);
|
||||
}
|
||||
} else {
|
||||
ret = type.getExtraComponents().getComponent(comp - numStandardComponents(type) - 1);
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
private Primitive getPrimitive(Type type) {
|
||||
Primitive p = null;
|
||||
if (Varies.class.isAssignableFrom(type.getClass())) {
|
||||
p = getPrimitive(((Varies) type).getData());
|
||||
} else if (Composite.class.isAssignableFrom(type.getClass())) {
|
||||
try {
|
||||
p = getPrimitive(((Composite) type).getComponent(0));
|
||||
} catch (HL7Exception e) {
|
||||
throw new Error("Internal error: HL7Exception thrown on Composite.getComponent(0).");
|
||||
}
|
||||
} else if (type instanceof Primitive) {
|
||||
p = (Primitive) type;
|
||||
}
|
||||
return p;
|
||||
}
|
||||
|
||||
public PrimitiveModel[] getPrimitives() {
|
||||
return this.primitives;
|
||||
}
|
||||
}
|
||||
// ============================================================================
|
||||
//
|
||||
// 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
|
||||
//
|
||||
// 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.designer.hl7.model;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.talend.core.model.utils.TalendTextUtils;
|
||||
|
||||
import ca.uhn.hl7v2.HL7Exception;
|
||||
import ca.uhn.hl7v2.model.Composite;
|
||||
import ca.uhn.hl7v2.model.DataTypeException;
|
||||
import ca.uhn.hl7v2.model.GenericComposite;
|
||||
import ca.uhn.hl7v2.model.GenericPrimitive;
|
||||
import ca.uhn.hl7v2.model.Primitive;
|
||||
import ca.uhn.hl7v2.model.Structure;
|
||||
import ca.uhn.hl7v2.model.Type;
|
||||
import ca.uhn.hl7v2.model.Varies;
|
||||
import ca.uhn.hl7v2.util.Terser;
|
||||
|
||||
/**
|
||||
* DOC Administrator class global comment. Detailled comment
|
||||
*/
|
||||
public class TypeModel extends AbstractStructureModel {
|
||||
|
||||
private Type type;
|
||||
|
||||
private int index;
|
||||
|
||||
private int rep;
|
||||
|
||||
private Terser terser;
|
||||
|
||||
private PrimitiveModel[] primitives;
|
||||
|
||||
public Type getType() {
|
||||
return this.type;
|
||||
}
|
||||
|
||||
public TypeModel(Type type, Structure parent, int rep, int index) {
|
||||
this.type = type;
|
||||
this.parent = parent;
|
||||
this.rep = rep;
|
||||
this.index = index;
|
||||
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$
|
||||
|
||||
}
|
||||
|
||||
private void generatePrimitive() {
|
||||
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 };
|
||||
}
|
||||
}
|
||||
|
||||
public Primitive getPrimitive(Type type, int component, int subcomponent) {
|
||||
Type comp = getComponent(type, component);
|
||||
Type sub = getComponent(comp, subcomponent);
|
||||
return getPrimitive(sub);
|
||||
}
|
||||
|
||||
private int numStandardComponents(Type t) {
|
||||
int n = 0;
|
||||
if (Varies.class.isAssignableFrom(t.getClass())) {
|
||||
n = numStandardComponents(((Varies) t).getData());
|
||||
} else if (Composite.class.isAssignableFrom(t.getClass())) {
|
||||
n = ((Composite) t).getComponents().length;
|
||||
} else {
|
||||
n = 1;
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
private Type getComponent(Type type, int comp) {
|
||||
Type ret = null;
|
||||
if (Varies.class.isAssignableFrom(type.getClass())) {
|
||||
Varies v = (Varies) type;
|
||||
|
||||
try {
|
||||
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);
|
||||
}
|
||||
|
||||
ret = getComponent(v.getData(), comp);
|
||||
} else {
|
||||
if (Primitive.class.isAssignableFrom(type.getClass()) && comp == 1) {
|
||||
ret = type;
|
||||
} else if (GenericComposite.class.isAssignableFrom(type.getClass())
|
||||
|| (Composite.class.isAssignableFrom(type.getClass()) && comp <= numStandardComponents(type))) {
|
||||
// note that GenericComposite can return components > number of standard components
|
||||
|
||||
try {
|
||||
ret = ((Composite) type).getComponent(comp - 1);
|
||||
} catch (Exception e) {
|
||||
throw new Error("Internal error: HL7Exception thrown on getComponent(x) where x < # standard components.", e);
|
||||
}
|
||||
} else {
|
||||
ret = type.getExtraComponents().getComponent(comp - numStandardComponents(type) - 1);
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
private Primitive getPrimitive(Type type) {
|
||||
Primitive p = null;
|
||||
if (Varies.class.isAssignableFrom(type.getClass())) {
|
||||
p = getPrimitive(((Varies) type).getData());
|
||||
} else if (Composite.class.isAssignableFrom(type.getClass())) {
|
||||
try {
|
||||
p = getPrimitive(((Composite) type).getComponent(0));
|
||||
} catch (HL7Exception e) {
|
||||
throw new Error("Internal error: HL7Exception thrown on Composite.getComponent(0).");
|
||||
}
|
||||
} else if (type instanceof Primitive) {
|
||||
p = (Primitive) type;
|
||||
}
|
||||
return p;
|
||||
}
|
||||
|
||||
public PrimitiveModel[] getPrimitives() {
|
||||
return this.primitives;
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,390 +1,390 @@
|
||||
// ============================================================================
|
||||
//
|
||||
// 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.designer.hl7.ui.data;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.talend.core.model.metadata.IMetadataColumn;
|
||||
import org.talend.core.model.metadata.IMetadataTable;
|
||||
|
||||
/**
|
||||
* DOC hwang class global comment. Detailled comment
|
||||
*/
|
||||
public abstract class HL7TreeNode {
|
||||
|
||||
private IMetadataTable table = null;
|
||||
|
||||
private IMetadataColumn column = null;
|
||||
|
||||
private String row = null;
|
||||
|
||||
private String label;
|
||||
|
||||
private String defaultValue;
|
||||
|
||||
private List<HL7TreeNode> children = null;
|
||||
|
||||
private HL7TreeNode parent = null;
|
||||
|
||||
private boolean isRepetableNode = false;
|
||||
|
||||
private boolean isGroupNode = false;
|
||||
|
||||
private boolean isMainNode = false;
|
||||
|
||||
private int order;
|
||||
|
||||
private boolean isAttribute = false;
|
||||
|
||||
private boolean isNameSpace = false;
|
||||
|
||||
private String columnName = null;
|
||||
|
||||
public boolean hasLink() {
|
||||
return column != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* HL7TreeNode constructor comment.
|
||||
*/
|
||||
public HL7TreeNode() {
|
||||
children = new ArrayList<HL7TreeNode>();
|
||||
}
|
||||
|
||||
/**
|
||||
* HL7TreeNode constructor comment.
|
||||
*/
|
||||
public HL7TreeNode(String label) {
|
||||
children = new ArrayList<HL7TreeNode>();
|
||||
this.label = label;
|
||||
}
|
||||
|
||||
/**
|
||||
* HL7TreeNode constructor comment.
|
||||
*/
|
||||
public HL7TreeNode(String label, String defaultValue) {
|
||||
children = new ArrayList<HL7TreeNode>();
|
||||
this.label = label;
|
||||
this.defaultValue = defaultValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for children.
|
||||
*
|
||||
* @return the children
|
||||
*/
|
||||
public List<HL7TreeNode> getChildren() {
|
||||
return this.children;
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for parent.
|
||||
*
|
||||
* @return the parent
|
||||
*/
|
||||
public HL7TreeNode getParent() {
|
||||
return this.parent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the parent.
|
||||
*
|
||||
* @param parent the parent to set
|
||||
*/
|
||||
public void setParent(HL7TreeNode parent) {
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
/**
|
||||
* DOC ke Comment method "getColumnLabel".
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getColumnLabel() {
|
||||
if (column != null) {
|
||||
if (getRow() != null) {
|
||||
return getRow() + ":" + this.column.getLabel(); //$NON-NLS-1$
|
||||
}
|
||||
return this.column.getLabel();
|
||||
} else if (columnName != null) {
|
||||
if (getRow() != null) {
|
||||
return getRow() + ":" + this.getColumnName();
|
||||
}
|
||||
return this.getColumnName();
|
||||
|
||||
} else {
|
||||
if (getRow() != null) {
|
||||
return getRow();
|
||||
}
|
||||
return ""; //$NON-NLS-1$
|
||||
}
|
||||
|
||||
// if (column == null) {
|
||||
// if (getRow() != null) {
|
||||
// return getRow();
|
||||
// }
|
||||
// return ""; //$NON-NLS-1$
|
||||
// } else {
|
||||
// if (getRow() != null) {
|
||||
// return getRow() + ":" + this.column.getLabel(); //$NON-NLS-1$
|
||||
// }
|
||||
// return this.column.getLabel();
|
||||
// }
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for schema.
|
||||
*
|
||||
* @return the schema
|
||||
*/
|
||||
public IMetadataColumn getColumn() {
|
||||
return column;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the schema.
|
||||
*
|
||||
* @param schema the schema to set
|
||||
*/
|
||||
public void setColumn(IMetadataColumn column) {
|
||||
this.column = column;
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for value.
|
||||
*
|
||||
* @return the value
|
||||
*/
|
||||
public String getLabel() {
|
||||
return this.label;
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for value.
|
||||
*
|
||||
* @return the value
|
||||
*/
|
||||
public String getLabelForViewer() {
|
||||
return this.label;
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for defaultValue.
|
||||
*
|
||||
* @return the value
|
||||
*/
|
||||
public String getDefaultValue() {
|
||||
return this.defaultValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the defaultValue.
|
||||
*
|
||||
* @param value the defaultValue to set
|
||||
*/
|
||||
public void setDefaultValue(String defaultValue) {
|
||||
this.defaultValue = defaultValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the value.
|
||||
*
|
||||
* @param value the value to set
|
||||
*/
|
||||
public void setLabel(String label) {
|
||||
this.label = label;
|
||||
}
|
||||
|
||||
/**
|
||||
* DOC ke Comment method "addChild".
|
||||
*
|
||||
* @param child
|
||||
*/
|
||||
public void addChild(HL7TreeNode child) {
|
||||
children.add(child);
|
||||
child.setParent(this);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* hwang Comment method "addChild".
|
||||
*
|
||||
* @param index
|
||||
* @param child
|
||||
*/
|
||||
public void addChild(int index, HL7TreeNode child) {
|
||||
if (index < children.size()) {
|
||||
children.add(index, child);
|
||||
} else {
|
||||
children.add(child);
|
||||
}
|
||||
child.setParent(this);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* DOC ke Comment method "removeChild".
|
||||
*
|
||||
* @param child
|
||||
*/
|
||||
public void removeChild(HL7TreeNode child) {
|
||||
children.remove(child);
|
||||
child.setParent(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* DOC ke Comment method "hasChildren".
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public boolean hasChildren() {
|
||||
return children.size() > 0;
|
||||
}
|
||||
|
||||
public boolean isRepetable() {
|
||||
return this.isRepetableNode;
|
||||
}
|
||||
|
||||
public void setRepetable(boolean b) {
|
||||
this.isRepetableNode = b;
|
||||
}
|
||||
|
||||
/**
|
||||
* DOC ke Comment method "isGroup".
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public boolean isGroup() {
|
||||
return this.isGroupNode;
|
||||
}
|
||||
|
||||
/**
|
||||
* DOC ke Comment method "setGroup".
|
||||
*
|
||||
* @param b
|
||||
*/
|
||||
public void setGroup(boolean b) {
|
||||
this.isGroupNode = b;
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for isMainNode.
|
||||
*
|
||||
* @return the isMainNode
|
||||
*/
|
||||
public boolean isMain() {
|
||||
return this.isMainNode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the isMainNode.
|
||||
*
|
||||
* @param isMainNode the isMainNode to set
|
||||
*/
|
||||
public void setMain(boolean isMainNode) {
|
||||
this.isMainNode = isMainNode;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* hwang Comment method "getTable".
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public IMetadataTable getTable() {
|
||||
return this.table;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* hwang Comment method "setTable".
|
||||
*
|
||||
* @param table
|
||||
*/
|
||||
public void setTable(IMetadataTable table) {
|
||||
this.table = table;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* hwang Comment method "getRow".
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getRow() {
|
||||
return this.row;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* hwang Comment method "setRow".
|
||||
*
|
||||
* @param row
|
||||
*/
|
||||
public void setRow(String row) {
|
||||
this.row = row;
|
||||
}
|
||||
|
||||
/**
|
||||
* hwang Comment method "getOrder".
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public int getOrder() {
|
||||
return this.order;
|
||||
}
|
||||
|
||||
/**
|
||||
* hwang Comment method "setOrder".
|
||||
*
|
||||
* @param order
|
||||
*/
|
||||
public void setOrder(int order) {
|
||||
this.order = order;
|
||||
}
|
||||
|
||||
public boolean isAttribute() {
|
||||
return this.isAttribute;
|
||||
}
|
||||
|
||||
public void setAttribute(boolean isAttribute) {
|
||||
this.isAttribute = isAttribute;
|
||||
}
|
||||
|
||||
public boolean isNameSpace() {
|
||||
return this.isNameSpace;
|
||||
}
|
||||
|
||||
public void setNameSpace(boolean isNameSpace) {
|
||||
this.isNameSpace = isNameSpace;
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for columnName.
|
||||
*
|
||||
* @return the columnName
|
||||
*/
|
||||
public String getColumnName() {
|
||||
return this.columnName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the columnName.
|
||||
*
|
||||
* @param columnName the columnName to set
|
||||
*/
|
||||
public void setColumnName(String columnName) {
|
||||
this.columnName = columnName;
|
||||
}
|
||||
}
|
||||
// ============================================================================
|
||||
//
|
||||
// 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
|
||||
//
|
||||
// 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.designer.hl7.ui.data;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.talend.core.model.metadata.IMetadataColumn;
|
||||
import org.talend.core.model.metadata.IMetadataTable;
|
||||
|
||||
/**
|
||||
* DOC hwang class global comment. Detailled comment
|
||||
*/
|
||||
public abstract class HL7TreeNode {
|
||||
|
||||
private IMetadataTable table = null;
|
||||
|
||||
private IMetadataColumn column = null;
|
||||
|
||||
private String row = null;
|
||||
|
||||
private String label;
|
||||
|
||||
private String defaultValue;
|
||||
|
||||
private List<HL7TreeNode> children = null;
|
||||
|
||||
private HL7TreeNode parent = null;
|
||||
|
||||
private boolean isRepetableNode = false;
|
||||
|
||||
private boolean isGroupNode = false;
|
||||
|
||||
private boolean isMainNode = false;
|
||||
|
||||
private int order;
|
||||
|
||||
private boolean isAttribute = false;
|
||||
|
||||
private boolean isNameSpace = false;
|
||||
|
||||
private String columnName = null;
|
||||
|
||||
public boolean hasLink() {
|
||||
return column != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* HL7TreeNode constructor comment.
|
||||
*/
|
||||
public HL7TreeNode() {
|
||||
children = new ArrayList<HL7TreeNode>();
|
||||
}
|
||||
|
||||
/**
|
||||
* HL7TreeNode constructor comment.
|
||||
*/
|
||||
public HL7TreeNode(String label) {
|
||||
children = new ArrayList<HL7TreeNode>();
|
||||
this.label = label;
|
||||
}
|
||||
|
||||
/**
|
||||
* HL7TreeNode constructor comment.
|
||||
*/
|
||||
public HL7TreeNode(String label, String defaultValue) {
|
||||
children = new ArrayList<HL7TreeNode>();
|
||||
this.label = label;
|
||||
this.defaultValue = defaultValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for children.
|
||||
*
|
||||
* @return the children
|
||||
*/
|
||||
public List<HL7TreeNode> getChildren() {
|
||||
return this.children;
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for parent.
|
||||
*
|
||||
* @return the parent
|
||||
*/
|
||||
public HL7TreeNode getParent() {
|
||||
return this.parent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the parent.
|
||||
*
|
||||
* @param parent the parent to set
|
||||
*/
|
||||
public void setParent(HL7TreeNode parent) {
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
/**
|
||||
* DOC ke Comment method "getColumnLabel".
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getColumnLabel() {
|
||||
if (column != null) {
|
||||
if (getRow() != null) {
|
||||
return getRow() + ":" + this.column.getLabel(); //$NON-NLS-1$
|
||||
}
|
||||
return this.column.getLabel();
|
||||
} else if (columnName != null) {
|
||||
if (getRow() != null) {
|
||||
return getRow() + ":" + this.getColumnName();
|
||||
}
|
||||
return this.getColumnName();
|
||||
|
||||
} else {
|
||||
if (getRow() != null) {
|
||||
return getRow();
|
||||
}
|
||||
return ""; //$NON-NLS-1$
|
||||
}
|
||||
|
||||
// if (column == null) {
|
||||
// if (getRow() != null) {
|
||||
// return getRow();
|
||||
// }
|
||||
// return ""; //$NON-NLS-1$
|
||||
// } else {
|
||||
// if (getRow() != null) {
|
||||
// return getRow() + ":" + this.column.getLabel(); //$NON-NLS-1$
|
||||
// }
|
||||
// return this.column.getLabel();
|
||||
// }
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for schema.
|
||||
*
|
||||
* @return the schema
|
||||
*/
|
||||
public IMetadataColumn getColumn() {
|
||||
return column;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the schema.
|
||||
*
|
||||
* @param schema the schema to set
|
||||
*/
|
||||
public void setColumn(IMetadataColumn column) {
|
||||
this.column = column;
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for value.
|
||||
*
|
||||
* @return the value
|
||||
*/
|
||||
public String getLabel() {
|
||||
return this.label;
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for value.
|
||||
*
|
||||
* @return the value
|
||||
*/
|
||||
public String getLabelForViewer() {
|
||||
return this.label;
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for defaultValue.
|
||||
*
|
||||
* @return the value
|
||||
*/
|
||||
public String getDefaultValue() {
|
||||
return this.defaultValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the defaultValue.
|
||||
*
|
||||
* @param value the defaultValue to set
|
||||
*/
|
||||
public void setDefaultValue(String defaultValue) {
|
||||
this.defaultValue = defaultValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the value.
|
||||
*
|
||||
* @param value the value to set
|
||||
*/
|
||||
public void setLabel(String label) {
|
||||
this.label = label;
|
||||
}
|
||||
|
||||
/**
|
||||
* DOC ke Comment method "addChild".
|
||||
*
|
||||
* @param child
|
||||
*/
|
||||
public void addChild(HL7TreeNode child) {
|
||||
children.add(child);
|
||||
child.setParent(this);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* hwang Comment method "addChild".
|
||||
*
|
||||
* @param index
|
||||
* @param child
|
||||
*/
|
||||
public void addChild(int index, HL7TreeNode child) {
|
||||
if (index < children.size()) {
|
||||
children.add(index, child);
|
||||
} else {
|
||||
children.add(child);
|
||||
}
|
||||
child.setParent(this);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* DOC ke Comment method "removeChild".
|
||||
*
|
||||
* @param child
|
||||
*/
|
||||
public void removeChild(HL7TreeNode child) {
|
||||
children.remove(child);
|
||||
child.setParent(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* DOC ke Comment method "hasChildren".
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public boolean hasChildren() {
|
||||
return children.size() > 0;
|
||||
}
|
||||
|
||||
public boolean isRepetable() {
|
||||
return this.isRepetableNode;
|
||||
}
|
||||
|
||||
public void setRepetable(boolean b) {
|
||||
this.isRepetableNode = b;
|
||||
}
|
||||
|
||||
/**
|
||||
* DOC ke Comment method "isGroup".
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public boolean isGroup() {
|
||||
return this.isGroupNode;
|
||||
}
|
||||
|
||||
/**
|
||||
* DOC ke Comment method "setGroup".
|
||||
*
|
||||
* @param b
|
||||
*/
|
||||
public void setGroup(boolean b) {
|
||||
this.isGroupNode = b;
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for isMainNode.
|
||||
*
|
||||
* @return the isMainNode
|
||||
*/
|
||||
public boolean isMain() {
|
||||
return this.isMainNode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the isMainNode.
|
||||
*
|
||||
* @param isMainNode the isMainNode to set
|
||||
*/
|
||||
public void setMain(boolean isMainNode) {
|
||||
this.isMainNode = isMainNode;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* hwang Comment method "getTable".
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public IMetadataTable getTable() {
|
||||
return this.table;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* hwang Comment method "setTable".
|
||||
*
|
||||
* @param table
|
||||
*/
|
||||
public void setTable(IMetadataTable table) {
|
||||
this.table = table;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* hwang Comment method "getRow".
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getRow() {
|
||||
return this.row;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* hwang Comment method "setRow".
|
||||
*
|
||||
* @param row
|
||||
*/
|
||||
public void setRow(String row) {
|
||||
this.row = row;
|
||||
}
|
||||
|
||||
/**
|
||||
* hwang Comment method "getOrder".
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public int getOrder() {
|
||||
return this.order;
|
||||
}
|
||||
|
||||
/**
|
||||
* hwang Comment method "setOrder".
|
||||
*
|
||||
* @param order
|
||||
*/
|
||||
public void setOrder(int order) {
|
||||
this.order = order;
|
||||
}
|
||||
|
||||
public boolean isAttribute() {
|
||||
return this.isAttribute;
|
||||
}
|
||||
|
||||
public void setAttribute(boolean isAttribute) {
|
||||
this.isAttribute = isAttribute;
|
||||
}
|
||||
|
||||
public boolean isNameSpace() {
|
||||
return this.isNameSpace;
|
||||
}
|
||||
|
||||
public void setNameSpace(boolean isNameSpace) {
|
||||
this.isNameSpace = isNameSpace;
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for columnName.
|
||||
*
|
||||
* @return the columnName
|
||||
*/
|
||||
public String getColumnName() {
|
||||
return this.columnName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the columnName.
|
||||
*
|
||||
* @param columnName the columnName to set
|
||||
*/
|
||||
public void setColumnName(String columnName) {
|
||||
this.columnName = columnName;
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -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) {
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -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;
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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"/>
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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"/>
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -81,13 +81,13 @@
|
||||
|
||||
<service ref="job">
|
||||
<interfaces>
|
||||
<value>routines.system.api.TalendJob</value>
|
||||
</interfaces>
|
||||
<service-properties>
|
||||
<entry key="name" value="${endpoint.jobName}" />
|
||||
<entry key="type" value="job" />
|
||||
</service-properties>
|
||||
</service>
|
||||
<value>routines.system.api.TalendJob</value>
|
||||
</interfaces>
|
||||
<service-properties>
|
||||
<entry key="name" value="${endpoint.jobName}" />
|
||||
<entry key="type" value="job" />
|
||||
</service-properties>
|
||||
</service>
|
||||
|
||||
<!-- Wiring the counter repository -->
|
||||
<bean class="org.apache.cxf.management.counters.CounterRepository">
|
||||
|
||||
@@ -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.
|
||||
@@ -785,4 +791,11 @@ UseDynamicJobSelectionDialog.downBtnText=Down
|
||||
|
||||
RepositoryService.projectNotFound=The project '{0}' is not found.
|
||||
RepositoryService.projectReadonlyTitle=Information
|
||||
RepositoryService.projectReadonly=The current login project is readonly.
|
||||
RepositoryService.projectReadonly=The current login project is readonly.
|
||||
|
||||
JobScriptsManager.ResourceNotFoundForExport="Resource cannot be found for export: " {0}
|
||||
|
||||
ShowErrorsDuringImportItemsDialog_title=Errors during the import items
|
||||
ShowErrorsDuringImportItemsDialog_exportLogButton_title=Export Log
|
||||
ShowErrorsDuringImportItemsDialog_exportLogEntry=Export Log Entry
|
||||
ShowErrorsDuringImportItemsDialog_confirmOverwrite_message = File " {0}" exists. Would you like to overwrite it?
|
||||
@@ -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 {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user