Subversion Repositories XServices

Rev

Rev 34 | Rev 42 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 34 Rev 39
Line 22... Line 22...
22
 
22
 
23
import java.math.BigInteger;
23
import java.math.BigInteger;
24
import java.net.URL;
24
import java.net.URL;
25
import java.util.ArrayList;
25
import java.util.ArrayList;
-
 
26
import java.util.Date;
26
import java.util.Date;
27
import java.util.HashMap;
27
import java.util.Iterator;
28
import java.util.Iterator;
-
 
29
import java.util.List;
28
import java.util.List;
30
import java.util.Map;
Line 29... Line 31...
29
import java.util.StringTokenizer;
31
import java.util.StringTokenizer;
30
 
32
 
Line 61... Line 63...
61
	private Aewebservices71PortType port;
63
	private Aewebservices71PortType port;
62
	private static final QName SERVICE_NAME = new QName("http://localhost:80/gsoap/aewebservices71.wsdl", "aewebservices71");
64
	private static final QName SERVICE_NAME = new QName("http://localhost:80/gsoap/aewebservices71.wsdl", "aewebservices71");
63
	private TaskRepository repository;
65
	private TaskRepository repository;
64
	private ObjectFactory of;
66
	private ObjectFactory of;
65
	private List<TableData> tables = new ArrayList<TableData>();
67
	private List<TableData> tables = new ArrayList<TableData>();
-
 
68
	private Map<String, List<SBMFieldValue>> validsets = new HashMap<String, List<SBMFieldValue>>();
Line 66... Line 69...
66
	
69
	
67
	/**
70
	/**
68
	 * Instantiates a new SBM client.
71
	 * Instantiates a new SBM client.
69
	 * Creates new instance of the aewebservices71 {@link net.brutex.sbm.wsclient.ObjectFactory} and
72
	 * Creates new instance of the aewebservices71 {@link net.brutex.sbm.wsclient.ObjectFactory} and
Line 100... Line 103...
100
			return false;
103
			return false;
101
		}
104
		}
102
		return true;
105
		return true;
103
	}
106
	}
Line -... Line 107...
-
 
107
	
-
 
108
	public List<TTItem> getTTItemsByTable(String tablename, String sql_where) throws CoreException {
-
 
109
		return getTTItemsByTable(tablename, sql_where, false);
-
 
110
	}
104
	
111
	
105
	/**
112
	/**
106
	 * Gets the SBM items from a table. The result size is limited to 500 and the sorting is done
113
	 * Gets the SBM items from a table. The result size is limited to 500 and the sorting is done
107
	 * by submit date descending.
114
	 * by TS_ID descending.
108
	 *
115
	 *
109
	 * @param tablename the tablename
116
	 * @param tablename the tablename
110
	 * @param sql_where the sql_where
117
	 * @param sql_where the sql_where
111
	 * @return the tT items by table
118
	 * @return the tT items by table
112
	 * @throws CoreException the core exception
119
	 * @throws CoreException the core exception
113
	 */
120
	 */
114
	public List<TTItem> getTTItemsByTable(String tablename, String sql_where) throws CoreException {
121
	public List<TTItem> getTTItemsByTable(String tablename, String sql_where, boolean getFullData) throws CoreException {
-
 
122
		List<TTItem> list = new ArrayList<TTItem>();
-
 
123
		String sections = "SECTION:FIXED";
115
		List<TTItem> list = new ArrayList<TTItem>();
124
		if(getFullData) sections = "SECTION:ALL";
116
		if(sql_where==null || sql_where.isEmpty()) sql_where = "TS_ID>0";
125
		if(sql_where==null || sql_where.isEmpty()) sql_where = "TS_ID>0";
117
		try {
126
		try {
118
			list = port.getItemsByQueryWithName(
127
			list = port.getItemsByQueryWithName(
119
					getAuth(), 
128
					getAuth(), 
120
					tablename, 
129
					tablename, 
121
					"("+sql_where+")",
130
					"("+sql_where+")",
-
 
131
					"TS_ID desc",
122
					"TS_SUBMITDATE desc",
132
					null, 
123
					BigInteger.valueOf(500l), null);
133
					sections);
124
		} catch (AEWebservicesFaultFault e) {
134
		} catch (AEWebservicesFaultFault e) {
125
			new CoreException(
135
			throw new CoreException(
126
					RepositoryStatus.createInternalError(
136
					RepositoryStatus.createInternalError(
127
							SBMConnectorPlugin.PLUGIN_ID, e.getFaultInfo(), e));
137
							SBMConnectorPlugin.PLUGIN_ID, e.getMessage(), e));
128
		}
138
		} 
129
		return list;
139
		return list;
Line -... Line 140...
-
 
140
	}
-
 
141
	
-
 
142
	public int getResultCount(String tablename, String sql) throws CoreException {
-
 
143
		List<TTItem> list = new ArrayList<TTItem>();
-
 
144
		try {
-
 
145
			list = port.getItemsByQueryWithName(
-
 
146
					getAuth(), 
-
 
147
					tablename, 
-
 
148
					"("+sql+")",
-
 
149
					"TS_ID desc",
-
 
150
					null, 
-
 
151
					"SECTION:NONE");
-
 
152
		} catch (AEWebservicesFaultFault e) {
-
 
153
			throw new CoreException(
-
 
154
					RepositoryStatus.createInternalError(
-
 
155
							SBMConnectorPlugin.PLUGIN_ID, e.getMessage(), e));
-
 
156
		}
-
 
157
		return list.size();
130
	}
158
	}
131
	
159
	
132
	/**
160
	/**
133
	 * Gets a SBM item specified by its internal identifier ([tableid:recordid])
161
	 * Gets a SBM item specified by its internal identifier ([tableid:recordid])
134
	 *
162
	 *
135
	 * @param itemid the itemid
163
	 * @param itemid the itemid
136
	 * @return the tT item
164
	 * @return the tT item
-
 
165
	 */
-
 
166
	public TTItem getTTItem(String itemid) {
-
 
167
		int pos1;
-
 
168
		int pos2;
-
 
169
		pos1 = itemid.lastIndexOf("[")+1;
137
	 */
170
		pos2 = itemid.lastIndexOf("]");
138
	public TTItem getTTItem(String itemid) {
171
		itemid = itemid.substring(pos1, pos2);
139
		TTItem item = of.createTTItem();
172
		TTItem item = of.createTTItem();
140
			try {
173
			try {
141
				item = port.getItem(getAuth(), itemid, null);
174
				item = port.getItem(getAuth(), itemid, null);
Line 294... Line 327...
294
					}
327
					}
295
				}
328
				}
296
				break;
329
				break;
297
			}
330
			}
298
		}
331
		}
299
	return "label_UNKNOWN";
332
	return fieldname; //field has not been found
300
	}
333
	}
Line 301... Line 334...
301
	
334
	
302
	/**
335
	/**
303
	 * Gets the table database name.
336
	 * Gets the table database name.
Line 452... Line 485...
452
		}
485
		}
453
		return values;
486
		return values;
454
	}
487
	}
Line 455... Line 488...
455
 
488
 
-
 
489
	public List<SBMFieldValue> getValidSet(String tablename, String fieldname) {
456
	public List<SBMFieldValue> getValidSet(String tablename, String fieldname) {
490
		if(validsets.containsKey(tablename+":"+fieldname)) return validsets.get(tablename+":"+fieldname);
457
		List<SBMFieldValue> list = new ArrayList<SBMFieldValue>();
491
		List<SBMFieldValue> list = new ArrayList<SBMFieldValue>();
458
		List<TTItem> ttlist = new ArrayList<TTItem>();
492
		List<TTItem> ttlist = new ArrayList<TTItem>();
459
		String sql = "TS_ID in (select max(TS_ID) from "+tablename+" group by ts_"+fieldname+")";
493
		String sql = "TS_ID in (select max(TS_ID) from "+tablename+" group by ts_"+fieldname+")";
460
		try {
494
		try {
Line 465... Line 499...
465
							SBMConnectorPlugin.PLUGIN_ID, e.getMessage(), e));
499
							SBMConnectorPlugin.PLUGIN_ID, e.getMessage(), e));
466
		}
500
		}
467
		for(TTItem ttitem : ttlist) {
501
		for(TTItem ttitem : ttlist) {
468
			list.add(getFieldValue(ttitem, fieldname));
502
			list.add(getFieldValue(ttitem, fieldname));
469
		}
503
		}
470
		
-
 
-
 
504
		validsets.put(tablename+":"+fieldname, list);
471
		return list;		
505
		return list;		
472
	}
506
	}
473
}
507
}