Revision 7418
Added by ben leinfelder about 12 years ago
src/edu/ucsb/nceas/metacat/dataone/MNodeService.java | ||
---|---|---|
34 | 34 |
import java.util.List; |
35 | 35 |
import java.util.Set; |
36 | 36 |
import java.util.Timer; |
37 |
import java.util.Vector; |
|
37 | 38 |
|
38 | 39 |
import javax.servlet.http.HttpServletRequest; |
39 | 40 |
|
... | ... | |
91 | 92 |
import org.dataone.service.types.v1.util.ChecksumUtil; |
92 | 93 |
import org.dataone.service.types.v1_1.QueryEngineDescription; |
93 | 94 |
import org.dataone.service.types.v1_1.QueryEngineList; |
95 |
import org.dataone.service.types.v1_1.QueryField; |
|
94 | 96 |
import org.dataone.service.util.Constants; |
95 | 97 |
|
96 | 98 |
import edu.ucsb.nceas.metacat.DBQuery; |
... | ... | |
101 | 103 |
import edu.ucsb.nceas.metacat.MetacatHandler; |
102 | 104 |
import edu.ucsb.nceas.metacat.dataone.hazelcast.HazelcastService; |
103 | 105 |
import edu.ucsb.nceas.metacat.properties.PropertyService; |
106 |
import edu.ucsb.nceas.metacat.shared.MetacatUtilException; |
|
104 | 107 |
import edu.ucsb.nceas.metacat.util.SystemUtil; |
105 | 108 |
import edu.ucsb.nceas.utilities.PropertyNotFoundException; |
106 | 109 |
|
... | ... | |
134 | 137 |
public class MNodeService extends D1NodeService |
135 | 138 |
implements MNAuthorization, MNCore, MNRead, MNReplication, MNStorage, MNQuery { |
136 | 139 |
|
137 |
/* the logger instance */ |
|
140 |
private static final String PATHQUERY = "pathquery"; |
|
141 |
|
|
142 |
/* the logger instance */ |
|
138 | 143 |
private Logger logMetacat = null; |
139 | 144 |
|
140 | 145 |
/* A reference to a remote Memeber Node */ |
... | ... | |
1327 | 1332 |
public QueryEngineDescription getQueryEngineDescription(String engine) |
1328 | 1333 |
throws InvalidToken, ServiceFailure, NotAuthorized, NotImplemented, |
1329 | 1334 |
NotFound { |
1330 |
// TODO: implement |
|
1331 |
throw new NotImplemented("", "Metacat has not implemented this method"); |
|
1335 |
QueryEngineDescription qed = new QueryEngineDescription(); |
|
1336 |
qed.setName(PATHQUERY); |
|
1337 |
qed.setQueryEngineVersion("1.0"); |
|
1338 |
qed.addAdditionalInfo("This is the traditional structured query for Metacat"); |
|
1339 |
Vector<String> pathsForIndexing = null; |
|
1340 |
try { |
|
1341 |
pathsForIndexing = SystemUtil.getPathsForIndexing(); |
|
1342 |
} catch (MetacatUtilException e) { |
|
1343 |
logMetacat.warn("Could not get index paths", e); |
|
1344 |
} |
|
1345 |
for (String fieldName: pathsForIndexing) { |
|
1346 |
QueryField field = new QueryField(); |
|
1347 |
field.addDescription("Indexed field for path '" + fieldName + "'"); |
|
1348 |
field.setName(fieldName); |
|
1349 |
field.setReturnable(true); |
|
1350 |
field.setSearchable(true); |
|
1351 |
field.setSortable(false); |
|
1352 |
// TODO: determine type and multivaluedness |
|
1353 |
field.setType(String.class.getName()); |
|
1354 |
//field.setMultivalued(true); |
|
1355 |
qed.addQueryField(field); |
|
1356 |
} |
|
1357 |
return qed; |
|
1332 | 1358 |
} |
1333 | 1359 |
|
1334 | 1360 |
@Override |
... | ... | |
1336 | 1362 |
ServiceFailure, NotAuthorized, NotImplemented { |
1337 | 1363 |
QueryEngineList qel = new QueryEngineList(); |
1338 | 1364 |
// support pathquery initially |
1339 |
qel.addQueryEngine("pathquery");
|
|
1365 |
qel.addQueryEngine(PATHQUERY);
|
|
1340 | 1366 |
// TODO: implement solr-based query |
1341 | 1367 |
//qel.addQueryEngine("solr"); |
1342 | 1368 |
return qel; |
... | ... | |
1346 | 1372 |
public InputStream query(String engine, String query) throws InvalidToken, |
1347 | 1373 |
ServiceFailure, NotAuthorized, InvalidRequest, NotImplemented, |
1348 | 1374 |
NotFound { |
1349 |
if (engine.equals("pathquery")) {
|
|
1375 |
if (engine.equals(PATHQUERY)) {
|
|
1350 | 1376 |
try { |
1351 | 1377 |
DBQuery queryobj = new DBQuery(); |
1352 | 1378 |
String user = Constants.SUBJECT_PUBLIC; |
Also available in: Unified diff
implement query description for pathquery -- only tells callers about the pre-indexed paths we have in Metacat since there are an infinite number of "fields" when storing arbitrary XML, but we really don't want people using non-indexed paths for performance reasons anyway. I've typed all the fields as String, even though some are not just strings and can be used for numeric or data comparisons.