public Element createNodeElement(Document dom, int i) { Element data; Collaborator col = collaborators.get(i); Element node = dom.createElement("node"); node.setAttribute("id", col.getId()); for (int row = 0; row < nodeAttr.length; row++) { data = dom.createElement("data"); data.setAttribute("key", nodeAttr[row][0]); if (nodeAttr[row][0].equalsIgnoreCase("ContributorID")) data.setTextContent(col.getId()); else if (nodeAttr[row][0].equalsIgnoreCase("Label")) data.setTextContent(col.getName()); else if (nodeAttr[row][0].equalsIgnoreCase("ContributorName")) data.setTextContent(col.getName()); else if (nodeAttr[row][0].equalsIgnoreCase("Roles")) data.setTextContent(col.getFunction()); else if (nodeAttr[row][0].equalsIgnoreCase("Gender")) data.setTextContent(col.getGender()); else if (nodeAttr[row][0].equalsIgnoreCase("Nationality")) data.setTextContent(col.getNationality()); else if (nodeAttr[row][0].equalsIgnoreCase("ContributorURL")) data.setTextContent(col.getUrl()); // data.setTextContent(conURLprefix + col.getId()); node.appendChild(data); } return node; }
@Override public void onSuccess(List<DocumentMetadata> result) { if (result == null || result.size() == 0) { collaborator.statusUpdate("No documents available."); } else { collaborator.statusUpdate("Document list updated."); GWT.log("Got " + result.size() + " documents."); collaborator.documentList.clear(); for (DocumentMetadata meta : result) { collaborator.documentList.addItem(meta.getTitle(), meta.getKey()); } } collaborator.refreshDoc.setEnabled(true); }
@Override public void onFailure(Throwable caught) { collaborator.statusUpdate( "Error retrieving document list" + "; caught exception " + caught.getClass() + " with message: " + caught.getMessage()); GWT.log("Error getting document list.", caught); collaborator.refreshDoc.setEnabled(true); }
@Test public void recordExpectationsOnInjectableFinalMockField() { new Expectations() { { mock.getValue(); result = 12; mock.doSomething(); times = 0; } }; assertEquals(12, mock.getValue()); }
public void getDocumentList() { collaborator.statusUpdate("Fetching document list."); collaborator.refreshDoc.setEnabled(false); collaborator.collabService.getDocumentList(this); }
private boolean listenersAllowRemovals(String... titles) { return listener.voteForRemovals(titles) > 0; }
private boolean listenersAllowRemoval(String title) { return listener.voteForRemoval(title) > 0; }
private void notifyListenersDocumentRemoved(String title) { listener.documentRemoved(title); }
private void notifyListenersDocumentChanged(final String title) { listener.documentChanged(title); }
/* * add some of the additional required information for collaborator */ public ArrayList<Collaborator> getCollaborators( TreeMap<Integer, Collaborator> network, String id) { // declare helper variables java.util.ArrayList<Collaborator> collaborators = new java.util.ArrayList<Collaborator>(); // define a SPARQL query to get details about a collaborator String sparqlQuery = "PREFIX foaf: <" + FOAF.NS + ">" + "PREFIX ausestage: <" + AuseStage.NS + "> " + "SELECT ?collabName ?function ?gender ?nationality " + "WHERE { " + " @ a foaf:Person ; " + " foaf:name ?collabName. " + "OPTIONAL {@ ausestage:function ?function} " + "OPTIONAL {@ foaf:gender ?gender} " + "OPTIONAL {@ ausestage:nationality ?nationality} " + "} "; String queryToExecute = null; ResultSet results = null; QuerySolution row = null; Collaborator collaborator = null; // loop through the list of collaborators and get additional information Collection networkKeys = network.keySet(); Iterator networkKeyIterator = networkKeys.iterator(); Integer networkKey = null; Integer centreId = Integer.parseInt(id); // loop through the list of keys while (networkKeyIterator.hasNext()) { // get the key for this collaborator networkKey = (Integer) networkKeyIterator.next(); // create a new collaborator object collaborator = new Collaborator(networkKey.toString()); // build the query queryToExecute = sparqlQuery.replaceAll( "@", "<" + AusStageURI.getContributorURI(collaborator.getId()) + ">"); // execute the query results = rdf.executeSparqlQuery(queryToExecute); // add details to this contributor while (results.hasNext()) { // loop though the resulset // get a new row of data row = results.nextSolution(); // add the data to the collaborator collaborator.setName(row.get("collabName").toString()); if (row.get("function") != null) { collaborator.setFunction(row.get("function").toString()); } if (row.get("gender") != null) { collaborator.setGender(row.get("gender").toString()); } if (row.get("nationality") != null) { collaborator.setNationality(row.get("nationality").toString()); } collaborator.setUrl(AusStageURI.getContributorURL(collaborator.getId())); } // play nice and tidy rdf.tidyUp(); results = null; // add the collaborator to the list collaborators.add(collaborator); } return collaborators; }