Compare commits
24 Commits
pyzhou/TDI
...
patch/5.5.
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e5b6610abb | ||
|
|
9d4155314f | ||
|
|
d03f803d06 | ||
|
|
c92187aac1 | ||
|
|
b54878022c | ||
|
|
e15fae7537 | ||
|
|
3f0be852c5 | ||
|
|
c6aa41b4b1 | ||
|
|
00f7756d2a | ||
|
|
15942688cf | ||
|
|
1960c9fcec | ||
|
|
82e2af536b | ||
|
|
ec60f556f5 | ||
|
|
96aafbd48f | ||
|
|
85a1808676 | ||
|
|
985409e0d1 | ||
|
|
30b5fe0da7 | ||
|
|
e022cf20f6 | ||
|
|
a014635905 | ||
|
|
c3bd080912 | ||
|
|
3fa50a4f21 | ||
|
|
8bfdf93db1 | ||
|
|
fa2d16e5f9 | ||
|
|
97d5f1a66b |
6
.gitignore
vendored
Normal file
6
.gitignore
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
/*/target
|
||||
/*/bin
|
||||
/*/class
|
||||
/*/classes
|
||||
/*/.settings
|
||||
/**/dev_con
|
||||
@@ -49,25 +49,15 @@
|
||||
boolean hasParallelIterate = false;
|
||||
for (IConnection iterateConn : iterateConnSet) {
|
||||
parallelIterate = "true".equals(ElementParameterParser.getValue(iterateConn, "__ENABLE_PARALLEL__"));
|
||||
String iterateNodeName = iterateConn.getTarget().getUniqueName();
|
||||
if (parallelIterate) {
|
||||
%>
|
||||
TalendThreadPool mtp_<%=iterateConn.getTarget().getUniqueName() %> = new TalendThreadPool(<%=ElementParameterParser.getValue(iterateConn,"__NUMBER_PARALLEL__") %>);
|
||||
|
||||
<%
|
||||
if(!hasParallelIterate){
|
||||
hasParallelIterate = true;
|
||||
%>
|
||||
|
||||
final Object[] lockWrite = new Object[0];
|
||||
int threadIdCounter =0;
|
||||
<%
|
||||
}
|
||||
%>
|
||||
|
||||
globalMap.put("lockWrite_<%=iterateNodeName%>", new Object[0]);
|
||||
int threadIdCounter_<%=iterateNodeName%> =0;
|
||||
<%
|
||||
}
|
||||
|
||||
String iterateNodeName = iterateConn.getTarget().getUniqueName();
|
||||
%>
|
||||
int NB_ITERATE_<%=iterateNodeName %> = 0; //for statistics
|
||||
<%
|
||||
|
||||
@@ -111,7 +111,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
<%=node.getUniqueName() %>Thread bt_<%=node.getUniqueName() %> = new <%=node.getUniqueName() %>Thread(globalMap<%=schemaInstanceDeclaration %>,threadIdCounter++);
|
||||
<%=node.getUniqueName() %>Thread bt_<%=node.getUniqueName() %> = new <%=node.getUniqueName() %>Thread(globalMap<%=schemaInstanceDeclaration %>,threadIdCounter_<%=node.getUniqueName()%>++);
|
||||
mtp_<%=node.getUniqueName() %>.execute(bt_<%=node.getUniqueName() %>);
|
||||
|
||||
<%
|
||||
@@ -134,4 +134,4 @@
|
||||
}//3
|
||||
}//2
|
||||
}//1
|
||||
%>
|
||||
%>
|
||||
|
||||
@@ -67,7 +67,6 @@ for (IConnection iterateConn : iterateConnSet) { //1
|
||||
rowList = rowList.substring(0, rowList.length()-1);
|
||||
%>
|
||||
class <%=node.getUniqueName() %>Thread extends TalendThread {//implements routines.system.TalendThreadPool.PropertySettable
|
||||
|
||||
class ThreadedMap extends java.util.HashMap<String, Object> {
|
||||
|
||||
private static final long serialVersionUID = 0L;
|
||||
|
||||
@@ -868,7 +868,6 @@ public class CodeGenerator implements ICodeGenerator {
|
||||
CodeGeneratorArgument argument = new CodeGeneratorArgument();
|
||||
argument.setNode(node);
|
||||
argument.setAllMainSubTreeConnections(subProcess.getAllMainSubTreeConnections());
|
||||
argument.setSubTreeContainsParallelIterate(subProcess.subTreeContainsParallelIterate());
|
||||
argument.setCodePart(part);
|
||||
argument.setStatistics(statistics);
|
||||
argument.setTrace(trace);
|
||||
|
||||
@@ -60,6 +60,7 @@ public class CodeGeneratorArgument {
|
||||
|
||||
private int pauseTime;
|
||||
|
||||
@Deprecated
|
||||
private boolean subTreeContainsParallelIterate;
|
||||
|
||||
/**
|
||||
@@ -277,10 +278,15 @@ public class CodeGeneratorArgument {
|
||||
this.subTree = subTree;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
/*
|
||||
* use org.talend.core.model.process.AbstractNode.getParallelIterator()
|
||||
*/
|
||||
public boolean subTreeContainsParallelIterate() {
|
||||
return subTreeContainsParallelIterate;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void setSubTreeContainsParallelIterate(boolean subTreeContainsParallelIterate) {
|
||||
this.subTreeContainsParallelIterate = subTreeContainsParallelIterate;
|
||||
}
|
||||
|
||||
@@ -22,7 +22,6 @@ import java.util.Map;
|
||||
|
||||
import org.talend.core.model.process.AbstractNode;
|
||||
import org.talend.core.model.process.EConnectionType;
|
||||
import org.talend.core.model.process.ElementParameterParser;
|
||||
import org.talend.core.model.process.IConnection;
|
||||
import org.talend.core.model.process.IConnectionCategory;
|
||||
import org.talend.core.model.process.INode;
|
||||
@@ -61,6 +60,7 @@ public class NodesSubTree {
|
||||
|
||||
List<IConnection> allMainSubTreeConnections = null;
|
||||
|
||||
@Deprecated
|
||||
boolean subTreeContainsParallelIterate = false;
|
||||
|
||||
List<INode> mergeBranchStarts;
|
||||
@@ -251,11 +251,7 @@ public class NodesSubTree {
|
||||
if (connection.getLineStyle().hasConnectionCategory(IConnectionCategory.MAIN)) {
|
||||
if (!connection.getLineStyle().hasConnectionCategory(IConnectionCategory.USE_ITERATE)) {
|
||||
allMainSubTreeConnections.add(connection);
|
||||
} else {
|
||||
if (Boolean.TRUE.toString().equals(ElementParameterParser.getValue(connection, "__ENABLE_PARALLEL__"))) { //$NON-NLS-1$
|
||||
subTreeContainsParallelIterate = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (DEBUG) {
|
||||
System.out.print(" -> "); //$NON-NLS-1$
|
||||
}
|
||||
@@ -505,6 +501,10 @@ public class NodesSubTree {
|
||||
this.allMainSubTreeConnections = allMainSubTreeConnections;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
/*
|
||||
* use org.talend.core.model.process.AbstractNode.getParallelIterator()
|
||||
*/
|
||||
public boolean subTreeContainsParallelIterate() {
|
||||
return subTreeContainsParallelIterate;
|
||||
}
|
||||
|
||||
@@ -10306,7 +10306,23 @@ public class SforceServiceStub extends org.apache.axis2.client.Stub implements
|
||||
"urn:partner.soap.sforce.com:Soap:describeGlobalRequest");
|
||||
_operationClient.getOptions().setExceptionToBeThrownOnSOAPFault(
|
||||
true);
|
||||
|
||||
{
|
||||
/*- ADD - START - BY cmeng - 20140901*/
|
||||
/**
|
||||
* https://jira.talendforge.org/browse/TDI-30366<br>
|
||||
* 1. Because this API seems not support this case: server use HTTP Protocol 1.0(not support CHUNKED) while client use HTTP Protocol 1.1<br>
|
||||
* , then client will throw exception(org.apache.axis2.AxisFault: Transport error: 411 Error: Length Required)<br>
|
||||
* 2. If the new API can support this case, then this additional codes can be cancelled.
|
||||
*
|
||||
* Some information I searched on the net:<br>
|
||||
* https://www.mail-archive.com/basedb-devel@lists.sourceforge.net/msg00309.html
|
||||
* http://axis.apache.org/axis2/java/core/docs/http-transport.html
|
||||
* http://en.wikipedia.org/wiki/Chunked_transfer_encoding
|
||||
*/
|
||||
_operationClient.getOptions().setProperty(
|
||||
org.apache.axis2.transport.http.HTTPConstants.CHUNKED, "false");
|
||||
/*- ADD - END - BY cmeng* - 20140901*/
|
||||
}
|
||||
addPropertyToOperationClient(
|
||||
_operationClient,
|
||||
org.apache.axis2.description.WSDL2Constants.ATTR_WHTTP_QUERY_PARAMETER_SEPARATOR,
|
||||
@@ -12816,7 +12832,23 @@ public class SforceServiceStub extends org.apache.axis2.client.Stub implements
|
||||
"urn:partner.soap.sforce.com:Soap:describeSObjectRequest");
|
||||
_operationClient.getOptions().setExceptionToBeThrownOnSOAPFault(
|
||||
true);
|
||||
|
||||
{
|
||||
/*- ADD - START - BY cmeng - 20140901*/
|
||||
/**
|
||||
* https://jira.talendforge.org/browse/TDI-30366<br>
|
||||
* 1. Because this API seems not support this case: server use HTTP Protocol 1.0(not support CHUNKED) while client use HTTP Protocol 1.1<br>
|
||||
* , then client will throw exception(org.apache.axis2.AxisFault: Transport error: 411 Error: Length Required)<br>
|
||||
* 2. If the new API can support this case, then this additional codes can be cancelled.
|
||||
*
|
||||
* Some information I searched on the net:<br>
|
||||
* https://www.mail-archive.com/basedb-devel@lists.sourceforge.net/msg00309.html
|
||||
* http://axis.apache.org/axis2/java/core/docs/http-transport.html
|
||||
* http://en.wikipedia.org/wiki/Chunked_transfer_encoding
|
||||
*/
|
||||
_operationClient.getOptions().setProperty(
|
||||
org.apache.axis2.transport.http.HTTPConstants.CHUNKED, "false");
|
||||
/*- ADD - END - BY cmeng - 20140901*/
|
||||
}
|
||||
addPropertyToOperationClient(
|
||||
_operationClient,
|
||||
org.apache.axis2.description.WSDL2Constants.ATTR_WHTTP_QUERY_PARAMETER_SEPARATOR,
|
||||
|
||||
@@ -12,6 +12,8 @@ imports="
|
||||
org.talend.core.model.utils.NodeUtil
|
||||
java.util.List
|
||||
org.talend.core.model.process.IProcess
|
||||
org.talend.core.model.process.IElementParameter
|
||||
org.talend.core.model.process.AbstractNode
|
||||
"
|
||||
%>
|
||||
<%@ include file="../templates/Log4j/Log4jFileUtil.javajet"%>
|
||||
@@ -457,9 +459,9 @@ if(("false").equals(ElementParameterParser.getValue(node,"__CSV_OPTION__"))) {
|
||||
synchronized (multiThreadLockWrite) {
|
||||
<%
|
||||
}
|
||||
if (codeGenArgument.subTreeContainsParallelIterate()) {
|
||||
if (((AbstractNode)node).getParallelIterator() != null) {
|
||||
%>
|
||||
synchronized (lockWrite) {
|
||||
synchronized ((Object[])globalMap.get("lockWrite_<%=((AbstractNode)node).getParallelIterator()%>")) {
|
||||
<%
|
||||
}
|
||||
if (isParallelize) {
|
||||
@@ -508,7 +510,7 @@ if(("false").equals(ElementParameterParser.getValue(node,"__CSV_OPTION__"))) {
|
||||
}
|
||||
<%
|
||||
}
|
||||
if (codeGenArgument.subTreeContainsParallelIterate()) {
|
||||
if (((AbstractNode)node).getParallelIterator() != null) {
|
||||
%>
|
||||
}
|
||||
<%
|
||||
@@ -892,9 +894,9 @@ if(("false").equals(ElementParameterParser.getValue(node,"__CSV_OPTION__"))) {
|
||||
synchronized (multiThreadLockWrite) {
|
||||
<%
|
||||
}
|
||||
if (codeGenArgument.subTreeContainsParallelIterate()) {
|
||||
if (((AbstractNode)node).getParallelIterator() != null) {
|
||||
%>
|
||||
synchronized (lockWrite) {
|
||||
synchronized ((Object[])globalMap.get("lockWrite_<%=((AbstractNode)node).getParallelIterator()%>")) {
|
||||
<%
|
||||
}
|
||||
if (isParallelize) {
|
||||
@@ -943,7 +945,7 @@ if(("false").equals(ElementParameterParser.getValue(node,"__CSV_OPTION__"))) {
|
||||
}
|
||||
<%
|
||||
}
|
||||
if (codeGenArgument.subTreeContainsParallelIterate()) {
|
||||
if (((AbstractNode)node).getParallelIterator() != null) {
|
||||
%>
|
||||
}
|
||||
<%
|
||||
@@ -1119,4 +1121,4 @@ resourceMap.put("nb_line_<%=cid%>", nb_line_<%=cid%>);
|
||||
<%}else{%>
|
||||
resourceMap.put("file<%=cid%>", file<%=cid%>);
|
||||
<%}%>
|
||||
<%}%>
|
||||
<%}%>
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
org.talend.core.model.process.ElementParameterParser
|
||||
java.util.List
|
||||
org.talend.core.model.process.IProcess
|
||||
org.talend.core.model.utils.NodeUtil
|
||||
org.talend.core.model.process.AbstractNode
|
||||
"
|
||||
%>
|
||||
<%@ include file="../templates/Log4j/Log4jFileUtil.javajet"%>
|
||||
@@ -43,9 +45,9 @@ if ((metadatas!=null)&&(metadatas.size()>0)) {
|
||||
synchronized (multiThreadLockWrite) {
|
||||
<%
|
||||
}
|
||||
if (codeGenArgument.subTreeContainsParallelIterate()) {
|
||||
if (((AbstractNode)node).getParallelIterator() != null) {
|
||||
%>
|
||||
synchronized (lockWrite) {
|
||||
synchronized ((Object[])globalMap.get("lockWrite_<%=((AbstractNode)node).getParallelIterator()%>")) {
|
||||
<%
|
||||
}
|
||||
if (isParallelize) {
|
||||
@@ -138,7 +140,7 @@ if ((metadatas!=null)&&(metadatas.size()>0)) {
|
||||
}
|
||||
<%
|
||||
}
|
||||
if (codeGenArgument.subTreeContainsParallelIterate()) {
|
||||
if (((AbstractNode)node).getParallelIterator() != null) {
|
||||
%>
|
||||
}
|
||||
<%
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
org.talend.core.model.process.ElementParameterParser
|
||||
java.util.List
|
||||
org.talend.core.model.process.IProcess
|
||||
org.talend.core.model.utils.NodeUtil
|
||||
org.talend.core.model.process.AbstractNode
|
||||
"
|
||||
%>
|
||||
|
||||
@@ -43,9 +45,9 @@ if ((metadatas!=null)&&(metadatas.size()>0)) {
|
||||
synchronized (multiThreadLockWrite) {
|
||||
<%
|
||||
}
|
||||
if (codeGenArgument.subTreeContainsParallelIterate()) {
|
||||
if (((AbstractNode)node).getParallelIterator() != null) {
|
||||
%>
|
||||
synchronized (lockWrite) {
|
||||
synchronized ((Object[])globalMap.get("lockWrite_<%=((AbstractNode)node).getParallelIterator()%>")) {
|
||||
<%
|
||||
}
|
||||
if (isParallelize) {
|
||||
@@ -140,7 +142,7 @@ if ((metadatas!=null)&&(metadatas.size()>0)) {
|
||||
}
|
||||
<%
|
||||
}
|
||||
if (codeGenArgument.subTreeContainsParallelIterate()) {
|
||||
if (((AbstractNode)node).getParallelIterator() != null) {
|
||||
%>
|
||||
}
|
||||
<%
|
||||
|
||||
@@ -10,6 +10,8 @@ imports="
|
||||
java.util.List
|
||||
org.talend.core.model.metadata.types.JavaTypesManager
|
||||
org.talend.core.model.metadata.types.JavaType
|
||||
org.talend.core.model.utils.NodeUtil
|
||||
org.talend.core.model.process.AbstractNode
|
||||
"
|
||||
%>
|
||||
|
||||
@@ -80,9 +82,9 @@ if(("false").equals(ElementParameterParser.getValue(node,"__CSV_OPTION__"))) {
|
||||
synchronized (multiThreadLockWrite) {
|
||||
<%
|
||||
}
|
||||
if (codeGenArgument.subTreeContainsParallelIterate()) {
|
||||
if (((AbstractNode)node).getParallelIterator() != null) {
|
||||
%>
|
||||
synchronized (lockWrite) {
|
||||
synchronized ((Object[])globalMap.get("lockWrite_<%=((AbstractNode)node).getParallelIterator()%>")) {
|
||||
<%
|
||||
}
|
||||
if (isParallelize) {
|
||||
@@ -135,7 +137,7 @@ if(("false").equals(ElementParameterParser.getValue(node,"__CSV_OPTION__"))) {
|
||||
}
|
||||
<%
|
||||
}
|
||||
if (codeGenArgument.subTreeContainsParallelIterate()) {
|
||||
if (((AbstractNode)node).getParallelIterator() != null) {
|
||||
%>
|
||||
}
|
||||
<%
|
||||
@@ -226,9 +228,9 @@ if(("false").equals(ElementParameterParser.getValue(node,"__CSV_OPTION__"))) {
|
||||
synchronized (multiThreadLockWrite) {
|
||||
<%
|
||||
}
|
||||
if (codeGenArgument.subTreeContainsParallelIterate()) {
|
||||
if (((AbstractNode)node).getParallelIterator() != null) {
|
||||
%>
|
||||
synchronized (lockWrite) {
|
||||
synchronized ((Object[])globalMap.get("lockWrite_<%=((AbstractNode)node).getParallelIterator()%>")) {
|
||||
<%
|
||||
}
|
||||
if (isParallelize) {
|
||||
@@ -349,7 +351,7 @@ if(("false").equals(ElementParameterParser.getValue(node,"__CSV_OPTION__"))) {
|
||||
}
|
||||
<%
|
||||
}
|
||||
if (codeGenArgument.subTreeContainsParallelIterate()) {
|
||||
if (((AbstractNode)node).getParallelIterator() != null) {
|
||||
%>
|
||||
}
|
||||
<%
|
||||
@@ -404,6 +406,8 @@ if(("false").equals(ElementParameterParser.getValue(node,"__CSV_OPTION__"))) {
|
||||
|
||||
boolean compress = ("true").equals(ElementParameterParser.getValue(node,"__COMPRESS__"));
|
||||
|
||||
boolean useOSLineSeparator = ("true").equals(ElementParameterParser.getValue(node,"__OS_LINE_SEPARATOR_AS_ROW_SEPARATOR__"));
|
||||
|
||||
boolean hasDynamic = metadata.isDynamicSchema();
|
||||
IMetadataColumn dynamicCol = metadata.getDynamicColumn();
|
||||
if(hasDynamic){
|
||||
@@ -424,9 +428,9 @@ if(("false").equals(ElementParameterParser.getValue(node,"__CSV_OPTION__"))) {
|
||||
synchronized (multiThreadLockWrite) {
|
||||
<%
|
||||
}
|
||||
if (codeGenArgument.subTreeContainsParallelIterate()) {
|
||||
if (((AbstractNode)node).getParallelIterator() != null) {
|
||||
%>
|
||||
synchronized (lockWrite) {
|
||||
synchronized ((Object[])globalMap.get("lockWrite_<%=((AbstractNode)node).getParallelIterator()%>")) {
|
||||
<%
|
||||
}
|
||||
if (isParallelize) {
|
||||
@@ -495,7 +499,7 @@ if(("false").equals(ElementParameterParser.getValue(node,"__CSV_OPTION__"))) {
|
||||
}
|
||||
<%
|
||||
}
|
||||
if (codeGenArgument.subTreeContainsParallelIterate()) {
|
||||
if (((AbstractNode)node).getParallelIterator() != null) {
|
||||
%>
|
||||
}
|
||||
<%
|
||||
@@ -583,9 +587,9 @@ if(("false").equals(ElementParameterParser.getValue(node,"__CSV_OPTION__"))) {
|
||||
synchronized (multiThreadLockWrite) {
|
||||
<%
|
||||
}
|
||||
if (codeGenArgument.subTreeContainsParallelIterate()) {
|
||||
if (((AbstractNode)node).getParallelIterator() != null) {
|
||||
%>
|
||||
synchronized (lockWrite) {
|
||||
synchronized ((Object[])globalMap.get("lockWrite_<%=((AbstractNode)node).getParallelIterator()%>")) {
|
||||
<%
|
||||
}
|
||||
if (isParallelize) {
|
||||
@@ -624,8 +628,25 @@ if(("false").equals(ElementParameterParser.getValue(node,"__CSV_OPTION__"))) {
|
||||
new java.io.FileOutputStream(fullName_<%=cid%> + splitedFileNo_<%=cid%> + extension_<%=cid%>, <%=isAppend%>),<%=encoding%>)));
|
||||
CsvWriter<%=cid%>.setSeparator(csvSettings_<%=cid %>.getFieldDelim());
|
||||
<%}%>
|
||||
if(csvSettings_<%=cid %>.getRowDelim()!='\r' && csvSettings_<%=cid %>.getRowDelim()!='\n')
|
||||
CsvWriter<%=cid%>.setLineEnd(""+csvSettings_<%=cid %>.getRowDelim());
|
||||
|
||||
<%
|
||||
if(!useOSLineSeparator) {
|
||||
%>
|
||||
if(csvSettings_<%=cid%>.isUseCRLFRecordDelimiter()) {
|
||||
CsvWriter<%=cid%>.setLineEnd("\r\n");
|
||||
} else {
|
||||
CsvWriter<%=cid%>.setLineEnd(""+csvSettings_<%=cid%>.getRowDelim());
|
||||
}
|
||||
<%
|
||||
} else {
|
||||
%>
|
||||
if(!csvSettings_<%=cid%>.isUseCRLFRecordDelimiter() && csvSettings_<%=cid%>.getRowDelim()!='\r' && csvSettings_<%=cid%>.getRowDelim()!='\n') {
|
||||
CsvWriter<%=cid%>.setLineEnd(""+csvSettings_<%=cid%>.getRowDelim());
|
||||
}
|
||||
<%
|
||||
}
|
||||
%>
|
||||
|
||||
//set header.
|
||||
<%
|
||||
if(isIncludeHeader && !isAppend){
|
||||
@@ -735,7 +756,7 @@ if(("false").equals(ElementParameterParser.getValue(node,"__CSV_OPTION__"))) {
|
||||
}
|
||||
<%
|
||||
}
|
||||
if (codeGenArgument.subTreeContainsParallelIterate()) {
|
||||
if (((AbstractNode)node).getParallelIterator() != null) {
|
||||
%>
|
||||
}
|
||||
<%
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
org.talend.designer.codegen.config.CodeGeneratorArgument
|
||||
org.talend.core.model.process.ElementParameterParser
|
||||
java.util.List
|
||||
org.talend.core.model.utils.NodeUtil
|
||||
org.talend.core.model.process.AbstractNode
|
||||
"
|
||||
%>
|
||||
<%
|
||||
@@ -30,9 +32,9 @@
|
||||
synchronized (multiThreadLockWrite) {
|
||||
<%
|
||||
}
|
||||
if (codeGenArgument.subTreeContainsParallelIterate()) {
|
||||
if (((AbstractNode)node).getParallelIterator() != null) {
|
||||
%>
|
||||
synchronized (lockWrite) {
|
||||
synchronized ((Object[])globalMap.get("lockWrite_<%=((AbstractNode)node).getParallelIterator()%>")) {
|
||||
<%
|
||||
}
|
||||
if (isParallelize) {
|
||||
@@ -57,7 +59,7 @@
|
||||
}
|
||||
<%
|
||||
}
|
||||
if (codeGenArgument.subTreeContainsParallelIterate()) {
|
||||
if (((AbstractNode)node).getParallelIterator() != null) {
|
||||
%>
|
||||
}
|
||||
<%
|
||||
|
||||
@@ -7,8 +7,10 @@
|
||||
org.talend.core.model.process.IConnectionCategory
|
||||
org.talend.core.model.process.ElementParameterParser
|
||||
org.talend.designer.codegen.config.CodeGeneratorArgument
|
||||
org.talend.core.model.utils.NodeUtil
|
||||
java.util.List
|
||||
java.util.Map
|
||||
org.talend.core.model.process.AbstractNode
|
||||
"
|
||||
%>
|
||||
<%
|
||||
@@ -70,9 +72,9 @@ if ((metadatas!=null)&&(metadatas.size()>0)) {
|
||||
synchronized (multiThreadLockWrite) {
|
||||
<%
|
||||
}
|
||||
if (codeGenArgument.subTreeContainsParallelIterate()) {
|
||||
if (((AbstractNode)node).getParallelIterator() != null) {
|
||||
%>
|
||||
synchronized (lockWrite) {
|
||||
synchronized ((Object[])globalMap.get("lockWrite_<%=((AbstractNode)node).getParallelIterator()%>")) {
|
||||
<%
|
||||
}
|
||||
if (isParallelize) {
|
||||
@@ -96,7 +98,7 @@ if ((metadatas!=null)&&(metadatas.size()>0)) {
|
||||
}
|
||||
<%
|
||||
}
|
||||
if (codeGenArgument.subTreeContainsParallelIterate()) {
|
||||
if (((AbstractNode)node).getParallelIterator() != null) {
|
||||
%>
|
||||
}
|
||||
<%
|
||||
|
||||
Binary file not shown.
@@ -22,6 +22,7 @@ imports="
|
||||
|
||||
boolean validate = ("true").equals(ElementParameterParser.getValue(node,"__VALIDATE__"));
|
||||
boolean isGenerateId = ("true").equals(ElementParameterParser.getValue(node,"__GENERATE_ID__"));
|
||||
boolean insertOnly = ("true").equals(ElementParameterParser.getValue(node,"__INSERT_ONLY__"));
|
||||
|
||||
boolean useTransaction = ("true").equals(ElementParameterParser.getValue(node,"__USE_TRANSACTION__"));
|
||||
String transactionProvider = ElementParameterParser.getValue(node,"__TRANSACTION_PROVIDER__");
|
||||
@@ -41,6 +42,6 @@ if(mdmTransaction_<%=cid%>!=null) {
|
||||
}
|
||||
<%}%>
|
||||
bulkloadClient_<%=cid %>.startThreadCount();
|
||||
bulkloadClient_<%=cid %>.setOptions(new org.talend.mdm.bulkload.client.BulkloadOptions(<%=isGenerateId %>, <%=validate %>, <%=arraySize%>));
|
||||
bulkloadClient_<%=cid %>.setOptions(new org.talend.mdm.bulkload.client.BulkloadOptions(<%=isGenerateId %>, <%=validate %>, <%=arraySize%>, <%=insertOnly%>));
|
||||
int count_<%=cid%> = 0;
|
||||
org.talend.mdm.bulkload.client.InputStreamMerger inputStreamMerger_<%=cid%> = null;
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
<%@ jet
|
||||
imports="
|
||||
org.talend.core.model.process.INode
|
||||
org.talend.designer.codegen.config.CodeGeneratorArgument"
|
||||
%>
|
||||
<%
|
||||
CodeGeneratorArgument codeGenArgument = (CodeGeneratorArgument) argument;
|
||||
INode node = (INode)codeGenArgument.getArgument();
|
||||
String cid = node.getUniqueName();
|
||||
%>
|
||||
Object o<%=cid %> = resourceMap.get("mdmBulkStream<%=cid %>");
|
||||
if(o<%=cid %> != null){
|
||||
org.talend.mdm.bulkload.client.InputStreamMerger stream = (org.talend.mdm.bulkload.client.InputStreamMerger)o<%=cid %>;
|
||||
stream.clean();
|
||||
}
|
||||
@@ -86,6 +86,10 @@
|
||||
<DEFAULT>false</DEFAULT>
|
||||
</PARAMETER>
|
||||
|
||||
<PARAMETER NAME="INSERT_ONLY" FIELD="CHECK" NUM_ROW="50">
|
||||
<DEFAULT>false</DEFAULT>
|
||||
</PARAMETER>
|
||||
|
||||
<PARAMETER NAME="MASS_LEVEL" FIELD="TEXT" NUM_ROW="60"
|
||||
REQUIRED="true">
|
||||
<DEFAULT>500</DEFAULT>
|
||||
|
||||
@@ -29,6 +29,7 @@ if (count_<%=cid%> % <%=arraySize%> == 0) {
|
||||
if(inputStreamMerger_<%=cid%> != null)
|
||||
inputStreamMerger_<%=cid%>.close();
|
||||
inputStreamMerger_<%=cid%> = bulkloadClient_<%=cid %>.load();
|
||||
resourceMap.put("mdmBulkStream<%=cid %>", inputStreamMerger_<%=cid%>);
|
||||
}
|
||||
|
||||
if(<%=conn.getName()%>.<%=xmlField %>!=null){
|
||||
|
||||
@@ -8,6 +8,7 @@ DATACONCEPT.NAME=Entity
|
||||
XMLFIELD.NAME=XML Field
|
||||
VALIDATE.NAME=Validate
|
||||
GENERATE_ID.NAME=Generate ID
|
||||
INSERT_ONLY.NAME=Insert only
|
||||
MASS_LEVEL.NAME=Commit size
|
||||
HELP=org.talend.help.tMDMOutput
|
||||
LONG_NAME=Output an xml structure to the talend MDM web service
|
||||
|
||||
@@ -8,6 +8,7 @@ DATACONCEPT.NAME=Entity
|
||||
XMLFIELD.NAME=XML Field
|
||||
VALIDATE.NAME=Validate
|
||||
GENERATE_ID.NAME=Generate ID
|
||||
INSERT_ONLY.NAME=Insert only
|
||||
MASS_LEVEL.NAME=Commit size
|
||||
HELP=org.talend.help.tMDMOutput
|
||||
LONG_NAME=Output an xml structure to the talend MDM web service
|
||||
|
||||
@@ -177,8 +177,10 @@ if ((metadatas != null) && (metadatas.size() > 0)) {//1
|
||||
|
||||
boolean continueFlag_<%=cid%> = true;
|
||||
int totalCount_<%=cid%> = -1;<%//For TDI-26039%>
|
||||
int totalPage_<%=cid %> = -1;
|
||||
int pageNumber_<%=cid %> = 0;
|
||||
while (continueFlag_<%=cid%>) {
|
||||
|
||||
pageNumber_<%=cid %>++;
|
||||
getitems_<%=cid%>=new org.talend.mdm.webservice.WSGetItems(dataCluster_<%=cid%>, <%=concept%>, wsItem_<%=cid%>,
|
||||
<%=spellThrehold%>, //spell Threshold
|
||||
skip_<%=cid%> + retrievedCount_<%=cid%>,
|
||||
@@ -188,6 +190,7 @@ if ((metadatas != null) && (metadatas.size() > 0)) {//1
|
||||
items_<%=cid%> = xtentisWS_<%=cid%>.getItems(getitems_<%=cid%>);
|
||||
if(totalCount_<%=cid%> < 0){
|
||||
totalCount_<%=cid%> = Integer.valueOf(items_<%=cid%>[0].replaceAll("<totalCount>", "").replaceAll("</totalCount>", ""));
|
||||
totalPage_<%=cid %> = totalCount_<%=cid%>/recordsPerPage_<%=cid%> +1;
|
||||
}
|
||||
} catch(java.lang.Exception e) {
|
||||
<%if(dieOnError) {%>
|
||||
@@ -197,7 +200,7 @@ if ((metadatas != null) && (metadatas.size() > 0)) {//1
|
||||
<% } %>
|
||||
}
|
||||
retrievedCount_<%=cid%> += (items_<%=cid%>.length - 1);
|
||||
if (totalCount_<%=cid%> == retrievedCount_<%=cid%> || recordsPerPage_<%=cid%> == -1 || (items_<%=cid%>.length - 1) < readRecordsSize_<%=cid%> || limit_<%=cid%> == retrievedCount_<%=cid%>) {
|
||||
if (totalCount_<%=cid%> == retrievedCount_<%=cid%> || recordsPerPage_<%=cid%> == -1 || (items_<%=cid%>.length - 1) < 1 || pageNumber_<%=cid %> == totalPage_<%=cid %> || limit_<%=cid%> == retrievedCount_<%=cid%>) {
|
||||
continueFlag_<%=cid%> = false;
|
||||
} else if (limit_<%=cid%> != -1 && limit_<%=cid%> < retrievedCount_<%=cid%> + readRecordsSize_<%=cid%>) {
|
||||
readRecordsSize_<%=cid%> = limit_<%=cid%> - retrievedCount_<%=cid%>;
|
||||
|
||||
@@ -842,4 +842,6 @@ PaserRuleSelectionDialog.RULE_VALUE=Rule Value
|
||||
PasswordController.NewPassword=Enter a new password
|
||||
PasswordController.NoteConvention=Note: Follow the usual Java convention which requires text to be surrounded by double quotes.
|
||||
NodeSelectedDialog.title=Select node
|
||||
NodeSelectedDialog.msg=Please select a node.
|
||||
NodeSelectedDialog.msg=Please select a node.
|
||||
SaveRoutineContentError.ErrorTitile=Error
|
||||
SaveRoutineContentError.ErrorContent=Save Routine Failed!
|
||||
@@ -158,6 +158,7 @@ public class ElementParameter implements IElementParameter {
|
||||
*
|
||||
* @see org.talend.designer.core.model.components.IDesignerElementParameter#setName(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public void setName(final String s) {
|
||||
name = s;
|
||||
}
|
||||
@@ -167,10 +168,12 @@ public class ElementParameter implements IElementParameter {
|
||||
*
|
||||
* @see org.talend.designer.core.model.components.IDesignerElementParameter#getVariableName()
|
||||
*/
|
||||
@Override
|
||||
public String getVariableName() {
|
||||
return "__" + name + "__"; //$NON-NLS-1$ //$NON-NLS-2$
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCategory(final EComponentCategory cat) {
|
||||
category = cat;
|
||||
}
|
||||
@@ -180,6 +183,7 @@ public class ElementParameter implements IElementParameter {
|
||||
*
|
||||
* @see org.talend.designer.core.model.components.IDesignerElementParameter#getCategory()
|
||||
*/
|
||||
@Override
|
||||
public EComponentCategory getCategory() {
|
||||
return this.category;
|
||||
}
|
||||
@@ -189,6 +193,7 @@ public class ElementParameter implements IElementParameter {
|
||||
*
|
||||
* @see org.talend.designer.core.model.components.IDesignerElementParameter#setDisplayName(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public void setDisplayName(final String s) {
|
||||
displayName = s;
|
||||
}
|
||||
@@ -199,6 +204,7 @@ public class ElementParameter implements IElementParameter {
|
||||
* @seeorg.talend.designer.core.model.components.IDesignerElementParameter#setField(org.talend.core.model.designer.
|
||||
* EParameterFieldType)
|
||||
*/
|
||||
@Override
|
||||
public void setFieldType(final EParameterFieldType type) {
|
||||
field = type;
|
||||
}
|
||||
@@ -208,10 +214,12 @@ public class ElementParameter implements IElementParameter {
|
||||
*
|
||||
* @see org.talend.designer.core.model.components.IDesignerElementParameter#setValue(java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public void setValue(final Object o) {
|
||||
value = o;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
@@ -221,6 +229,7 @@ public class ElementParameter implements IElementParameter {
|
||||
*
|
||||
* @see org.talend.designer.core.model.components.IDesignerElementParameter#getDisplayName()
|
||||
*/
|
||||
@Override
|
||||
public String getDisplayName() {
|
||||
return displayName;
|
||||
}
|
||||
@@ -230,6 +239,7 @@ public class ElementParameter implements IElementParameter {
|
||||
*
|
||||
* @see org.talend.designer.core.model.components.IDesignerElementParameter#getField()
|
||||
*/
|
||||
@Override
|
||||
public EParameterFieldType getFieldType() {
|
||||
return field;
|
||||
}
|
||||
@@ -239,26 +249,32 @@ public class ElementParameter implements IElementParameter {
|
||||
*
|
||||
* @see org.talend.designer.core.model.components.IDesignerElementParameter#getValue()
|
||||
*/
|
||||
@Override
|
||||
public Object getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setListItemsDisplayName(final String[] list) {
|
||||
itemsDisplayName = list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getListItemsDisplayName() {
|
||||
return itemsDisplayName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setListItemsDisplayCodeName(final String[] list) {
|
||||
itemsDisplayCodeName = list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getListItemsDisplayCodeName() {
|
||||
return itemsDisplayCodeName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setListItemsValue(final Object[] list) {
|
||||
if (this.getFieldType() == EParameterFieldType.TABLE) {
|
||||
EParameterFieldType.AS400_CHECK.getClass();
|
||||
@@ -266,42 +282,52 @@ public class ElementParameter implements IElementParameter {
|
||||
itemsValue = list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object[] getListItemsValue() {
|
||||
return itemsValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDefaultClosedListValue(Object o) {
|
||||
defaultClosedListValue = o;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getDefaultClosedListValue() {
|
||||
return defaultClosedListValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setListRepositoryItems(final String[] list) {
|
||||
itemsRepository = list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getListRepositoryItems() {
|
||||
return itemsRepository;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setListItemsShowIf(String[] list) {
|
||||
itemsShowIf = list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getListItemsShowIf() {
|
||||
return itemsShowIf;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setListItemsNotShowIf(String[] list) {
|
||||
itemsNotShowIf = list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getListItemsNotShowIf() {
|
||||
return itemsNotShowIf;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getIndexOfItemFromList(String item) {
|
||||
int index = -1;
|
||||
boolean found = false;
|
||||
@@ -324,22 +350,27 @@ public class ElementParameter implements IElementParameter {
|
||||
return index;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getNbLines() {
|
||||
return this.nbLines;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setNbLines(final int nbLines) {
|
||||
this.nbLines = nbLines;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getNumRow() {
|
||||
return this.numRow;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setNumRow(final int numRow) {
|
||||
this.numRow = numRow;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isReadOnly() {
|
||||
if (element != null) {
|
||||
return (this.readOnly || element.isReadOnly());
|
||||
@@ -351,54 +382,67 @@ public class ElementParameter implements IElementParameter {
|
||||
return this.readOnly;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setReadOnly(final boolean readOnly) {
|
||||
this.readOnly = readOnly;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRequired() {
|
||||
return this.required;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRequired(final boolean required) {
|
||||
this.required = required;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setShow(final boolean show) {
|
||||
this.show = show;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRepositoryValue() {
|
||||
return this.repositoryValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRepositoryValue(String repositoryValue) {
|
||||
this.repositoryValue = repositoryValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRepositoryValueUsed() {
|
||||
return this.repositoryValueUsed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRepositoryValueUsed(boolean repositoryUsed) {
|
||||
this.repositoryValueUsed = repositoryUsed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getShowIf() {
|
||||
return showIf;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setShowIf(String showIf) {
|
||||
this.showIf = showIf;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNotShowIf() {
|
||||
return notShowIf;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setNotShowIf(String notShowIf) {
|
||||
this.notShowIf = notShowIf;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isShow(List<? extends IElementParameter> listParam) {
|
||||
boolean showParameter = false;
|
||||
|
||||
@@ -415,6 +459,7 @@ public class ElementParameter implements IElementParameter {
|
||||
}
|
||||
|
||||
// added by dlin for feature TDI-22421
|
||||
@Override
|
||||
public boolean isRequired(List<? extends IElementParameter> listParam) {
|
||||
boolean requiredParameter = false;
|
||||
if (this.requiredIF != null && !required) {
|
||||
@@ -425,6 +470,7 @@ public class ElementParameter implements IElementParameter {
|
||||
return requiredParameter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isShow(String conditionShowIf, String conditionNotShowIf, List<? extends IElementParameter> listParam) {
|
||||
boolean showParameter = false;
|
||||
|
||||
@@ -454,19 +500,29 @@ public class ElementParameter implements IElementParameter {
|
||||
return showParameter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<IElementParameterDefaultValue> getDefaultValues() {
|
||||
return this.defaultValues;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDefaultValues(List<IElementParameterDefaultValue> defaultValues) {
|
||||
this.defaultValues = defaultValues;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValueToDefault(List<? extends IElementParameter> listParam) {
|
||||
for (IElementParameterDefaultValue defaultValue : defaultValues) {
|
||||
if (defaultValues == null) {
|
||||
return;
|
||||
}
|
||||
int size = defaultValues.size();
|
||||
// a performance improvement, and keep the result like before.
|
||||
// for (IElementParameterDefaultValue defaultValue : defaultValues) {
|
||||
for (int i = size - 1; 0 <= i; i--) {
|
||||
IElementParameterDefaultValue iDefaultValue = defaultValues.get(i);
|
||||
boolean setDefaultValue = false;
|
||||
String conditionIf = defaultValue.getIfCondition();
|
||||
String conditionNotIf = defaultValue.getNotIfCondition();
|
||||
String conditionIf = iDefaultValue.getIfCondition();
|
||||
String conditionNotIf = iDefaultValue.getNotIfCondition();
|
||||
|
||||
if ((conditionIf != null) || (conditionNotIf != null)) {
|
||||
if (conditionIf != null) {
|
||||
@@ -477,26 +533,31 @@ public class ElementParameter implements IElementParameter {
|
||||
}
|
||||
if (setDefaultValue) {
|
||||
if (this.field.equals(EParameterFieldType.CHECK) || this.field.equals(EParameterFieldType.RADIO)) {
|
||||
setValue(new Boolean(defaultValue.getDefaultValue().toString()));
|
||||
setValue(new Boolean(iDefaultValue.getDefaultValue().toString()));
|
||||
} else {
|
||||
setValue(defaultValue.getDefaultValue());
|
||||
setValue(iDefaultValue.getDefaultValue());
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public IElement getElement() {
|
||||
return element;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setElement(IElement element) {
|
||||
this.element = element;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBasedOnSchema() {
|
||||
return basedOnSchema;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBasedOnSchema(boolean basedOnSchema) {
|
||||
this.basedOnSchema = basedOnSchema;
|
||||
}
|
||||
@@ -509,10 +570,12 @@ public class ElementParameter implements IElementParameter {
|
||||
return name + ": " + value.toString(); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFilter() {
|
||||
return filter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFilter(String filter) {
|
||||
this.filter = filter;
|
||||
}
|
||||
@@ -522,6 +585,7 @@ public class ElementParameter implements IElementParameter {
|
||||
*
|
||||
* @return the noCheck
|
||||
*/
|
||||
@Override
|
||||
public boolean isNoCheck() {
|
||||
IPreferenceStore preferenceStore = DesignerPlugin.getDefault().getPreferenceStore();
|
||||
|
||||
@@ -542,6 +606,7 @@ public class ElementParameter implements IElementParameter {
|
||||
*
|
||||
* @param noCheck the noCheck to set
|
||||
*/
|
||||
@Override
|
||||
public void setNoCheck(boolean noCheck) {
|
||||
this.noCheck = noCheck;
|
||||
}
|
||||
@@ -551,6 +616,7 @@ public class ElementParameter implements IElementParameter {
|
||||
*
|
||||
* @return the context
|
||||
*/
|
||||
@Override
|
||||
public String getContext() {
|
||||
return context;
|
||||
}
|
||||
@@ -560,6 +626,7 @@ public class ElementParameter implements IElementParameter {
|
||||
*
|
||||
* @param context the context to set
|
||||
*/
|
||||
@Override
|
||||
public void setContext(String context) {
|
||||
this.context = context;
|
||||
}
|
||||
@@ -569,6 +636,7 @@ public class ElementParameter implements IElementParameter {
|
||||
*
|
||||
* @return the childParameters
|
||||
*/
|
||||
@Override
|
||||
public Map<String, IElementParameter> getChildParameters() {
|
||||
if (childParameters == null) {
|
||||
childParameters = new HashMap<String, IElementParameter>();
|
||||
@@ -576,10 +644,12 @@ public class ElementParameter implements IElementParameter {
|
||||
return childParameters;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IElementParameter getParentParameter() {
|
||||
return parentParameter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setParentParameter(IElementParameter parentParameter) {
|
||||
this.parentParameter = parentParameter;
|
||||
// keep the same category with parent.
|
||||
@@ -614,6 +684,7 @@ public class ElementParameter implements IElementParameter {
|
||||
*
|
||||
* @see org.talend.core.model.process.IElementParameter#getGroup()
|
||||
*/
|
||||
@Override
|
||||
public String getGroup() {
|
||||
return this.groupName;
|
||||
}
|
||||
@@ -623,6 +694,7 @@ public class ElementParameter implements IElementParameter {
|
||||
*
|
||||
* @see org.talend.core.model.process.IElementParameter#setGroup(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public void setGroup(String groupName) {
|
||||
this.groupName = groupName;
|
||||
}
|
||||
@@ -632,6 +704,7 @@ public class ElementParameter implements IElementParameter {
|
||||
*
|
||||
* @see org.talend.core.model.process.IElementParameter#getGroupDisplayName()
|
||||
*/
|
||||
@Override
|
||||
public String getGroupDisplayName() {
|
||||
return this.groupDisplayName;
|
||||
}
|
||||
@@ -641,6 +714,7 @@ public class ElementParameter implements IElementParameter {
|
||||
*
|
||||
* @see org.talend.core.model.process.IElementParameter#setGroupDisplayName(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public void setGroupDisplayName(String groupDisplayName) {
|
||||
this.groupDisplayName = groupDisplayName;
|
||||
}
|
||||
@@ -650,6 +724,7 @@ public class ElementParameter implements IElementParameter {
|
||||
*
|
||||
* @see org.talend.core.model.process.IElementParameter#getContextMode()
|
||||
*/
|
||||
@Override
|
||||
public boolean isContextMode() {
|
||||
return this.contextMode;
|
||||
}
|
||||
@@ -659,6 +734,7 @@ public class ElementParameter implements IElementParameter {
|
||||
*
|
||||
* @see org.talend.core.model.process.IElementParameter#setContextMode(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public void setContextMode(boolean mode) {
|
||||
this.contextMode = mode;
|
||||
}
|
||||
@@ -668,6 +744,7 @@ public class ElementParameter implements IElementParameter {
|
||||
*
|
||||
* @see org.talend.core.model.process.IElementParameter#getLabelFromRepository()
|
||||
*/
|
||||
@Override
|
||||
public String getLabelFromRepository() {
|
||||
return this.labelFromRepository;
|
||||
}
|
||||
@@ -677,6 +754,7 @@ public class ElementParameter implements IElementParameter {
|
||||
*
|
||||
* @see org.talend.core.model.process.IElementParameter#setLabelFromRepository(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public void setLabelFromRepository(String label) {
|
||||
this.labelFromRepository = label;
|
||||
|
||||
@@ -687,6 +765,7 @@ public class ElementParameter implements IElementParameter {
|
||||
*
|
||||
* @return the color
|
||||
*/
|
||||
@Override
|
||||
public RGB getColor() {
|
||||
return this.color;
|
||||
}
|
||||
@@ -696,6 +775,7 @@ public class ElementParameter implements IElementParameter {
|
||||
*
|
||||
* @param color the color to set
|
||||
*/
|
||||
@Override
|
||||
public void setColor(RGB color) {
|
||||
this.color = color;
|
||||
}
|
||||
@@ -705,6 +785,7 @@ public class ElementParameter implements IElementParameter {
|
||||
*
|
||||
* @return the backgroundColor
|
||||
*/
|
||||
@Override
|
||||
public RGB getBackgroundColor() {
|
||||
return this.backgroundColor;
|
||||
}
|
||||
@@ -714,6 +795,7 @@ public class ElementParameter implements IElementParameter {
|
||||
*
|
||||
* @param backgroundColor the backgroundColor to set
|
||||
*/
|
||||
@Override
|
||||
public void setBackgroundColor(RGB backgroundColor) {
|
||||
this.backgroundColor = backgroundColor;
|
||||
}
|
||||
@@ -723,6 +805,7 @@ public class ElementParameter implements IElementParameter {
|
||||
*
|
||||
* @see org.talend.core.model.process.IElementParameter#isBasedOnSubjobStarts()
|
||||
*/
|
||||
@Override
|
||||
public boolean isBasedOnSubjobStarts() {
|
||||
return basedOnSubjobStarts;
|
||||
}
|
||||
@@ -732,6 +815,7 @@ public class ElementParameter implements IElementParameter {
|
||||
*
|
||||
* @see org.talend.core.model.process.IElementParameter#setBasedOnSubjobStarts(boolean)
|
||||
*/
|
||||
@Override
|
||||
public void setBasedOnSubjobStarts(boolean basedOnSubjobStarts) {
|
||||
this.basedOnSubjobStarts = basedOnSubjobStarts;
|
||||
}
|
||||
@@ -741,6 +825,7 @@ public class ElementParameter implements IElementParameter {
|
||||
*
|
||||
* @see org.talend.core.model.process.IElementParameter#isDynamicSettings()
|
||||
*/
|
||||
@Override
|
||||
public boolean isDynamicSettings() {
|
||||
return this.dynamicSettings;
|
||||
}
|
||||
@@ -750,6 +835,7 @@ public class ElementParameter implements IElementParameter {
|
||||
*
|
||||
* @see org.talend.core.model.process.IElementParameter#setDynamicSettings(java.lang.Boolean)
|
||||
*/
|
||||
@Override
|
||||
public void setDynamicSettings(boolean dynamicSettings) {
|
||||
this.dynamicSettings = dynamicSettings;
|
||||
}
|
||||
@@ -759,6 +845,7 @@ public class ElementParameter implements IElementParameter {
|
||||
*
|
||||
* @see org.talend.core.model.process.IElementParameter#getListItemsNotReadOnlyIf()
|
||||
*/
|
||||
@Override
|
||||
public String[] getListItemsNotReadOnlyIf() {
|
||||
return this.itemsNotReadOnlyIf;
|
||||
}
|
||||
@@ -768,6 +855,7 @@ public class ElementParameter implements IElementParameter {
|
||||
*
|
||||
* @see org.talend.core.model.process.IElementParameter#getListItemsReadOnlyIf()
|
||||
*/
|
||||
@Override
|
||||
public String[] getListItemsReadOnlyIf() {
|
||||
return this.itemsReadOnlyIf;
|
||||
}
|
||||
@@ -777,6 +865,7 @@ public class ElementParameter implements IElementParameter {
|
||||
*
|
||||
* @see org.talend.core.model.process.IElementParameter#getNotReadOnlyIf()
|
||||
*/
|
||||
@Override
|
||||
public String getNotReadOnlyIf() {
|
||||
// TODO Auto-generated method stub
|
||||
return this.notReadonlyIf;
|
||||
@@ -787,6 +876,7 @@ public class ElementParameter implements IElementParameter {
|
||||
*
|
||||
* @see org.talend.core.model.process.IElementParameter#getReadOnlyIf()
|
||||
*/
|
||||
@Override
|
||||
public String getReadOnlyIf() {
|
||||
// TODO Auto-generated method stub
|
||||
return this.readonlyIf;
|
||||
@@ -797,6 +887,7 @@ public class ElementParameter implements IElementParameter {
|
||||
*
|
||||
* @see org.talend.core.model.process.IElementParameter#isReadOnly(java.util.List)
|
||||
*/
|
||||
@Override
|
||||
public boolean isReadOnly(List<? extends IElementParameter> listParam) {
|
||||
boolean readonlyParameter = false;
|
||||
|
||||
@@ -818,6 +909,7 @@ public class ElementParameter implements IElementParameter {
|
||||
* @see org.talend.core.model.process.IElementParameter#isReadOnly(java.lang.String, java.lang.String,
|
||||
* java.util.Map)
|
||||
*/
|
||||
@Override
|
||||
public boolean isReadOnly(String conditionReadOnlyIf, String conditionNotReadOnlyIf,
|
||||
List<? extends IElementParameter> listParam) {
|
||||
boolean readonlyParameter = false;
|
||||
@@ -839,6 +931,7 @@ public class ElementParameter implements IElementParameter {
|
||||
*
|
||||
* @see org.talend.core.model.process.IElementParameter#setListItemsNotReadOnlyIf(java.lang.String[])
|
||||
*/
|
||||
@Override
|
||||
public void setListItemsNotReadOnlyIf(String[] list) {
|
||||
itemsNotReadOnlyIf = list;
|
||||
|
||||
@@ -849,6 +942,7 @@ public class ElementParameter implements IElementParameter {
|
||||
*
|
||||
* @see org.talend.core.model.process.IElementParameter#setListItemsReadOnlyIf(java.lang.String[])
|
||||
*/
|
||||
@Override
|
||||
public void setListItemsReadOnlyIf(String[] list) {
|
||||
itemsReadOnlyIf = list;
|
||||
|
||||
@@ -859,6 +953,7 @@ public class ElementParameter implements IElementParameter {
|
||||
*
|
||||
* @see org.talend.core.model.process.IElementParameter#setNotReadOnlyIf(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public void setNotReadOnlyIf(String notReadOnly) {
|
||||
this.notReadonlyIf = notReadOnly;
|
||||
}
|
||||
@@ -868,26 +963,32 @@ public class ElementParameter implements IElementParameter {
|
||||
*
|
||||
* @see org.talend.core.model.process.IElementParameter#setReadOnlyIf(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public void setReadOnlyIf(String readOnly) {
|
||||
this.readonlyIf = readOnly;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isColumnsBasedOnSchema() {
|
||||
return this.columnsBasedOnSchema;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setColumnsBasedOnSchema(boolean columnsBasedOnSchema) {
|
||||
this.columnsBasedOnSchema = columnsBasedOnSchema;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isNoContextAssist() {
|
||||
return this.noContextAssist;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setNoContextAssist(boolean enable) {
|
||||
this.noContextAssist = enable;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IElementParameter getClone() {
|
||||
IElementParameter clone = new ElementParameter(this.element);
|
||||
|
||||
@@ -1038,6 +1139,7 @@ public class ElementParameter implements IElementParameter {
|
||||
*
|
||||
* @return the maxlength
|
||||
*/
|
||||
@Override
|
||||
public int getMaxlength() {
|
||||
return this.maxlength;
|
||||
}
|
||||
|
||||
@@ -311,18 +311,32 @@ public final class Expression {
|
||||
// #LINK@NODE, #PREVIOUS@NODE, #NEXT@NODE ----->implement them later
|
||||
if ((variableName != null) && (variableValue != null)) {
|
||||
if (varNames[0].equals("#LINK@NODE")) { //$NON-NLS-1$
|
||||
INode node = null;
|
||||
if (currentParam != null && currentParam.getElement() instanceof INode) {
|
||||
INode node = (INode) currentParam.getElement();
|
||||
node = (INode) currentParam.getElement();
|
||||
} else if (currentParam == null) {
|
||||
if (listParam != null && listParam.size() > 0) {
|
||||
IElement element = listParam.get(0).getElement();
|
||||
if (element instanceof INode) {
|
||||
node = (INode) element;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (node != null) {
|
||||
String relatedNodeName = ElementParameterParser.getValue(node, "__" + varNames[1] + "__"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
List<? extends INode> generatingNodes = node.getProcess().getGeneratingNodes();
|
||||
for (INode aNode : generatingNodes) {
|
||||
if (aNode.getUniqueName().equals(relatedNodeName)) {
|
||||
simpleExpression = simpleExpression.replace(varNames[0] + "." + varNames[1] + ".", ""); //$NON-NLS-1$ //$NON-NLS-2$//$NON-NLS-3$
|
||||
List<? extends IElementParameter> elementParameters = aNode.getElementParameters();
|
||||
// let's supose the currentParam = null, there won't want deal with the TABLE field, only
|
||||
// deal with LIST/CHECKBOX
|
||||
return evaluate(simpleExpression, elementParameters);
|
||||
// if relatedNodeName is empty, maybe means this property have not been setted
|
||||
if (relatedNodeName != null && !relatedNodeName.trim().isEmpty()) {
|
||||
List<? extends INode> generatingNodes = node.getProcess().getGeneratingNodes();
|
||||
for (INode aNode : generatingNodes) {
|
||||
if (aNode.getUniqueName().equals(relatedNodeName)) {
|
||||
simpleExpression = simpleExpression.replace(varNames[0] + "." + varNames[1] + ".", ""); //$NON-NLS-1$ //$NON-NLS-2$//$NON-NLS-3$
|
||||
List<? extends IElementParameter> elementParameters = aNode.getElementParameters();
|
||||
// let's supose the currentParam = null, there won't want deal with the TABLE field,
|
||||
// only
|
||||
// deal with LIST/CHECKBOX
|
||||
return evaluate(simpleExpression, elementParameters);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -662,28 +676,42 @@ public final class Expression {
|
||||
// debug: System.out.println(leftString + " => " +
|
||||
// leftExpression.isValid());
|
||||
}
|
||||
String rightString = string.substring(i + 3, string.length()).trim();
|
||||
Expression rightExpression = new Expression(rightString);
|
||||
expression.setRightExpression(rightExpression);
|
||||
if (rightString.contains("(") //$NON-NLS-1$
|
||||
|| isThereCondition(rightString, AND) || isThereCondition(rightString, OR)) {
|
||||
evaluateExpression(rightExpression, listParam, currentParam);
|
||||
} else { // no bracket == evaluate expression
|
||||
rightExpression.setValid(evaluateSimpleExpression(rightString, listParam, currentParam));
|
||||
// debug: System.out.println(rightString + " => " +
|
||||
// rightExpression.isValid());
|
||||
|
||||
boolean needValidRightExpression = true;
|
||||
if (expression.getCondition().equals(AND) && !expression.getLeftExpression().isValid()) {
|
||||
// if left expression is already false, then needn't continue to validate right expression
|
||||
expression.setValid(false);
|
||||
needValidRightExpression = false;
|
||||
} else if (expression.getCondition().equals(OR) && expression.getLeftExpression().isValid()) {
|
||||
// if left expression is already true, then need't continue to validate right expression
|
||||
expression.setValid(true);
|
||||
needValidRightExpression = false;
|
||||
}
|
||||
if (expression.getCondition().equals(AND)) {
|
||||
if (expression.getLeftExpression().isValid() && expression.getRightExpression().isValid()) {
|
||||
expression.setValid(true);
|
||||
} else {
|
||||
expression.setValid(false);
|
||||
|
||||
if (needValidRightExpression) {
|
||||
String rightString = string.substring(i + 3, string.length()).trim();
|
||||
Expression rightExpression = new Expression(rightString);
|
||||
expression.setRightExpression(rightExpression);
|
||||
if (rightString.contains("(") //$NON-NLS-1$
|
||||
|| isThereCondition(rightString, AND) || isThereCondition(rightString, OR)) {
|
||||
evaluateExpression(rightExpression, listParam, currentParam);
|
||||
} else { // no bracket == evaluate expression
|
||||
rightExpression.setValid(evaluateSimpleExpression(rightString, listParam, currentParam));
|
||||
// debug: System.out.println(rightString + " => " +
|
||||
// rightExpression.isValid());
|
||||
}
|
||||
} else if (expression.getCondition().equals(OR)) {
|
||||
if (expression.getLeftExpression().isValid() || expression.getRightExpression().isValid()) {
|
||||
expression.setValid(true);
|
||||
} else {
|
||||
expression.setValid(false);
|
||||
if (expression.getCondition().equals(AND)) {
|
||||
if (expression.getLeftExpression().isValid() && expression.getRightExpression().isValid()) {
|
||||
expression.setValid(true);
|
||||
} else {
|
||||
expression.setValid(false);
|
||||
}
|
||||
} else if (expression.getCondition().equals(OR)) {
|
||||
if (expression.getLeftExpression().isValid() || expression.getRightExpression().isValid()) {
|
||||
expression.setValid(true);
|
||||
} else {
|
||||
expression.setValid(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,6 +47,7 @@ import org.talend.core.model.process.AbstractNode;
|
||||
import org.talend.core.model.process.EComponentCategory;
|
||||
import org.talend.core.model.process.EConnectionType;
|
||||
import org.talend.core.model.process.EParameterFieldType;
|
||||
import org.talend.core.model.process.ElementParameterParser;
|
||||
import org.talend.core.model.process.IConnection;
|
||||
import org.talend.core.model.process.IConnectionCategory;
|
||||
import org.talend.core.model.process.IElement;
|
||||
@@ -1770,6 +1771,20 @@ public class DataProcess implements IGeneratingProcess {
|
||||
dataNodeList.remove(preStaLogConNode);
|
||||
dataNodeList.add(0, preStaLogConNode);
|
||||
}
|
||||
|
||||
// tag all the components after Iterator(Parallel)
|
||||
// !iterator with parallel shouldn't work on merge!
|
||||
for (INode node : dataNodeList) {
|
||||
if (node.isSubProcessStart() && node.isActivate()) {
|
||||
tagComponentAfterParallelIterator(node);
|
||||
}
|
||||
}
|
||||
for (INode node : dataNodeList) {
|
||||
if (node.isSubProcessStart() && node.isActivate()) {
|
||||
tagSubProcessAfterParallelIterator(node);
|
||||
}
|
||||
}
|
||||
|
||||
checkRefList = null;
|
||||
checkMultipleMap = null;
|
||||
checktUniteMap = null;
|
||||
@@ -1781,6 +1796,50 @@ public class DataProcess implements IGeneratingProcess {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* DOC bchen Comment method "tagSubProcessAfterParallelIterator".
|
||||
*
|
||||
* @param node
|
||||
*/
|
||||
private void tagSubProcessAfterParallelIterator(INode node) {
|
||||
if (node.getIncomingConnections() != null && node.getIncomingConnections().size() != 0) {
|
||||
IConnection connection = node.getIncomingConnections().get(0);
|
||||
if (connection.getLineStyle().equals(EConnectionType.ON_COMPONENT_OK)
|
||||
|| connection.getLineStyle().equals(EConnectionType.ON_COMPONENT_ERROR)
|
||||
|| connection.getLineStyle().equals(EConnectionType.ON_SUBJOB_OK)
|
||||
|| connection.getLineStyle().equals(EConnectionType.ON_SUBJOB_ERROR)
|
||||
|| connection.getLineStyle().equals(EConnectionType.RUN_IF)) {// add if you think it should be count
|
||||
// for parallel Iterator
|
||||
if (((AbstractNode) connection.getSource()).getParallelIterator() != null) {
|
||||
((AbstractNode) node).setParallelIterator(((AbstractNode) connection.getSource()).getParallelIterator());
|
||||
tagComponentAfterParallelIterator(node);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* DOC bchen Comment method "tagComponentAfterParallelIterator".
|
||||
*
|
||||
* @param node
|
||||
*/
|
||||
private void tagComponentAfterParallelIterator(INode node) {
|
||||
for (IConnection connection : node.getOutgoingSortedConnections()) {
|
||||
if (connection.getTarget().isActivate()) {
|
||||
|
||||
if (connection.getLineStyle().hasConnectionCategory(IConnectionCategory.MAIN | IConnectionCategory.USE_ITERATE)) {
|
||||
if (((AbstractNode) node).getParallelIterator() != null) {
|
||||
((AbstractNode) connection.getTarget()).setParallelIterator(((AbstractNode) node).getParallelIterator());
|
||||
} else if (connection.getLineStyle().equals(EConnectionType.ITERATE)
|
||||
&& Boolean.TRUE.toString().equals(ElementParameterParser.getValue(connection, "__ENABLE_PARALLEL__"))) {
|
||||
((AbstractNode) connection.getTarget()).setParallelIterator(connection.getTarget().getUniqueName());
|
||||
}
|
||||
tagComponentAfterParallelIterator(connection.getTarget());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void checkPigLoadComponent() {
|
||||
// if (PluginChecker.isPigudfPluginLoaded()) {
|
||||
// for (INode dataNode : dataNodeList) {
|
||||
|
||||
@@ -16,9 +16,15 @@ import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.core.resources.IResource;
|
||||
import org.eclipse.core.resources.IWorkspace;
|
||||
import org.eclipse.core.resources.IWorkspaceRunnable;
|
||||
import org.eclipse.core.resources.IncrementalProjectBuilder;
|
||||
import org.eclipse.core.resources.ResourcesPlugin;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.IStatus;
|
||||
import org.eclipse.core.runtime.Status;
|
||||
import org.eclipse.core.runtime.jobs.ISchedulingRule;
|
||||
import org.eclipse.emf.common.notify.Notification;
|
||||
import org.eclipse.emf.common.notify.impl.AdapterImpl;
|
||||
import org.eclipse.emf.common.util.EList;
|
||||
@@ -55,16 +61,19 @@ import org.talend.commons.ui.runtime.image.ImageProvider;
|
||||
import org.talend.commons.utils.VersionUtils;
|
||||
import org.talend.core.CorePlugin;
|
||||
import org.talend.core.GlobalServiceRegister;
|
||||
import org.talend.core.model.general.Project;
|
||||
import org.talend.core.model.properties.ByteArray;
|
||||
import org.talend.core.model.properties.FileItem;
|
||||
import org.talend.core.model.properties.Information;
|
||||
import org.talend.core.model.properties.Item;
|
||||
import org.talend.core.model.properties.Property;
|
||||
import org.talend.core.model.properties.RoutineItem;
|
||||
import org.talend.core.model.repository.ERepositoryObjectType;
|
||||
import org.talend.core.model.repository.Folder;
|
||||
import org.talend.core.model.repository.IRepositoryViewObject;
|
||||
import org.talend.core.model.utils.RepositoryManagerHelper;
|
||||
import org.talend.core.repository.model.ProxyRepositoryFactory;
|
||||
import org.talend.core.runtime.CoreRuntimePlugin;
|
||||
import org.talend.core.ui.ILastVersionChecker;
|
||||
import org.talend.core.ui.IUIRefresher;
|
||||
import org.talend.core.ui.branding.IBrandingService;
|
||||
@@ -74,6 +83,7 @@ import org.talend.designer.core.ui.action.SaveAsRoutineAction;
|
||||
import org.talend.designer.core.ui.action.SaveAsSQLPatternAction;
|
||||
import org.talend.designer.core.ui.views.problems.Problems;
|
||||
import org.talend.designer.core.utils.DesignerColorUtils;
|
||||
import org.talend.repository.ProjectManager;
|
||||
import org.talend.repository.RepositoryWorkUnit;
|
||||
import org.talend.repository.editor.RepositoryEditorInput;
|
||||
import org.talend.repository.model.ERepositoryStatus;
|
||||
@@ -299,6 +309,27 @@ public class StandAloneTalendJavaEditor extends CompilationUnitEditor implements
|
||||
|
||||
}
|
||||
|
||||
public void resetItem() throws PersistenceException {
|
||||
if (item.getProperty().eResource() == null || item.eResource() == null) {
|
||||
IRepositoryService service = CoreRuntimePlugin.getInstance().getRepositoryService();
|
||||
IProxyRepositoryFactory factory = service.getProxyRepositoryFactory();
|
||||
//
|
||||
// Property updated = factory.getUptodateProperty(getItem().getProperty());
|
||||
Property updatedProperty = null;
|
||||
try {
|
||||
factory.initialize();
|
||||
IRepositoryViewObject repositoryViewObject = factory.getLastVersion(new Project(ProjectManager.getInstance()
|
||||
.getProject(item.getProperty().getItem())), item.getProperty().getId());
|
||||
if (repositoryViewObject != null) {
|
||||
updatedProperty = repositoryViewObject.getProperty();
|
||||
item = (FileItem) updatedProperty.getItem();
|
||||
}
|
||||
} catch (PersistenceException e) {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doSave(final IProgressMonitor monitor) {
|
||||
IRepositoryService service = CorePlugin.getDefault().getRepositoryService();
|
||||
@@ -325,6 +356,7 @@ public class StandAloneTalendJavaEditor extends CompilationUnitEditor implements
|
||||
super.doSave(monitor);
|
||||
|
||||
try {
|
||||
resetItem();
|
||||
ByteArray byteArray = item.getContent();
|
||||
byteArray.setInnerContentFromFile(((FileEditorInput) getEditorInput()).getFile());
|
||||
try {
|
||||
@@ -343,8 +375,10 @@ public class StandAloneTalendJavaEditor extends CompilationUnitEditor implements
|
||||
refreshJobAndSave(repFactory);
|
||||
}
|
||||
};
|
||||
repositoryWorkUnit.setAvoidSvnUpdate(true);
|
||||
repositoryWorkUnit.setAvoidUnloadResources(true);
|
||||
repFactory.executeRepositoryWorkUnit(repositoryWorkUnit);
|
||||
|
||||
repositoryWorkUnit.throwPersistenceExceptionIfAny();
|
||||
// for bug 11930: Unable to save Routines.* in db project
|
||||
|
||||
// repFactory.save(item);
|
||||
@@ -357,13 +391,47 @@ public class StandAloneTalendJavaEditor extends CompilationUnitEditor implements
|
||||
|
||||
}
|
||||
|
||||
private void refreshJobAndSave(final IProxyRepositoryFactory repFactory) {
|
||||
private void refreshJobAndSave(final IProxyRepositoryFactory repFactory) throws PersistenceException {
|
||||
|
||||
final IWorkspaceRunnable op = new IWorkspaceRunnable() {
|
||||
|
||||
@Override
|
||||
public void run(IProgressMonitor monitor) throws CoreException {
|
||||
try {
|
||||
repFactory.save(item);
|
||||
} catch (PersistenceException e) {
|
||||
throw new CoreException(new Status(IStatus.ERROR, DesignerPlugin.ID, "Save Routine failed!", e));
|
||||
}
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
IRunnableWithProgress iRunnableWithProgress = new IRunnableWithProgress() {
|
||||
|
||||
@Override
|
||||
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
|
||||
IWorkspace workspace = ResourcesPlugin.getWorkspace();
|
||||
try {
|
||||
ISchedulingRule schedulingRule = workspace.getRoot();
|
||||
// the update the project files need to be done in the workspace runnable to avoid all
|
||||
// notification
|
||||
// of changes before the end of the modifications.
|
||||
workspace.run(op, schedulingRule, IWorkspace.AVOID_UPDATE, monitor);
|
||||
} catch (CoreException e) {
|
||||
throw new InvocationTargetException(e);
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
try {
|
||||
// cause it to update MaxInformationLevel
|
||||
repFactory.save(item);
|
||||
} catch (Exception e) {
|
||||
PlatformUI.getWorkbench().getProgressService().run(false, false, iRunnableWithProgress);
|
||||
} catch (InvocationTargetException e) {
|
||||
throw new PersistenceException(e);
|
||||
} catch (InterruptedException e) {
|
||||
throw new PersistenceException(e);
|
||||
}
|
||||
// update editor image
|
||||
|
||||
setTitleImage(getTitleImage());
|
||||
|
||||
}
|
||||
|
||||
@@ -433,6 +433,10 @@ public class NodesPasteCommand extends Command {
|
||||
copyOfMetadataList.add(newTable);
|
||||
}
|
||||
pastedNode.setMetadataList(copyOfMetadataList);
|
||||
}
|
||||
|
||||
// TDQ-10039 extract this code from above "else",aslo consider tMatchGroup.
|
||||
if (mainConnector.isMultiSchema() || copiedNode.getComponent().getName().startsWith("tMatchGroup")) { //$NON-NLS-1$
|
||||
IExternalNode externalNode = pastedNode.getExternalNode();
|
||||
if (externalNode != null) {
|
||||
if (copiedNode.getExternalData() != null) {
|
||||
|
||||
@@ -77,7 +77,7 @@ public class PropertyChangeCommand extends Command {
|
||||
|
||||
private final Map<IElementParameter, Object> oldElementValues;
|
||||
|
||||
private ChangeMetadataCommand changeMetadataCommand;
|
||||
private List<ChangeMetadataCommand> changeMetadataCommands;
|
||||
|
||||
private String propertyTypeName;
|
||||
|
||||
@@ -106,6 +106,7 @@ public class PropertyChangeCommand extends Command {
|
||||
newValue = propValue;
|
||||
toUpdate = false;
|
||||
oldElementValues = new HashMap<IElementParameter, Object>();
|
||||
changeMetadataCommands = new ArrayList<ChangeMetadataCommand>();
|
||||
setLabel(Messages.getString("PropertyChangeCommand.Label")); //$NON-NLS-1$
|
||||
// for job settings extra (feature 2710)
|
||||
// if (JobSettingsConstants.isExtraParameter(propName) ||
|
||||
@@ -128,9 +129,50 @@ public class PropertyChangeCommand extends Command {
|
||||
// }
|
||||
}
|
||||
|
||||
private List<INode> getRelativeNodes(List<? extends IElementParameter> elementParameters) {
|
||||
List<INode> retList = null;
|
||||
if (elementParameters == null || elementParameters.size() == 0) {
|
||||
return retList;
|
||||
}
|
||||
IElement element = elementParameters.get(0).getElement();
|
||||
if (element instanceof Node) {
|
||||
Node operatingNode = (Node) element;
|
||||
IProcess process = operatingNode.getProcess();
|
||||
if (process == null) {
|
||||
return retList;
|
||||
}
|
||||
List<? extends INode> graphicNodes = process.getGraphicalNodes();
|
||||
if (graphicNodes == null || graphicNodes.size() == 0) {
|
||||
return retList;
|
||||
}
|
||||
String nodeName = operatingNode.getLabel();
|
||||
retList = new ArrayList<INode>();
|
||||
for (INode node : graphicNodes) {
|
||||
List<? extends IElementParameter> nodeElementParameters = node.getElementParameters();
|
||||
if (nodeElementParameters == null || nodeElementParameters.size() == 0) {
|
||||
continue;
|
||||
}
|
||||
for (IElementParameter elementParameter : nodeElementParameters) {
|
||||
if (elementParameter.getFieldType() == EParameterFieldType.COMPONENT_LIST) {
|
||||
Object objName = elementParameter.getValue();
|
||||
if (objName == null) {
|
||||
continue;
|
||||
}
|
||||
String relatedComponentsName = objName.toString();
|
||||
if (relatedComponentsName.equals(nodeName)) {
|
||||
retList.add(node);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return retList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
IElementParameter currentParam = elem.getElementParameter(propName);
|
||||
changeMetadataCommands.clear();
|
||||
oldElementValues.clear();
|
||||
if (currentParam == null) {
|
||||
return;
|
||||
@@ -316,74 +358,11 @@ public class PropertyChangeCommand extends Command {
|
||||
if (!toUpdate
|
||||
&& (currentParam.getFieldType().equals(EParameterFieldType.RADIO)
|
||||
|| currentParam.getFieldType().equals(EParameterFieldType.CLOSED_LIST)
|
||||
|| currentParam.getFieldType().equals(EParameterFieldType.CHECK) || currentParam.getFieldType().equals(
|
||||
EParameterFieldType.AS400_CHECK))) {
|
||||
|| currentParam.getFieldType().equals(EParameterFieldType.CHECK)
|
||||
|| currentParam.getFieldType().equals(EParameterFieldType.AS400_CHECK) || currentParam.getFieldType()
|
||||
.equals(EParameterFieldType.COMPONENT_LIST))) {
|
||||
toUpdate = false;
|
||||
for (int i = 0; i < elem.getElementParameters().size(); i++) {
|
||||
IElementParameter testedParam = elem.getElementParameters().get(i);
|
||||
|
||||
String showIf = testedParam.getShowIf();
|
||||
String notShowIf = testedParam.getNotShowIf();
|
||||
|
||||
if (showIf != null) {
|
||||
if (showIf.contains(currentParam.getName())) {
|
||||
toUpdate = true;
|
||||
}
|
||||
} else {
|
||||
if (notShowIf != null) {
|
||||
if (notShowIf.contains(currentParam.getName())) {
|
||||
toUpdate = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (testedParam.getFieldType() == EParameterFieldType.TABLE) {
|
||||
String[] tmpShowIfs = testedParam.getListItemsShowIf();
|
||||
if (tmpShowIfs != null) {
|
||||
for (String show : tmpShowIfs) {
|
||||
if (show != null && show.contains(currentParam.getName())) {
|
||||
toUpdate = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
tmpShowIfs = testedParam.getListItemsNotShowIf();
|
||||
if (tmpShowIfs != null) {
|
||||
for (String show : tmpShowIfs) {
|
||||
if (show != null && show.contains(currentParam.getName())) {
|
||||
toUpdate = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (currentParam.getFieldType().equals(EParameterFieldType.CLOSED_LIST)) {
|
||||
/*
|
||||
* TUP-968, In order to refresh for missing modules top messages.
|
||||
*/
|
||||
if (EParameterName.DB_VERSION.getName().equals(currentParam.getName())
|
||||
|| "HBASE_VERSION".equals(currentParam.getName()) //$NON-NLS-1$
|
||||
|| "HIVE_VERSION".equals(currentParam.getName()) //$NON-NLS-1$
|
||||
|| "HCAT_VERSION".equals(currentParam.getName()) //$NON-NLS-1$
|
||||
|| "DISTRIBUTION".equals(currentParam.getName())) {//$NON-NLS-1$
|
||||
toUpdate = true;
|
||||
} else if (testedParam.getListItemsShowIf() != null) {
|
||||
for (int j = 0; j < testedParam.getListItemsShowIf().length && !toUpdate; j++) {
|
||||
showIf = testedParam.getListItemsShowIf()[j];
|
||||
notShowIf = testedParam.getListItemsNotShowIf()[j];
|
||||
if (showIf != null) {
|
||||
if (showIf.contains(currentParam.getName())) {
|
||||
toUpdate = true;
|
||||
}
|
||||
} else {
|
||||
if (notShowIf != null) {
|
||||
if (notShowIf.contains(currentParam.getName())) {
|
||||
toUpdate = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
setDefaultValues(currentParam, testedParam);
|
||||
}
|
||||
setDefaultValues(currentParam, elem);
|
||||
}
|
||||
|
||||
if (currentParam.getName().equals(EParameterName.PROCESS_TYPE_PROCESS.getName())) {
|
||||
@@ -421,6 +400,7 @@ public class PropertyChangeCommand extends Command {
|
||||
}
|
||||
}
|
||||
}
|
||||
updateRelativeNodesIfNeeded(currentParam);
|
||||
//
|
||||
if (elem instanceof IGraphicalNode) {
|
||||
((IGraphicalNode) elem).checkAndRefreshNode();
|
||||
@@ -433,6 +413,103 @@ public class PropertyChangeCommand extends Command {
|
||||
refreshMR(propName);
|
||||
}
|
||||
|
||||
/**
|
||||
* DOC cmeng Comment method "updateRelativeNodesIfNeeded".
|
||||
*
|
||||
* @param currentParam
|
||||
*/
|
||||
private void updateRelativeNodesIfNeeded(IElementParameter currentParam) {
|
||||
boolean originalUpdateValue = toUpdate;
|
||||
List<INode> relativeNodes = getRelativeNodes(elem.getElementParameters());
|
||||
if (relativeNodes != null && 0 < relativeNodes.size()) {
|
||||
for (INode node : relativeNodes) {
|
||||
toUpdate = false;
|
||||
setDefaultValues(currentParam, node);
|
||||
if (toUpdate) {
|
||||
node.setPropertyValue(updataComponentParamName, new Boolean(true));
|
||||
}
|
||||
}
|
||||
}
|
||||
toUpdate = originalUpdateValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* DOC cmeng Comment method "setDefaultValues".
|
||||
*
|
||||
* @param currentParam
|
||||
*/
|
||||
private void setDefaultValues(IElementParameter currentParam, IElement node) {
|
||||
List<? extends IElementParameter> elementParameters = node.getElementParameters();
|
||||
if (elementParameters == null) {
|
||||
return;
|
||||
}
|
||||
for (int i = 0; i < elementParameters.size(); i++) {
|
||||
IElementParameter testedParam = elementParameters.get(i);
|
||||
|
||||
String showIf = testedParam.getShowIf();
|
||||
String notShowIf = testedParam.getNotShowIf();
|
||||
|
||||
if (showIf != null) {
|
||||
if (showIf.contains(currentParam.getName())) {
|
||||
toUpdate = true;
|
||||
}
|
||||
} else {
|
||||
if (notShowIf != null) {
|
||||
if (notShowIf.contains(currentParam.getName())) {
|
||||
toUpdate = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (testedParam.getFieldType() == EParameterFieldType.TABLE) {
|
||||
String[] tmpShowIfs = testedParam.getListItemsShowIf();
|
||||
if (tmpShowIfs != null) {
|
||||
for (String show : tmpShowIfs) {
|
||||
if (show != null && show.contains(currentParam.getName())) {
|
||||
toUpdate = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
tmpShowIfs = testedParam.getListItemsNotShowIf();
|
||||
if (tmpShowIfs != null) {
|
||||
for (String show : tmpShowIfs) {
|
||||
if (show != null && show.contains(currentParam.getName())) {
|
||||
toUpdate = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (currentParam.getFieldType().equals(EParameterFieldType.CLOSED_LIST)) {
|
||||
/*
|
||||
* TUP-968, In order to refresh for missing modules top messages.
|
||||
*/
|
||||
if (EParameterName.DB_VERSION.getName().equals(currentParam.getName())
|
||||
|| "HBASE_VERSION".equals(currentParam.getName()) //$NON-NLS-1$
|
||||
|| "HIVE_VERSION".equals(currentParam.getName()) //$NON-NLS-1$
|
||||
|| "HCAT_VERSION".equals(currentParam.getName()) //$NON-NLS-1$
|
||||
|| "DISTRIBUTION".equals(currentParam.getName())) {//$NON-NLS-1$
|
||||
toUpdate = true;
|
||||
} else if (testedParam.getListItemsShowIf() != null) {
|
||||
for (int j = 0; j < testedParam.getListItemsShowIf().length && !toUpdate; j++) {
|
||||
showIf = testedParam.getListItemsShowIf()[j];
|
||||
notShowIf = testedParam.getListItemsNotShowIf()[j];
|
||||
if (showIf != null) {
|
||||
if (showIf.contains(currentParam.getName())) {
|
||||
toUpdate = true;
|
||||
}
|
||||
} else {
|
||||
if (notShowIf != null) {
|
||||
if (notShowIf.contains(currentParam.getName())) {
|
||||
toUpdate = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
setDefaultValues(currentParam, testedParam, node);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean needUpdateMonitorConnection() {
|
||||
|
||||
if (elem instanceof Connection) {
|
||||
@@ -465,7 +542,11 @@ public class PropertyChangeCommand extends Command {
|
||||
* @param testedParam Tested parameter, to know if there is a link for the default values between this parameter and
|
||||
* the current.
|
||||
*/
|
||||
private void setDefaultValues(IElementParameter currentParam, IElementParameter testedParam) {
|
||||
private void setDefaultValues(IElementParameter currentParam, IElementParameter testedParam, IElement referenceNode) {
|
||||
List<? extends IElementParameter> elementParameters = referenceNode.getElementParameters();
|
||||
if (elementParameters == null) {
|
||||
return;
|
||||
}
|
||||
boolean contains = false;
|
||||
|
||||
// zli
|
||||
@@ -495,13 +576,13 @@ public class PropertyChangeCommand extends Command {
|
||||
if (testedParam.getListItemsShowIf() != null) {
|
||||
String conditionShowIf = testedParam.getListItemsShowIf()[index];
|
||||
if (conditionShowIf != null) {
|
||||
isCurrentComboValid = Expression.evaluate(conditionShowIf, elem.getElementParameters());
|
||||
isCurrentComboValid = Expression.evaluate(conditionShowIf, elementParameters);
|
||||
}
|
||||
}
|
||||
if (testedParam.getListItemsNotShowIf() != null) {
|
||||
String conditionNotShowIf = testedParam.getListItemsNotShowIf()[index];
|
||||
if (conditionNotShowIf != null) {
|
||||
isCurrentComboValid = !Expression.evaluate(conditionNotShowIf, elem.getElementParameters());
|
||||
isCurrentComboValid = !Expression.evaluate(conditionNotShowIf, elementParameters);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -509,7 +590,7 @@ public class PropertyChangeCommand extends Command {
|
||||
if (!isCurrentComboValid && testedParam.getListItemsShowIf() != null) {
|
||||
for (String condition : testedParam.getListItemsShowIf()) {
|
||||
if (condition != null && condition.contains(currentParam.getName())) {
|
||||
boolean isValid = Expression.evaluate(condition, elem.getElementParameters());
|
||||
boolean isValid = Expression.evaluate(condition, elementParameters);
|
||||
if (isValid) {
|
||||
int index = ArrayUtils.indexOf(testedParam.getListItemsShowIf(), condition);
|
||||
testedParam.setValue(testedParam.getListItemsValue()[index]);
|
||||
@@ -521,7 +602,7 @@ public class PropertyChangeCommand extends Command {
|
||||
if (!isCurrentComboValid && !contains && testedParam.getListItemsNotShowIf() != null) {
|
||||
for (String condition : testedParam.getListItemsNotShowIf()) {
|
||||
if (condition != null && condition.contains(currentParam.getName())) {
|
||||
boolean isValid = !Expression.evaluate(condition, elem.getElementParameters());
|
||||
boolean isValid = !Expression.evaluate(condition, elementParameters);
|
||||
if (isValid) {
|
||||
int index = ArrayUtils.indexOf(testedParam.getListItemsNotShowIf(), condition);
|
||||
testedParam.setValue(testedParam.getListItemsValue()[index]);
|
||||
@@ -542,11 +623,11 @@ public class PropertyChangeCommand extends Command {
|
||||
&& !testedParam.getFieldType().equals(EParameterFieldType.RADIO)) {
|
||||
oldMapping = (String) testedParam.getValue();
|
||||
}
|
||||
testedParam.setValueToDefault(elem.getElementParameters());
|
||||
testedParam.setValueToDefault(elementParameters);
|
||||
if (testedParam.getFieldType().equals(EParameterFieldType.MAPPING_TYPE)) {
|
||||
String newMapping = (String) testedParam.getValue();
|
||||
if (!oldMapping.equals(newMapping)) {
|
||||
Node node = (Node) elem;
|
||||
Node node = (Node) referenceNode;
|
||||
if (node.getMetadataList().size() > 0) {
|
||||
// to change with:
|
||||
// IMetadataTable metadataTable = node.getMetadataFromConnector(testedParam.getContext());
|
||||
@@ -557,7 +638,7 @@ public class PropertyChangeCommand extends Command {
|
||||
}
|
||||
} else {
|
||||
// See issue 975, update the schema.
|
||||
Node node = (Node) elem;
|
||||
Node node = (Node) referenceNode;
|
||||
if (node.getMetadataList().size() > 0) {
|
||||
IMetadataTable metadataTable = null;
|
||||
IMetadataTable newMetadataTable = null;
|
||||
@@ -629,7 +710,9 @@ public class PropertyChangeCommand extends Command {
|
||||
newMetadataTable = metadataTable;
|
||||
}
|
||||
|
||||
changeMetadataCommand = new ChangeMetadataCommand(node, null, null, newMetadataTable);
|
||||
ChangeMetadataCommand changeMetadataCommand = new ChangeMetadataCommand(node, null, null,
|
||||
newMetadataTable);
|
||||
changeMetadataCommands.add(changeMetadataCommand);
|
||||
changeMetadataCommand.execute(true);
|
||||
}
|
||||
}
|
||||
@@ -670,8 +753,12 @@ public class PropertyChangeCommand extends Command {
|
||||
if (toUpdate) {
|
||||
elem.setPropertyValue(updataComponentParamName, new Boolean(true));
|
||||
}
|
||||
if (changeMetadataCommand != null) {
|
||||
changeMetadataCommand.undo();
|
||||
if (changeMetadataCommands != null) {
|
||||
int size = changeMetadataCommands.size();
|
||||
for (int i = size - 1; 0 <= i; i--) {
|
||||
ChangeMetadataCommand changeMetadataCommand = changeMetadataCommands.get(i);
|
||||
changeMetadataCommand.undo();
|
||||
}
|
||||
}
|
||||
CodeView.refreshCodeView(elem);
|
||||
ComponentSettings.switchToCurComponentSettingsView();
|
||||
@@ -726,8 +813,10 @@ public class PropertyChangeCommand extends Command {
|
||||
elem.setPropertyValue(updataComponentParamName, new Boolean(true));
|
||||
}
|
||||
|
||||
if (changeMetadataCommand != null) {
|
||||
changeMetadataCommand.redo();
|
||||
if (changeMetadataCommands != null) {
|
||||
for (ChangeMetadataCommand changeMetadataCommand : changeMetadataCommands) {
|
||||
changeMetadataCommand.redo();
|
||||
}
|
||||
}
|
||||
CodeView.refreshCodeView(elem);
|
||||
ComponentSettings.switchToCurComponentSettingsView();
|
||||
|
||||
@@ -528,7 +528,7 @@ public class JobletContainer extends NodeContainer {
|
||||
if (isCollapsed()) {
|
||||
((Connection) conn).reconnect(conn.getSource(), this.node, conn.getLineStyle());
|
||||
} else {
|
||||
for (NodeContainer nodeContainer : this.nodeContainers) {
|
||||
out: for (NodeContainer nodeContainer : this.nodeContainers) {
|
||||
Node connNode = nodeContainer.getNode();
|
||||
IElementParameter elePa = this.node.getElementParameter(connNode.getJoblet_unique_name());
|
||||
|
||||
@@ -565,6 +565,11 @@ public class JobletContainer extends NodeContainer {
|
||||
break;
|
||||
} else if (getFlowInput(inputs).size() == 1 && !isTri
|
||||
&& new JobletUtil().isJobletInput(connNode, this.getProcess())) {
|
||||
for (IConnection flowConn : getFlowInput(inputs)) {
|
||||
if (!flowConn.getUniqueName().equals(conn.getUniqueName())) {
|
||||
continue out;
|
||||
}
|
||||
}
|
||||
JobletConnectionReconnectCommand reConnectCommand = new JobletConnectionReconnectCommand(conn);
|
||||
reConnectCommand.setNewTarget(connNode);
|
||||
reConnectCommand.execute();
|
||||
@@ -674,6 +679,7 @@ public class JobletContainer extends NodeContainer {
|
||||
public boolean canCollapse() {
|
||||
List<String> connList = new ArrayList<String>();
|
||||
List<String> metaList = new ArrayList<String>();
|
||||
List<String> triConnList = new ArrayList<String>();
|
||||
if (node.getIncomingConnections().size() > 1) {
|
||||
for (IConnection conn : node.getIncomingConnections()) {
|
||||
if (conn.getConnectorName().startsWith("TRIGGER")) {
|
||||
@@ -693,6 +699,15 @@ public class JobletContainer extends NodeContainer {
|
||||
if (isTri) {
|
||||
IElementParameter elechild = elePa.getChildParameters().get("COMPONENT_LIST");
|
||||
if (elechild != null) {
|
||||
if (elechild.getValue() == null || ((String) elechild.getValue()).length() <= 0) {
|
||||
return false;
|
||||
} else {
|
||||
if (triConnList.contains(elechild.getValue())) {
|
||||
return false;
|
||||
} else {
|
||||
triConnList.add((String) elechild.getValue());
|
||||
}
|
||||
}
|
||||
if (elechild.getValue() != null && (elechild.getValue() instanceof String)) {
|
||||
metaList.remove(elechild.getValue());
|
||||
}
|
||||
|
||||
@@ -3391,7 +3391,7 @@ public class Node extends Element implements IGraphicalNode {
|
||||
"Node.differentFromSchemaDefined", inputConnecion.getName()); //$NON-NLS-1$
|
||||
Problems.add(ProblemStatus.ERROR, this, errorMessage);
|
||||
}
|
||||
} else if (connector.getMaxLinkInput() != 0 && connector.getMaxLinkOutput() == 0) {
|
||||
} else if (connector != null && connector.getMaxLinkInput() != 0 && connector.getMaxLinkOutput() == 0) {
|
||||
if (!outputMeta.sameMetadataAs(inputMeta, IMetadataColumn.OPTIONS_NONE)) {
|
||||
schemaSynchronized = false;
|
||||
String errorMessage = Messages.getString(
|
||||
|
||||
@@ -152,6 +152,7 @@ import org.talend.designer.core.ui.editor.nodecontainer.NodeContainer;
|
||||
import org.talend.designer.core.ui.editor.nodes.Node;
|
||||
import org.talend.designer.core.ui.editor.notes.Note;
|
||||
import org.talend.designer.core.ui.editor.properties.controllers.ColumnListController;
|
||||
import org.talend.designer.core.ui.editor.properties.controllers.ComponentListController;
|
||||
import org.talend.designer.core.ui.editor.properties.controllers.ConnectionListController;
|
||||
import org.talend.designer.core.ui.editor.subjobcontainer.SubjobContainer;
|
||||
import org.talend.designer.core.ui.preferences.TalendDesignerPrefConstants;
|
||||
@@ -1084,6 +1085,22 @@ public class Process extends Element implements IProcess2, IGEFProcess, ILastVer
|
||||
listParamType.add(pType);
|
||||
}
|
||||
|
||||
private void initJobletComponents() {
|
||||
for (INode node : nodes) {
|
||||
if ((node instanceof Node) && ((Node) node).isJoblet()) {
|
||||
List<? extends IElementParameter> parametersWithChildrens = node.getElementParametersWithChildrens();
|
||||
for (IElementParameter param : parametersWithChildrens) {
|
||||
if (param.getFieldType() == EParameterFieldType.COMPONENT_LIST) {
|
||||
if (param.getValue() == null || ((String) param.getValue()).length() <= 0) {
|
||||
ComponentListController.updateComponentList(node, param);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private void loadElementParameters(Element elemParam, EList listParamType) {
|
||||
boolean flag = false;
|
||||
@@ -1750,6 +1767,7 @@ public class Process extends Element implements IProcess2, IGEFProcess, ILastVer
|
||||
loadSubjobs(processType);
|
||||
|
||||
initExternalComponents();
|
||||
initJobletComponents();
|
||||
setActivate(true);
|
||||
checkStartNodes();
|
||||
// (bug 5365)
|
||||
|
||||
@@ -1301,7 +1301,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);
|
||||
|
||||
@@ -648,9 +648,19 @@ public class TableController extends AbstractElementPropertySectionController {
|
||||
}
|
||||
|
||||
contextParameterNames = contextParameterNamesList.toArray(new String[0]);
|
||||
} else {
|
||||
contextParameterNames = new String[0];
|
||||
}
|
||||
|
||||
if (contextParameterNames == null || contextParameterNames.length == 0) {
|
||||
contextParameterNamesList.clear();
|
||||
// in case the job is opened but childjob are missing, or if there is a problem when retrieve the child job
|
||||
// we rerebuild the list here from what was saved in the job before
|
||||
for (HashMap<String, Object> values : (List<HashMap<String, Object>>) param.getValue()) {
|
||||
String name = (String) values.get("PARAM_NAME_COLUMN"); //$NON-NLS-1$
|
||||
contextParameterNamesList.add(name);
|
||||
}
|
||||
contextParameterNames = contextParameterNamesList.toArray(new String[0]);
|
||||
}
|
||||
|
||||
// update table values
|
||||
TableViewerCreator tableViewerCreator = (TableViewerCreator) hashCurControls.get(param.getName());
|
||||
Object[] itemsValue = param.getListItemsValue();
|
||||
@@ -694,7 +704,7 @@ public class TableController extends AbstractElementPropertySectionController {
|
||||
} else {
|
||||
if (o instanceof String) {
|
||||
Integer nb = new Integer(tmpParam.getIndexOfItemFromList((String) o));
|
||||
if (nb == -1) {
|
||||
if (nb == -1 && !"".equals(tmpParam.getDefaultClosedListValue())) { //$NON-NLS-1$
|
||||
currentLine.put(items[j], tmpParam.getDefaultClosedListValue());
|
||||
}
|
||||
}
|
||||
@@ -706,18 +716,6 @@ public class TableController extends AbstractElementPropertySectionController {
|
||||
}
|
||||
// (bug 3740)
|
||||
boolean checked = contextParameterNames != null && contextParameterNames.length > 0;
|
||||
if (!checked) {
|
||||
Object value = param.getValue();
|
||||
if (value != null && value instanceof List) {
|
||||
if (!((List) value).isEmpty()) {
|
||||
((List) value).clear();
|
||||
if (part != null && part.getTalendEditor() != null) {
|
||||
part.getTalendEditor().setDirty(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
revertToolBarButtonState(checked);
|
||||
|
||||
}
|
||||
|
||||
@@ -22,6 +22,8 @@ import org.apache.commons.lang.ArrayUtils;
|
||||
import org.eclipse.emf.common.util.EList;
|
||||
import org.eclipse.ui.IEditorReference;
|
||||
import org.eclipse.ui.PlatformUI;
|
||||
import org.talend.commons.exception.ExceptionHandler;
|
||||
import org.talend.commons.utils.PasswordEncryptUtil;
|
||||
import org.talend.commons.utils.VersionUtils;
|
||||
import org.talend.core.CorePlugin;
|
||||
import org.talend.core.context.Context;
|
||||
@@ -240,12 +242,26 @@ public class ElementParameter2ParameterType {
|
||||
}
|
||||
}
|
||||
}
|
||||
IElementParameter tmpParam = null;
|
||||
for (Object o : param.getListItemsValue()) {
|
||||
if (o instanceof IElementParameter) {
|
||||
IElementParameter tableParam = (IElementParameter) o;
|
||||
if (tableParam.getName().equals(elementValue.getElementRef())) {
|
||||
tmpParam = tableParam;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (found) {
|
||||
if ((lineValues == null) || (lineValues.get(elementValue.getElementRef()) != null)) {
|
||||
lineValues = new HashMap<String, Object>();
|
||||
tableValues.add(lineValues);
|
||||
}
|
||||
lineValues.put(elementValue.getElementRef(), elementValue.getValue());
|
||||
String elemValue = elementValue.getValue();
|
||||
if (tmpParam != null && EParameterFieldType.PASSWORD.equals(tmpParam.getFieldType())) {
|
||||
elemValue = getRawValue(elemValue, tmpParam.getFieldType());
|
||||
}
|
||||
lineValues.put(elementValue.getElementRef(), elemValue);
|
||||
if (elementValue.getType() != null) {
|
||||
lineValues.put(elementValue.getElementRef() + IEbcdicConstant.REF_TYPE,
|
||||
elementValue.getType());
|
||||
@@ -253,6 +269,8 @@ public class ElementParameter2ParameterType {
|
||||
}
|
||||
}
|
||||
elemParam.setPropertyValue(pTypeName, tableValues);
|
||||
} else if (param.getFieldType().equals(EParameterFieldType.PASSWORD)) {
|
||||
param.setValue(getRawValue(pType.getValue(), param.getFieldType()));
|
||||
} else if (param.getFieldType().equals(EParameterFieldType.ENCODING_TYPE)) {
|
||||
// fix for bug 2193
|
||||
boolean setToCustom = false;
|
||||
@@ -516,4 +534,22 @@ public class ElementParameter2ParameterType {
|
||||
}
|
||||
}
|
||||
|
||||
private static String getRawValue(String value, EParameterFieldType fileType) {
|
||||
if (value != null && value.length() > 0 && fileType.equals(EParameterFieldType.PASSWORD)) {
|
||||
|
||||
try {
|
||||
int ind = value.lastIndexOf(PasswordEncryptUtil.ENCRYPT_KEY);
|
||||
if (ind != -1) {
|
||||
String encryptedPart = new StringBuilder(value).replace(ind, ind + PasswordEncryptUtil.ENCRYPT_KEY.length(),
|
||||
"").toString(); //$NON-NLS-1$
|
||||
String decryptedValue = PasswordEncryptUtil.decryptPassword(encryptedPart);
|
||||
return decryptedValue;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
#Fri Feb 05 11:38:53 CST 2010
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
|
||||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
||||
org.eclipse.jdt.core.compiler.compliance=1.5
|
||||
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
|
||||
org.eclipse.jdt.core.compiler.debug.localVariable=generate
|
||||
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
|
||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.source=1.5
|
||||
@@ -1,28 +1,32 @@
|
||||
Manifest-Version: 1.0
|
||||
Bundle-ManifestVersion: 2
|
||||
Bundle-Name: Hl7 Plug-in
|
||||
Bundle-SymbolicName: org.talend.designer.hl7;singleton:=true
|
||||
Bundle-Version: 1.0.0.qualifier
|
||||
Require-Bundle: org.eclipse.ui.workbench,
|
||||
org.talend.model,
|
||||
org.eclipse.core.runtime,
|
||||
org.talend.core.runtime,
|
||||
org.talend.commons.ui,
|
||||
org.talend.metadata.managment,
|
||||
org.talend.metadata.managment.ui,
|
||||
org.talend.core,
|
||||
org.talend.core.ui,
|
||||
org.talend.repository,
|
||||
org.talend.designer.core,
|
||||
org.talend.designer.codegen,
|
||||
org.eclipse.jface,
|
||||
org.eclipse.gef,
|
||||
org.talend.libraries.hl7
|
||||
Bundle-ActivationPolicy: lazy
|
||||
Bundle-Vendor: .Talend SA.
|
||||
Bundle-ClassPath: .
|
||||
Export-Package: org.talend.designer.hl7,
|
||||
org.talend.designer.hl7.action,
|
||||
org.talend.designer.hl7.ui.data,
|
||||
org.talend.designer.hl7.ui.edit,
|
||||
org.talend.designer.hl7.ui.form
|
||||
Manifest-Version: 1.0
|
||||
Bundle-ManifestVersion: 2
|
||||
Bundle-Name: Hl7 Plug-in
|
||||
Bundle-SymbolicName: org.talend.designer.hl7;singleton:=true
|
||||
Bundle-Version: 1.0.0.qualifier
|
||||
Require-Bundle: org.eclipse.ui.workbench,
|
||||
org.talend.model,
|
||||
org.eclipse.core.runtime,
|
||||
org.talend.core.runtime,
|
||||
org.talend.commons.ui,
|
||||
org.talend.metadata.managment,
|
||||
org.talend.metadata.managment.ui,
|
||||
org.talend.core,
|
||||
org.talend.core.ui,
|
||||
org.talend.repository,
|
||||
org.talend.designer.core,
|
||||
org.talend.designer.codegen,
|
||||
org.eclipse.jface,
|
||||
org.eclipse.gef,
|
||||
org.talend.libraries.hl7
|
||||
Bundle-ActivationPolicy: lazy
|
||||
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.header,
|
||||
org.talend.designer.hl7.util
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
#Created by JInto - www.guh-software.de
|
||||
FooterComposite.0=Ok
|
||||
FooterComposite.1=Cancel
|
||||
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.
|
||||
#Created by JInto - www.guh-software.de
|
||||
FooterComposite.0=Ok
|
||||
FooterComposite.1=Cancel
|
||||
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,146 +0,0 @@
|
||||
// ============================================================================
|
||||
//
|
||||
// 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.dialogs.InputDialog;
|
||||
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.repository.ui.swt.utils.AbstractForm;
|
||||
|
||||
/**
|
||||
* bqian Create a xml node. <br/>
|
||||
*
|
||||
* $Id: CreateAttributeAction.java,v 1.1 2007/06/12 07:20:38 gke Exp $
|
||||
*
|
||||
*/
|
||||
public class CreateHL7AttributeAction extends SelectionProviderAction {
|
||||
|
||||
// the xml viewer, see HL7UI.
|
||||
private TreeViewer xmlViewer;
|
||||
|
||||
private HL7UI hl7ui;
|
||||
|
||||
private AbstractForm from;
|
||||
|
||||
/**
|
||||
* CreateNode constructor comment.
|
||||
*
|
||||
* @param provider
|
||||
* @param text
|
||||
*/
|
||||
public CreateHL7AttributeAction(TreeViewer xmlViewer, String text) {
|
||||
super(xmlViewer, text);
|
||||
this.xmlViewer = xmlViewer;
|
||||
}
|
||||
|
||||
public CreateHL7AttributeAction(TreeViewer xmlViewer, String text, AbstractForm from) {
|
||||
super(xmlViewer, text);
|
||||
this.xmlViewer = xmlViewer;
|
||||
this.from = from;
|
||||
}
|
||||
|
||||
public CreateHL7AttributeAction(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 Element) {
|
||||
if (((Element) node).getAttributeChildren().size() > 0) {
|
||||
this.setEnabled(false);
|
||||
return;
|
||||
}
|
||||
|
||||
String nodeName = node.getLabel() + "-";
|
||||
List<HL7TreeNode> childs = ((Element) node).getElementChildren();
|
||||
if (childs.size() > 0) {
|
||||
for (HL7TreeNode child : childs) {
|
||||
if (!child.getLabel().startsWith(nodeName)) {
|
||||
this.setEnabled(false);
|
||||
return;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
this.setEnabled(false);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (node.getClass() != Element.class) {
|
||||
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 != null) {
|
||||
createChildNode(node);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the child node of the input node
|
||||
*
|
||||
* @param node
|
||||
*/
|
||||
private void createChildNode(HL7TreeNode node) {
|
||||
String label = ""; //$NON-NLS-1$
|
||||
while (!StringUtil.validateLabelForXML(label)) {
|
||||
InputDialog dialog = new InputDialog(null, "Input attribute's label", "Input the new attribute's valid label", "",
|
||||
null);
|
||||
int status = dialog.open();
|
||||
if (status == InputDialog.OK) {
|
||||
label = dialog.getValue().trim();
|
||||
}
|
||||
if (status == InputDialog.CANCEL) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
HL7TreeNode child = new Attribute(label);
|
||||
child.setRow(node.getRow());
|
||||
node.addChild(child);
|
||||
this.xmlViewer.refresh();
|
||||
xmlViewer.expandAll();
|
||||
if (hl7ui != null) {
|
||||
hl7ui.redrawLinkers();
|
||||
} else if (from != null) {
|
||||
from.refreshLinks();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,179 +1,209 @@
|
||||
// ============================================================================
|
||||
//
|
||||
// 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.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.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(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) {
|
||||
child.setRow(((HL7OutputManager) hl7ui.gethl7Manager()).getCurrentSchema(false));
|
||||
}
|
||||
} else {
|
||||
child.setRow(node.getRow());
|
||||
}
|
||||
|
||||
node.addChild(child);
|
||||
this.xmlViewer.refresh();
|
||||
this.xmlViewer.expandAll();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
// ============================================================================
|
||||
//
|
||||
// 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();
|
||||
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() {
|
||||
|
||||
@Override
|
||||
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-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.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,453 +1,437 @@
|
||||
// ============================================================================
|
||||
//
|
||||
// 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.process.INode;
|
||||
import org.talend.core.model.utils.NodeUtil;
|
||||
import org.talend.core.runtime.CoreRuntimePlugin;
|
||||
import org.talend.core.ui.metadata.command.RepositoryChangeMetadataForHL7Command;
|
||||
import org.talend.designer.hl7.managers.HL7OutputManager;
|
||||
import org.talend.designer.hl7.ui.HL7UI;
|
||||
import org.talend.designer.hl7.ui.data.Attribute;
|
||||
import org.talend.designer.hl7.ui.data.Element;
|
||||
import org.talend.designer.hl7.ui.data.HL7TreeNode;
|
||||
import org.talend.designer.hl7.ui.data.NameSpaceNode;
|
||||
import org.talend.designer.hl7.ui.form.AbstractHL7StepForm;
|
||||
import org.talend.designer.hl7.ui.header.HL7Parse;
|
||||
import org.talend.designer.hl7.util.HL7PublicUtil;
|
||||
import org.talend.repository.model.IProxyRepositoryFactory;
|
||||
|
||||
import ca.uhn.hl7v2.model.Message;
|
||||
|
||||
/**
|
||||
* 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> 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, 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<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>();
|
||||
INode targetNode = null;
|
||||
HL7TreeNode rootNode = null;
|
||||
for (String rowName : schemaList) {
|
||||
IMetadataTable metadataTable = null;
|
||||
for (IConnection connection : incomingConnections) {
|
||||
if (connection.getUniqueName().equals(rowName)) {
|
||||
metadataTable = connection.getMetadataTable();
|
||||
metadataTable.setLabel(connection.getUniqueName());
|
||||
}
|
||||
targetNode = connection.getTarget();
|
||||
}
|
||||
|
||||
MetadataTable targetMetadataTable = ConnectionFactory.eINSTANCE.createMetadataTable();
|
||||
targetMetadataTable.setId(factory.getNextId());
|
||||
targetMetadataTable.setLabel(rowName);
|
||||
iMetadataTables.add(targetMetadataTable);
|
||||
List<MetadataColumn> columns = new ArrayList<MetadataColumn>();
|
||||
|
||||
HL7TreeNode current = null;
|
||||
HL7TreeNode temp = null;
|
||||
HL7TreeNode mainNode = null;
|
||||
String mainPath = null;
|
||||
String currentPath = null;
|
||||
String defaultValue = null;
|
||||
int nodeOrder = 0;
|
||||
boolean haveOrder = true;
|
||||
String schemaId = rowName + ":";//((MetadataTable) obj).getLabel() + ":"; //$NON-NLS-1$
|
||||
// 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, mapNodes);
|
||||
// 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.setRow(rowName);
|
||||
}
|
||||
|
||||
if (columnName != null && columnName.length() > 0 && columnName.startsWith(schemaId)) {
|
||||
columnName = columnName.replace(schemaId, ""); //$NON-NLS-1$
|
||||
// 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;
|
||||
}
|
||||
}
|
||||
if (metadataTableTemp != null) {
|
||||
temp.setColumnName(columnName);
|
||||
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");
|
||||
columns.add(newColumn);
|
||||
}
|
||||
}
|
||||
}
|
||||
targetMetadataTable.getColumns().addAll(columns);
|
||||
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);
|
||||
}
|
||||
}
|
||||
// execute the commands,initialize the propertiesView .
|
||||
List<Command> commands = new ArrayList<Command>();
|
||||
for (MetadataTable tableTemp : iMetadataTables) {
|
||||
if (targetNode != null) {
|
||||
Command hl7Cmd = new RepositoryChangeMetadataForHL7Command(targetNode.getExternalNode(),
|
||||
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());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
// ============================================================================
|
||||
//
|
||||
// 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-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.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();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,209 +0,0 @@
|
||||
package org.talend.designer.hl7.edit;
|
||||
|
||||
// ============================================================================
|
||||
//
|
||||
// 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
|
||||
//
|
||||
// ============================================================================
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.dnd.ByteArrayTransfer;
|
||||
import org.eclipse.swt.dnd.DND;
|
||||
import org.eclipse.swt.dnd.DragSource;
|
||||
import org.eclipse.swt.dnd.DragSourceAdapter;
|
||||
import org.eclipse.swt.dnd.DragSourceEvent;
|
||||
import org.eclipse.swt.dnd.DropTarget;
|
||||
import org.eclipse.swt.dnd.DropTargetAdapter;
|
||||
import org.eclipse.swt.dnd.DropTargetEvent;
|
||||
import org.eclipse.swt.dnd.Transfer;
|
||||
import org.eclipse.swt.dnd.TransferData;
|
||||
import org.eclipse.swt.layout.FillLayout;
|
||||
import org.eclipse.swt.widgets.Display;
|
||||
import org.eclipse.swt.widgets.Label;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
|
||||
public class Snippet79 {
|
||||
|
||||
/*
|
||||
* The data being transferred is an <bold>array of type MyType</bold> where MyType is define as:
|
||||
*/
|
||||
static class MyType {
|
||||
|
||||
String fileName;
|
||||
|
||||
long fileLength;
|
||||
|
||||
long lastModified;
|
||||
}
|
||||
|
||||
static class MyTransfer extends ByteArrayTransfer {
|
||||
|
||||
private static final String MYTYPENAME = "name_for_my_type";
|
||||
|
||||
private static final int MYTYPEID = registerType(MYTYPENAME);
|
||||
|
||||
private static MyTransfer _instance = new MyTransfer();
|
||||
|
||||
public static MyTransfer getInstance() {
|
||||
return _instance;
|
||||
}
|
||||
|
||||
public void javaToNative(Object object, TransferData transferData) {
|
||||
if (!checkMyType(object) || !isSupportedType(transferData)) {
|
||||
DND.error(DND.ERROR_INVALID_DATA);
|
||||
}
|
||||
MyType[] myTypes = (MyType[]) object;
|
||||
try {
|
||||
// write data to a byte array and then ask super to convert to
|
||||
// pMedium
|
||||
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||
DataOutputStream writeOut = new DataOutputStream(out);
|
||||
for (int i = 0, length = myTypes.length; i < length; i++) {
|
||||
byte[] buffer = myTypes[i].fileName.getBytes();
|
||||
writeOut.writeInt(buffer.length);
|
||||
writeOut.write(buffer);
|
||||
writeOut.writeLong(myTypes[i].fileLength);
|
||||
writeOut.writeLong(myTypes[i].lastModified);
|
||||
}
|
||||
byte[] buffer = out.toByteArray();
|
||||
writeOut.close();
|
||||
super.javaToNative(buffer, transferData);
|
||||
} catch (IOException e) {
|
||||
}
|
||||
}
|
||||
|
||||
public Object nativeToJava(TransferData transferData) {
|
||||
if (isSupportedType(transferData)) {
|
||||
byte[] buffer = (byte[]) super.nativeToJava(transferData);
|
||||
if (buffer == null)
|
||||
return null;
|
||||
|
||||
MyType[] myData = new MyType[0];
|
||||
try {
|
||||
ByteArrayInputStream in = new ByteArrayInputStream(buffer);
|
||||
DataInputStream readIn = new DataInputStream(in);
|
||||
while (readIn.available() > 20) {
|
||||
MyType datum = new MyType();
|
||||
int size = readIn.readInt();
|
||||
byte[] name = new byte[size];
|
||||
readIn.read(name);
|
||||
datum.fileName = new String(name);
|
||||
datum.fileLength = readIn.readLong();
|
||||
datum.lastModified = readIn.readLong();
|
||||
MyType[] newMyData = new MyType[myData.length + 1];
|
||||
System.arraycopy(myData, 0, newMyData, 0, myData.length);
|
||||
newMyData[myData.length] = datum;
|
||||
myData = newMyData;
|
||||
}
|
||||
readIn.close();
|
||||
} catch (IOException ex) {
|
||||
return null;
|
||||
}
|
||||
return myData;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
protected String[] getTypeNames() {
|
||||
return new String[] { MYTYPENAME };
|
||||
}
|
||||
|
||||
protected int[] getTypeIds() {
|
||||
return new int[] { MYTYPEID };
|
||||
}
|
||||
|
||||
boolean checkMyType(Object object) {
|
||||
if (object == null || !(object instanceof MyType[]) || ((MyType[]) object).length == 0) {
|
||||
return false;
|
||||
}
|
||||
MyType[] myTypes = (MyType[]) object;
|
||||
for (int i = 0; i < myTypes.length; i++) {
|
||||
if (myTypes[i] == null || myTypes[i].fileName == null || myTypes[i].fileName.length() == 0) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
protected boolean validate(Object object) {
|
||||
return checkMyType(object);
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
Display display = new Display();
|
||||
Shell shell = new Shell(display);
|
||||
shell.setLayout(new FillLayout());
|
||||
final Label label1 = new Label(shell, SWT.BORDER | SWT.WRAP);
|
||||
label1.setText("Drag Source for MyData[]");
|
||||
final Label label2 = new Label(shell, SWT.BORDER | SWT.WRAP);
|
||||
label2.setText("Drop Target for MyData[]");
|
||||
|
||||
DragSource source = new DragSource(label1, DND.DROP_COPY);
|
||||
source.setTransfer(new Transfer[] { MyTransfer.getInstance() });
|
||||
source.addDragListener(new DragSourceAdapter() {
|
||||
|
||||
public void dragSetData(DragSourceEvent event) {
|
||||
MyType myType1 = new MyType();
|
||||
myType1.fileName = "C:\\abc.txt";
|
||||
myType1.fileLength = 1000;
|
||||
myType1.lastModified = 12312313;
|
||||
MyType myType2 = new MyType();
|
||||
myType2.fileName = "C:\\xyz.txt";
|
||||
myType2.fileLength = 500;
|
||||
myType2.lastModified = 12312323;
|
||||
event.data = new MyType[] { myType1, myType2 };
|
||||
}
|
||||
});
|
||||
DropTarget target = new DropTarget(label2, DND.DROP_COPY | DND.DROP_DEFAULT);
|
||||
target.setTransfer(new Transfer[] { MyTransfer.getInstance() });
|
||||
target.addDropListener(new DropTargetAdapter() {
|
||||
|
||||
public void dragEnter(DropTargetEvent event) {
|
||||
if (event.detail == DND.DROP_DEFAULT) {
|
||||
event.detail = DND.DROP_COPY;
|
||||
}
|
||||
}
|
||||
|
||||
public void dragOperationChanged(DropTargetEvent event) {
|
||||
if (event.detail == DND.DROP_DEFAULT) {
|
||||
event.detail = DND.DROP_COPY;
|
||||
}
|
||||
}
|
||||
|
||||
public void drop(DropTargetEvent event) {
|
||||
if (event.data != null) {
|
||||
MyType[] myTypes = (MyType[]) event.data;
|
||||
if (myTypes != null) {
|
||||
String string = "";
|
||||
for (int i = 0; i < myTypes.length; i++) {
|
||||
string += myTypes[i].fileName + " ";
|
||||
}
|
||||
label2.setText(string);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
shell.setSize(200, 200);
|
||||
shell.open();
|
||||
while (!shell.isDisposed()) {
|
||||
if (!display.readAndDispatch())
|
||||
display.sleep();
|
||||
}
|
||||
display.dispose();
|
||||
}
|
||||
}
|
||||
@@ -1,170 +0,0 @@
|
||||
// ============================================================================
|
||||
//
|
||||
// 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.edit;
|
||||
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.dnd.DND;
|
||||
import org.eclipse.swt.dnd.DragSource;
|
||||
import org.eclipse.swt.dnd.DragSourceEvent;
|
||||
import org.eclipse.swt.dnd.DragSourceListener;
|
||||
import org.eclipse.swt.dnd.DropTarget;
|
||||
import org.eclipse.swt.dnd.DropTargetAdapter;
|
||||
import org.eclipse.swt.dnd.DropTargetEvent;
|
||||
import org.eclipse.swt.dnd.TextTransfer;
|
||||
import org.eclipse.swt.dnd.Transfer;
|
||||
import org.eclipse.swt.graphics.Point;
|
||||
import org.eclipse.swt.graphics.Rectangle;
|
||||
import org.eclipse.swt.layout.FillLayout;
|
||||
import org.eclipse.swt.widgets.Display;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
import org.eclipse.swt.widgets.Tree;
|
||||
import org.eclipse.swt.widgets.TreeItem;
|
||||
|
||||
public class Snippet91 {
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
final Display display = new Display();
|
||||
final Shell shell = new Shell(display);
|
||||
shell.setLayout(new FillLayout());
|
||||
final Tree tree = new Tree(shell, SWT.BORDER);
|
||||
for (int i = 0; i < 3; i++) {
|
||||
TreeItem item = new TreeItem(tree, SWT.NONE);
|
||||
item.setText("item " + i);
|
||||
for (int j = 0; j < 3; j++) {
|
||||
TreeItem subItem = new TreeItem(item, SWT.NONE);
|
||||
subItem.setText("item " + i + " " + j);
|
||||
for (int k = 0; k < 3; k++) {
|
||||
TreeItem subsubItem = new TreeItem(subItem, SWT.NONE);
|
||||
subsubItem.setText("item " + i + " " + j + " " + k);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Transfer[] types = new Transfer[] { TextTransfer.getInstance() };
|
||||
int operations = DND.DROP_MOVE | DND.DROP_COPY | DND.DROP_LINK;
|
||||
|
||||
final DragSource source = new DragSource(tree, operations);
|
||||
source.setTransfer(types);
|
||||
final TreeItem[] dragSourceItem = new TreeItem[1];
|
||||
source.addDragListener(new DragSourceListener() {
|
||||
|
||||
public void dragStart(DragSourceEvent event) {
|
||||
TreeItem[] selection = tree.getSelection();
|
||||
if (selection.length > 0 && selection[0].getItemCount() == 0) {
|
||||
event.doit = true;
|
||||
dragSourceItem[0] = selection[0];
|
||||
} else {
|
||||
event.doit = false;
|
||||
}
|
||||
};
|
||||
|
||||
public void dragSetData(DragSourceEvent event) {
|
||||
event.data = dragSourceItem[0].getText();
|
||||
}
|
||||
|
||||
public void dragFinished(DragSourceEvent event) {
|
||||
if (event.detail == DND.DROP_MOVE)
|
||||
dragSourceItem[0].dispose();
|
||||
dragSourceItem[0] = null;
|
||||
}
|
||||
});
|
||||
|
||||
DropTarget target = new DropTarget(tree, operations);
|
||||
target.setTransfer(types);
|
||||
target.addDropListener(new DropTargetAdapter() {
|
||||
|
||||
public void dragOver(DropTargetEvent event) {
|
||||
event.feedback = DND.FEEDBACK_EXPAND | DND.FEEDBACK_SCROLL;
|
||||
if (event.item != null) {
|
||||
TreeItem item = (TreeItem) event.item;
|
||||
Point pt = display.map(null, tree, event.x, event.y);
|
||||
Rectangle bounds = item.getBounds();
|
||||
if (pt.y < bounds.y + bounds.height / 3) {
|
||||
event.feedback |= DND.FEEDBACK_INSERT_BEFORE;
|
||||
} else if (pt.y > bounds.y + 2 * bounds.height / 3) {
|
||||
event.feedback |= DND.FEEDBACK_INSERT_AFTER;
|
||||
} else {
|
||||
event.feedback |= DND.FEEDBACK_SELECT;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void drop(DropTargetEvent event) {
|
||||
if (event.data == null) {
|
||||
event.detail = DND.DROP_NONE;
|
||||
return;
|
||||
}
|
||||
String text = (String) event.data;
|
||||
if (event.item == null) {
|
||||
TreeItem item = new TreeItem(tree, SWT.NONE);
|
||||
item.setText(text);
|
||||
} else {
|
||||
TreeItem item = (TreeItem) event.item;
|
||||
Point pt = display.map(null, tree, event.x, event.y);
|
||||
Rectangle bounds = item.getBounds();
|
||||
TreeItem parent = item.getParentItem();
|
||||
if (parent != null) {
|
||||
TreeItem[] items = parent.getItems();
|
||||
int index = 0;
|
||||
for (int i = 0; i < items.length; i++) {
|
||||
if (items[i] == item) {
|
||||
index = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (pt.y < bounds.y + bounds.height / 3) {
|
||||
TreeItem newItem = new TreeItem(parent, SWT.NONE, index);
|
||||
newItem.setText(text);
|
||||
} else if (pt.y > bounds.y + 2 * bounds.height / 3) {
|
||||
TreeItem newItem = new TreeItem(parent, SWT.NONE, index + 1);
|
||||
newItem.setText(text);
|
||||
} else {
|
||||
TreeItem newItem = new TreeItem(item, SWT.NONE);
|
||||
newItem.setText(text);
|
||||
}
|
||||
|
||||
} else {
|
||||
TreeItem[] items = tree.getItems();
|
||||
int index = 0;
|
||||
for (int i = 0; i < items.length; i++) {
|
||||
if (items[i] == item) {
|
||||
index = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (pt.y < bounds.y + bounds.height / 3) {
|
||||
TreeItem newItem = new TreeItem(tree, SWT.NONE, index);
|
||||
newItem.setText(text);
|
||||
} else if (pt.y > bounds.y + 2 * bounds.height / 3) {
|
||||
TreeItem newItem = new TreeItem(tree, SWT.NONE, index + 1);
|
||||
newItem.setText(text);
|
||||
} else {
|
||||
TreeItem newItem = new TreeItem(item, SWT.NONE);
|
||||
newItem.setText(text);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
shell.setSize(400, 400);
|
||||
shell.open();
|
||||
while (!shell.isDisposed()) {
|
||||
if (!display.readAndDispatch())
|
||||
display.sleep();
|
||||
}
|
||||
display.dispose();
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,101 +1,140 @@
|
||||
// ============================================================================
|
||||
//
|
||||
// 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 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>();
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
// ============================================================================
|
||||
//
|
||||
// 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,157 +1,155 @@
|
||||
// ============================================================================
|
||||
//
|
||||
// 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 typeDispaly = type == null ? "" : TalendTextUtils.LBRACKET + this.type.getName() + TalendTextUtils.RBRACKET;
|
||||
this.displayName = getParent().getName() + "-" + index + "(" + (++rep) + ")" + typeDispaly; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||
|
||||
}
|
||||
|
||||
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);
|
||||
if (p.getValue() != null) {
|
||||
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;
|
||||
}
|
||||
}
|
||||
// ============================================================================
|
||||
//
|
||||
// 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-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;
|
||||
}
|
||||
}
|
||||
// ============================================================================
|
||||
//
|
||||
// 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
@@ -18,7 +18,7 @@ public class XmlMapExpressionManager {
|
||||
|
||||
private final static String EXPRESSION_PATTERN = "(\\[)\\s*(\\w+)\\s*\\.(\\w+\\s*:\\s*(/.+?)+(/@.+?)*)\\s*(\\])|((?!\\[)\\s*\\w+)\\s*\\.\\s*(\\w+(?!\\]))";
|
||||
|
||||
private final String SUBS_PATTERN_FOR_REPLACE_LOCATION = "{0}(\\s*){1}(\\s*)\\.(\\s*){2}(\\s*){3}";
|
||||
private final String SUBS_PATTERN_FOR_REPLACE_LOCATION = "{0}(\\s*\\b){1}(\\s*)\\.(\\s*){2}(\\b\\s*){3}";
|
||||
|
||||
private Perl5Matcher matcher = new Perl5Matcher();
|
||||
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -3,6 +3,5 @@
|
||||
<classpathentry exported="true" kind="lib" path="lib/commons-net-3.3.jar"/>
|
||||
<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,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/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>
|
||||
|
||||
@@ -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>
|
||||
|
||||
Binary file not shown.
@@ -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>
|
||||
|
||||
@@ -415,7 +415,16 @@ public class ImportItemUtil {
|
||||
return 0;
|
||||
} else if (!(o1.getProperty().getItem() instanceof RoutineItem)
|
||||
&& !(o2.getProperty().getItem() instanceof RoutineItem)) {
|
||||
return 0;
|
||||
// TUP-2548 sort items by label
|
||||
String label = o1.getLabel();
|
||||
if (label == null) {
|
||||
return -1;
|
||||
}
|
||||
final String label2 = o2.getLabel();
|
||||
if (label2 == null) {
|
||||
return 1;
|
||||
}
|
||||
return label.compareTo(label2);
|
||||
} else if (o1.getProperty().getItem() instanceof RoutineItem) {
|
||||
return -1;
|
||||
} else {
|
||||
|
||||
@@ -25,6 +25,7 @@ import java.util.Map;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
import org.eclipse.core.resources.IWorkspace;
|
||||
import org.eclipse.core.resources.IWorkspaceRunnable;
|
||||
import org.eclipse.core.resources.ResourcesPlugin;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.FileLocator;
|
||||
@@ -32,6 +33,7 @@ import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||
import org.eclipse.core.runtime.Path;
|
||||
import org.eclipse.core.runtime.Platform;
|
||||
import org.eclipse.core.runtime.jobs.ISchedulingRule;
|
||||
import org.eclipse.jface.dialogs.ProgressMonitorDialog;
|
||||
import org.eclipse.jface.layout.GridDataFactory;
|
||||
import org.eclipse.jface.operation.IRunnableWithProgress;
|
||||
@@ -71,6 +73,7 @@ import org.talend.core.model.properties.PropertiesFactory;
|
||||
import org.talend.core.model.repository.ERepositoryObjectType;
|
||||
import org.talend.core.repository.model.ProxyRepositoryFactory;
|
||||
import org.talend.core.ui.ISVNProviderService;
|
||||
import org.talend.repository.RepositoryWorkUnit;
|
||||
import org.talend.repository.model.ComponentsFactoryProvider;
|
||||
import org.talend.repository.model.IProxyRepositoryFactory;
|
||||
|
||||
@@ -142,6 +145,7 @@ public class CustomComponentSettingPage extends ProjectSettingPage {
|
||||
|
||||
componentViewer.addSelectionChangedListener(new ISelectionChangedListener() {
|
||||
|
||||
@Override
|
||||
public void selectionChanged(SelectionChangedEvent event) {
|
||||
shareButton.setEnabled(!event.getSelection().isEmpty());
|
||||
}
|
||||
@@ -158,6 +162,7 @@ public class CustomComponentSettingPage extends ProjectSettingPage {
|
||||
|
||||
shareViewer.addSelectionChangedListener(new ISelectionChangedListener() {
|
||||
|
||||
@Override
|
||||
public void selectionChanged(SelectionChangedEvent event) {
|
||||
backButton.setEnabled(!event.getSelection().isEmpty());
|
||||
}
|
||||
@@ -340,6 +345,7 @@ public class CustomComponentSettingPage extends ProjectSettingPage {
|
||||
protected void performApply() {
|
||||
final IRunnableWithProgress runnable = new IRunnableWithProgress() {
|
||||
|
||||
@Override
|
||||
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
|
||||
monitor.beginTask("Save custom component setting", (sharedAdded.size() + backAdded.size()) * 100);
|
||||
finish(monitor);
|
||||
@@ -369,97 +375,138 @@ public class CustomComponentSettingPage extends ProjectSettingPage {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean performCancel() {
|
||||
if (componentViewer != null) {
|
||||
resetCustomComponentSetting();
|
||||
}
|
||||
return super.performCancel();
|
||||
}
|
||||
public boolean performCancel() {
|
||||
if (componentViewer != null) {
|
||||
resetCustomComponentSetting();
|
||||
}
|
||||
return super.performCancel();
|
||||
}
|
||||
|
||||
private void finish(IProgressMonitor... monitorWrap) {
|
||||
private void finish(IProgressMonitor... monitorWrap) {
|
||||
IProgressMonitor monitor = null;
|
||||
if (monitorWrap != null && monitorWrap.length == 1) {
|
||||
monitor = monitorWrap[0];
|
||||
}
|
||||
IProxyRepositoryFactory prf = CorePlugin.getDefault().getProxyRepositoryFactory();
|
||||
final IProxyRepositoryFactory prf = CorePlugin.getDefault().getProxyRepositoryFactory();
|
||||
|
||||
if (PluginChecker.isSVNProviderPluginLoaded() && (!sharedAdded.isEmpty() || !backAdded.isEmpty())) {
|
||||
ISVNProviderService service = (ISVNProviderService) GlobalServiceRegister.getDefault().getService(
|
||||
ISVNProviderService.class);
|
||||
String projectLabel = pro.getTechnicalLabel();
|
||||
IWorkspace workspace = ResourcesPlugin.getWorkspace();
|
||||
IProject eclipseProject = workspace.getRoot().getProject(projectLabel);
|
||||
RepositoryWorkUnit repositoryWorkUnit = new RepositoryWorkUnit("Commit new component") {
|
||||
|
||||
String targetRoot = new Path(Platform.getInstanceLocation().getURL().getPath()).toFile().getPath()
|
||||
+ File.separatorChar + projectLabel + File.separatorChar
|
||||
+ ERepositoryObjectType.getFolderName(ERepositoryObjectType.COMPONENTS);
|
||||
File componentFolder = new File(targetRoot);
|
||||
URL url = null;
|
||||
try {
|
||||
if (!componentFolder.exists()) {
|
||||
FilesUtils.createFoldersIfNotExists(targetRoot, false);
|
||||
}
|
||||
Bundle b = Platform.getBundle(IComponentsFactory.COMPONENTS_LOCATION);
|
||||
url = FileLocator.toFileURL(FileLocator.find(b, new Path(""), null));
|
||||
@Override
|
||||
public void run() throws PersistenceException {
|
||||
final IWorkspaceRunnable op = new IWorkspaceRunnable() {
|
||||
|
||||
String sourceRoot = url.getFile();
|
||||
@Override
|
||||
public void run(IProgressMonitor subMonitor) throws CoreException {
|
||||
|
||||
// delete share
|
||||
for (IComponent component : backAdded.keySet()) {
|
||||
service.svnEclipseHandlerDelete(eclipseProject, pro, targetRoot + File.separator + component.getName());
|
||||
if (monitor != null) {
|
||||
monitor.worked(10);
|
||||
}
|
||||
}
|
||||
if (!backAdded.isEmpty()) {
|
||||
getCustomComponentSettings().removeAll(backAdded.values());
|
||||
}
|
||||
ISVNProviderService service = (ISVNProviderService) GlobalServiceRegister.getDefault().getService(
|
||||
ISVNProviderService.class);
|
||||
String projectLabel = pro.getTechnicalLabel();
|
||||
IWorkspace workspace = ResourcesPlugin.getWorkspace();
|
||||
IProject eclipseProject = workspace.getRoot().getProject(projectLabel);
|
||||
|
||||
FileFilter ff = new FileFilter() {
|
||||
String targetRoot = new Path(Platform.getInstanceLocation().getURL().getPath()).toFile().getPath()
|
||||
+ File.separatorChar + projectLabel + File.separatorChar
|
||||
+ ERepositoryObjectType.getFolderName(ERepositoryObjectType.COMPONENTS);
|
||||
File componentFolder = new File(targetRoot);
|
||||
URL url = null;
|
||||
try {
|
||||
if (!componentFolder.exists()) {
|
||||
FilesUtils.createFoldersIfNotExists(targetRoot, false);
|
||||
}
|
||||
Bundle b = Platform.getBundle(IComponentsFactory.COMPONENTS_LOCATION);
|
||||
url = FileLocator.toFileURL(FileLocator.find(b, new Path(""), null));
|
||||
|
||||
public boolean accept(File pathname) {
|
||||
if (FilesUtils.isSVNFolder(pathname)) {
|
||||
return false;
|
||||
String sourceRoot = url.getFile();
|
||||
|
||||
// delete share
|
||||
for (IComponent component : backAdded.keySet()) {
|
||||
service.svnEclipseHandlerDelete(eclipseProject, pro,
|
||||
targetRoot + File.separator + component.getName());
|
||||
if (subMonitor != null) {
|
||||
subMonitor.worked(10);
|
||||
}
|
||||
}
|
||||
if (!backAdded.isEmpty()) {
|
||||
getCustomComponentSettings().removeAll(backAdded.values());
|
||||
}
|
||||
|
||||
FileFilter ff = new FileFilter() {
|
||||
|
||||
@Override
|
||||
public boolean accept(File pathname) {
|
||||
if (FilesUtils.isSVNFolder(pathname)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
// share
|
||||
for (IComponent component : sharedAdded.keySet()) {
|
||||
String sourcePath = sourceRoot + component.getPathSource() + File.separator
|
||||
+ component.getName();
|
||||
File sourceFile = new File(sourcePath);
|
||||
|
||||
String targetPath = targetRoot + File.separatorChar + component.getName();
|
||||
File targetFile = new File(targetPath);
|
||||
FilesUtils.copyFolder(sourceFile, targetFile, true, ff, null, true, false);
|
||||
if (subMonitor != null) {
|
||||
subMonitor.worked(10);
|
||||
}
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
resetCustomComponentSetting();
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
try {
|
||||
prf.saveProject(pro);
|
||||
} catch (PersistenceException e) {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
|
||||
try {
|
||||
eclipseProject.refreshLocal(IResource.DEPTH_INFINITE, subMonitor);
|
||||
} catch (CoreException e1) {
|
||||
ExceptionHandler.process(e1);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
// share
|
||||
for (IComponent component : sharedAdded.keySet()) {
|
||||
String sourcePath = sourceRoot + component.getPathSource() + File.separator + component.getName();
|
||||
File sourceFile = new File(sourcePath);
|
||||
|
||||
String targetPath = targetRoot + File.separatorChar + component.getName();
|
||||
File targetFile = new File(targetPath);
|
||||
FilesUtils.copyFolder(sourceFile, targetFile, true, ff, null, true, false);
|
||||
if (monitor != null) {
|
||||
monitor.worked(10);
|
||||
};
|
||||
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, new NullProgressMonitor());
|
||||
} catch (CoreException e) {
|
||||
throw new PersistenceException(e.getCause());
|
||||
}
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
resetCustomComponentSetting();
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
};
|
||||
repositoryWorkUnit.setRefreshRepository(false);
|
||||
repositoryWorkUnit.setForceTransaction(true);
|
||||
prf.executeRepositoryWorkUnit(repositoryWorkUnit);
|
||||
try {
|
||||
prf.saveProject(pro);
|
||||
repositoryWorkUnit.throwPersistenceExceptionIfAny();
|
||||
} catch (PersistenceException e) {
|
||||
ExceptionHandler.process(e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
try {
|
||||
eclipseProject.refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());
|
||||
} catch (CoreException e1) {
|
||||
ExceptionHandler.process(e1);
|
||||
}
|
||||
|
||||
}
|
||||
if (monitor != null) {
|
||||
monitor.done();
|
||||
}
|
||||
|
||||
// refresh again after the gui closed .
|
||||
try {
|
||||
String projectLabel = pro.getTechnicalLabel();
|
||||
IWorkspace workspace = ResourcesPlugin.getWorkspace();
|
||||
IProject eclipseProject = workspace.getRoot().getProject(projectLabel);
|
||||
eclipseProject.refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());
|
||||
} catch (CoreException e1) {
|
||||
ExceptionHandler.process(e1);
|
||||
}
|
||||
}
|
||||
|
||||
private void resetCustomComponentSetting() {
|
||||
@@ -504,21 +551,25 @@ public class CustomComponentSettingPage extends ProjectSettingPage {
|
||||
*/
|
||||
class CustomCompSettingContentProvider implements ITreeContentProvider {
|
||||
|
||||
@Override
|
||||
public Object[] getChildren(Object parentElement) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getParent(Object element) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasChildren(Object element) {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object[] getElements(Object inputElement) {
|
||||
if (inputElement instanceof List) {
|
||||
return ((List) inputElement).toArray();
|
||||
@@ -526,11 +577,13 @@ public class CustomComponentSettingPage extends ProjectSettingPage {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dispose() {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
|
||||
Reference in New Issue
Block a user