/** * This function makes the call to the XML database and retrieves all the file metadata for use in * ECGridToolkit. The data is first retrieved in a series of XML blocks, and then they are * converted into StudyEntry Objects and returned to the user * * @param userID - The ID of the user. This is used to check which files the user has submitted * and thus has access to * @return The list of StudyEntry Objects taken from the file metadata in the XML database */ public ArrayList<StudyEntry> getEntries(String userID) { ArrayList<StudyEntry> tempList = new ArrayList<StudyEntry>(); try { // create first query to get the entire studyEntry block, the collection() XQuery function // does this across // all documents in the XML Collection // The goal of this query is to find all the data we need for the StudyEntry object based on // which user submitted them. For all the documents searched, the query looks to see // if any files for that subject's ECG repository were submitted by that user. If any files // were submitted, retrieve their metadata contained in the studyEntry block. String sQuery = studyBuilder.defaultFor() + studyBuilder.defaultWhere(userID) + studyBuilder.defaultOrderBy() + studyBuilder.defaultReturn(); System.out.println("Query to be executed = " + sQuery); ResourceSet resultSet = executeQuery(sQuery); ResourceIterator iter = resultSet.getIterator(); Resource selection = null; Resource fileSelection = null; int listIndex = 0; int subjectCount = 1; while (iter.hasMoreResources()) { selection = iter.nextResource(); String studyEntryResult = (selection.getContent()).toString(); // Now we will create an XStream object and then put that into our StudyEntry objects // the StudyEntry objects are de-serialized versions of the studyEntry blocks. XStream xmlStream = new XStream(); xmlStream.alias("studyEntry", StudyEntry.class); xmlStream.alias("recordDetails", RecordDetails.class); xmlStream.alias("fileDetails", FileDetails.class); xmlStream.addImplicitCollection(RecordDetails.class, "fileDetails"); StudyEntry newStudy = (StudyEntry) xmlStream.fromXML(studyEntryResult); // System.out.println(newStudy); // Add it to the return array tempList.add(newStudy); } } catch (Exception ex) { System.out.println( "StudyEntryUtility.getEntries(): AN EXCEPTION HAS BEEN CAUGHT! IF A LIST IS RETURNED, IT WILL BE EMPTY!!!"); ex.printStackTrace(); } return tempList; }
public ArrayList<String> queryDatatypeNodes(String userID) { System.out.println("In function queryDatatypeTypes"); ArrayList<String> tempList = new ArrayList<String>(); try { // create first query to get the entire studyEntry block, the collection() XQuery function // does this across // all documents in the XML Collection // The goal of this query is to find all the data we need for the StudyEntry object based on // which user submitted them. For all the documents searched, the query looks to see // if any files for that subject's ECG repository were submitted by that user. If any files // were submitted, retrieve their metadata contained in the studyEntry block. String sQuery = studyBuilder.defaultFor() + studyBuilder.userDefinedWhere(userID) + studyBuilder.defaultOrderBy() + studyBuilder.returnDistinct(EnumStudyTreeNode.DATATYPE); System.out.println("Query to be executed = " + sQuery); ResourceSet resultSet = executeQuery(sQuery); ResourceIterator iter = resultSet.getIterator(); Resource selection = null; tempList = this.checkForDuplicates(iter, selection); for (String listing : tempList) { int i = 1; System.out.println("Entry " + i + " = " + listing); i++; } } catch (Exception ex) { System.out.println( "StudyEntryUtility.queryStudies(): AN EXCEPTION HAS BEEN CAUGHT! IF A LIST IS RETURNED, IT WILL BE EMPTY!!!"); ex.printStackTrace(); } return tempList; }