/** * M�todo criado pra teste do m�todo getSocialInteractions da ferramenta de mensagens * @param mapping * @param form * @param request * @param response * @return * @throws Exception */ public ActionForward testMessageTool(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception{ System.out.println("Testando MessageTool"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); String inicio = "2012-12-10"; String fim = "2013-02-05"; Date dataIni = sdf.parse(inicio); Date dataFim = sdf.parse(fim); Course curso = facade.getCoursesById(18); MultiMap map = SocialInteractions.getSocialInteractionsFromMessenger(curso, dataIni, dataFim); for(Object o : map.values()) System.out.println(o); return null; }
/** * M�todo criado pra teste do m�todo getSocialInteractions da ferramenta do twitter * @param mapping * @param form * @param request * @param response * @return * @throws Exception */ public ActionForward testTwitterTool(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception{ System.out.println("Testando TwitterTool"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); String inicio = "2013-03-03"; String fim = "2013-03-05"; Date dataIni = sdf.parse(inicio); Date dataFim = sdf.parse(fim); MultiMap map = SocialInteractions.getSocialInteractionsFromTwitterTool(dataIni,dataFim); for(Object o : map.values()) System.out.println(o); return null; }
public Map<String,Integer> prestigeStudentsValued(ArrayList<String> actors, MultiMap interactions){ Map<String,Integer> prestige = new HashMap<String,Integer>(); int cont = 0; Collection<String> col = interactions.values(); ArrayList<String> interactionsEnd = new ArrayList<String>(col); for (String i:actors){ for (String j:interactionsEnd){ if (i.equals(j)){ cont++; } } prestige.put(i, cont); cont = 0; } return prestige; }
public Map<String,Integer> engagementStudentsValued(ArrayList<String> actors, MultiMap interac){ MultiValueMap interactions = (MultiValueMap)interac; Map<String,Integer> engagement = new HashMap<String,Integer>(); int cont = 0; for (String i:actors){ cont = interactions.size(i); engagement.put(i, cont); cont = 0; //System.out.println("Engajamento: " + engagement); } return engagement; }
public MultiMap noDuplicatedInteractions(ArrayList<String> actors, MultiMap interactions){ MultiMap clone = new MultiValueMap(); ArrayList<String> edges = new ArrayList<String>(); for (String j:actors){ edges = (ArrayList<String>)interactions.get(j); if (edges != null){ for (String i:edges){ if (!(tuplaExist(i,(ArrayList<String>)clone.get(j)))){ clone.put(j, i); } } } } System.out.println(clone); return clone; }
@SuppressWarnings("unchecked") private InputStream doBuildZip(CherryPickRequest cherryPickRequest, Set<CherryPickAssayPlate> forPlates) throws IOException { ByteArrayOutputStream zipOutRaw = new ByteArrayOutputStream(); ZipOutputStream zipOut = new ZipOutputStream(zipOutRaw); MultiMap/*<String,SortedSet<CherryPick>>*/ files2CherryPicks = buildCherryPickFiles(cherryPickRequest, forPlates); buildReadme(cherryPickRequest, zipOut); buildDistinctPlateCopyFile(cherryPickRequest, forPlates, zipOut); PrintWriter out = new CSVPrintWriter(new OutputStreamWriter(zipOut), NEWLINE); for (Iterator iter = files2CherryPicks.keySet().iterator(); iter.hasNext();) { String fileName = (String) iter.next(); ZipEntry zipEntry = new ZipEntry(fileName); zipOut.putNextEntry(zipEntry); writeHeadersRow(out); for (LabCherryPick cherryPick : (SortedSet<LabCherryPick>) files2CherryPicks.get(fileName)) { writeCherryPickRow(out, cherryPick); } out.flush(); } out.close(); return new ByteArrayInputStream(zipOutRaw.toByteArray()); }
private MultiMap getSourcePlateTypesForEachAssayPlate(CherryPickRequest cherryPickRequest) { MultiMap assayPlateName2PlateTypes = MultiValueMap.decorate(new HashMap(), new Factory() { public Object create() { return new HashSet(); } }); for (LabCherryPick cherryPick : cherryPickRequest.getLabCherryPicks()) { if (cherryPick.isAllocated() && cherryPick.isMapped()) { assayPlateName2PlateTypes.put(cherryPick.getAssayPlate().getName(), cherryPick.getSourceCopy().findPlate(cherryPick.getSourceWell().getPlateNumber()).getPlateType()); } } return assayPlateName2PlateTypes; }
/** * Internal method for collapsing a set of vertexes. * * @param er * @param superVertices * @param vertices_to_edges */ protected void collapseVerticesIntoSuperVertices( EquivalenceRelation er, Map superVertices, MultiMap vertices_to_edges) { Set vertices = new HashSet(vertices_to_edges.keySet()); // some of these vertices may be parts of one or another root set for (Iterator destinations = vertices.iterator(); destinations.hasNext(); ) { Vertex dest = (Vertex) destinations.next(); Set destSet = er.getEquivalenceRelationContaining(dest); if (destSet != null) { CollapsedVertex superV = (CollapsedVertex) superVertices.get(destSet); replaceWith(vertices_to_edges, dest, superV); } } }
/** * INTERNAL METHOD. * For a set of vertices, finds all the edges connected to them, indexed (in a MultiMap) * to the vertices to which they connect. Thus, in the graph with edges (A-C, A-D, B-C), * with input (A, B), the result will be ( C {A-C, B-C}; D {A-D} ) * @param rootSet * @return */ protected MultiMap findEdgesAndVerticesConnectedToRootSet(Set rootSet) { // now, let's get a candidate set of edges MultiMap vertices_to_edges = new MultiHashMap(); for (Iterator iter = rootSet.iterator(); iter.hasNext();) { Vertex v = (Vertex) iter.next(); for (Iterator iterator = v.getIncidentEdges().iterator(); iterator.hasNext(); ) { Edge e = (Edge) iterator.next(); Vertex other = e.getOpposite(v); if (rootSet.contains(other)) continue; vertices_to_edges.put(other, e); } } return vertices_to_edges; }
public MultiMap readCSVFile(String filename) throws Exception { BufferedReader inputTMP = new BufferedReader(new FileReader(filename)); String lineTMP = null; EmptyStringTokenizer strTk = null; while ((lineTMP = inputTMP.readLine()) != null) { String columnName = ""; ArrayList<String> dataForEachColumn = new ArrayList<String>(); strTk = new EmptyStringTokenizer(lineTMP.toString(), ","); columnName = strTk.nextToken(); StringBuffer _strBuf = new StringBuffer(); while (strTk.hasMoreTokens()) { _strBuf.append(strTk.nextToken() + ","); } _mhm.put(columnName, _strBuf); } return _mhm; }
@Override public MultiMap initEmbeddedPageActions() { if(embeddedPageActions == null) { MultiMap mm = new MultiValueMap(); Layout layout = pageInstance.getLayout(); for(ChildPage childPage : layout.getChildPages()) { String layoutContainerInParent = childPage.getContainer(); if(layoutContainerInParent != null) { String newPath = context.getActionPath() + "/" + childPage.getName(); newPath = ServletUtils.removePathParameters(newPath); //#PRT-1650 Path parameters mess with include File pageDir = new File(pageInstance.getChildrenDirectory(), childPage.getName()); try { Page page = DispatcherLogic.getPage(pageDir); EmbeddedPageAction embeddedPageAction = new EmbeddedPageAction( childPage.getName(), childPage.getActualOrder(), newPath, page); mm.put(layoutContainerInParent, embeddedPageAction); } catch (PageNotActiveException e) { logger.warn("Embedded page action is not active, skipping! " + pageDir, e); } } } for(Object entryObj : mm.entrySet()) { Map.Entry entry = (Map.Entry) entryObj; List pageActionContainer = (List) entry.getValue(); Collections.sort(pageActionContainer); } embeddedPageActions = mm; } return embeddedPageActions; }
private MultiMap getParameterMap(HttpServletRequest request) { MultiMap parameters = new MultiValueMap(); Page page = Page.fromRequest(request); String pageSessionNameFromRequest = page.getSessionAttributeName(); if (null != pageSessionNameFromRequest) { parameters.put(Page.IN_REQUEST, pageSessionNameFromRequest); } return parameters; }
/** * M�todo que retorna as intera��es sociais referentes a ferramenta de mensagens ass�ncronas. * @return Um multimap<Person,Person> que representa as intera��es sociais. * Dessa forma Person "key" interage com os Persons "values" * @throws Exception Lancada caso a data de fim venha antes da data de in�cio */ @SuppressWarnings("unchecked") public static MultiValueMap getSocialInteractionsFromMessenger(Course course, Date inicio, Date fim) throws Exception { if(fim.before(inicio)) throw new Exception("Data fim menor que a Data in�cio."); MultiMap interactions = new MultiValueMap(); Facade facade = Facade.getInstance(); List<Person> teachers = facade.getTeachersByCourse(course); List<Person> persons = facade.listStudentsByCourse(course); for (Person p : persons) { for (MessengerMessage m : p.getSent()) { if( (isBetweenDates(m, inicio, fim)) && ( persons.contains(m.getReceiver()) || teachers.contains(m.getReceiver()) ) ) interactions.put(p.getName(), m.getReceiver().getName()); } } Set keys = interactions.keySet(); System.out.println("Cheguei"); for(Object k : keys){ System.out.println(k + " : " + interactions.get(k)); } return (MultiValueMap) interactions; }
/** * M�todo que retorna as intera��es sociais referentes a ferramenta de monitoramento * do twitter. * @param inicio * @param fim * @return */ public static MultiMap getSocialInteractionsFromTwitterTool(Date inicio, Date fim){ Facade facade = Facade.getInstance(); List<Tweet> tweets = facade.getTweetBetweenDates(inicio, fim); MultiMap map = new MultiValueMap(); for(Tweet t : tweets){ if(t.getDateOfTweet().after(inicio) && t.getDateOfTweet().before(fim)) map.put(t.getUserSender().getName(), t.getUserTarget().getName()); } Set keys = map.keySet(); for(Object k : keys){ System.out.println(k + " : " + map.get(k)); } return map; }
/** * M�todo que retorna as intera��es sociais referentes a ferramenta de forum. * @return Um multimap<Person,Person> que representa as intera��es sociais. * Dessa forma Person "key" interage com os Persons "values" paramterizado pelas datas iniciais e finais. */ @SuppressWarnings("unchecked") public static MultiValueMap getSocialInteractionsFromForumsByCourseAndData(Course course, Date dataini, Date datafim) { MultiMap mhm = new MultiValueMap(); Facade facade = Facade.getInstance(); Course crs = facade.getCoursesById(course.getId()); List<Module> mdls = crs.getModules(); for (Module m : mdls) { for(Forum f: m.getForums()){ for(Message msg: f.getMessages()){ if(msg.getMessageReply()!=null &&msg.getDate().after(dataini)&&msg.getDate().before(datafim)&&!msg.getAuthor().equals(msg.getMessageReply().getAuthor())){ mhm.put(msg.getAuthor().getName(), msg.getMessageReply().getAuthor().getName()); }else if(msg.getMessageReply() == null && msg.getDate().after(dataini) && msg.getDate().before(datafim)){ mhm.put(msg.getAuthor().getName(), "EmptyUserReply"); } } } } Iterator it2 = mhm.keySet().iterator(); while(it2.hasNext()){ System.out.println("Retornando chaves:"+it2.next().toString()); } Iterator it = mhm.values().iterator(); while(it.hasNext()){ System.out.println("Retornando valores:"+it.next().toString()); } return (MultiValueMap) mhm; }
public MultiMap initEmbeddedPageActions() { if(embeddedPageActions == null) { MultiMap mm = new MultiHashMap(); Layout layout = pageInstance.getLayout(); for(ChildPage childPage : layout.getChildPages()) { String layoutContainerInParent = childPage.getContainer(); if(layoutContainerInParent != null) { String newPath = context.getActionPath() + "/" + childPage.getName(); File pageDir = new File(pageInstance.getChildrenDirectory(), childPage.getName()); try { Page page = DispatcherLogic.getPage(pageDir); EmbeddedPageAction embeddedPageAction = new EmbeddedPageAction( childPage.getName(), childPage.getActualOrder(), newPath, page); mm.put(layoutContainerInParent, embeddedPageAction); } catch (PageNotActiveException e) { logger.warn("Embedded page action is not active, skipping! " + pageDir, e); } } } for(Object entryObj : mm.entrySet()) { Map.Entry entry = (Map.Entry) entryObj; List pageActionContainer = (List) entry.getValue(); Collections.sort(pageActionContainer); } embeddedPageActions = mm; } return embeddedPageActions; }
/** * INTERNAL (undocumented) method * @param m * @param dest * @param superV */ protected void replaceWith(MultiMap m, Vertex dest, CollapsedVertex superV) { Collection c = (Collection) m.get(dest); for (Iterator iter = c.iterator(); iter.hasNext();) { m.put(superV, iter.next()); } m.remove(dest); }
/** * Adds all pairs (key, value) to the multimap from * the initial set keySet. * @param set * @param hyperEdge */ private static void addAll(MultiMap mm, Set keyset, Object value) { for (Iterator iter = keyset.iterator(); iter.hasNext();) { Object key = iter.next(); mm.put(key, value); } }
public void BeginTransformation() throws Exception { /** * 1. For each key in the _csvDataFromFile, check if the key exists in _mappedData <br> * 1a. If exists, get the pos and the colmnname <br> * 2. create SDTM record instance <br> * 2a. setRecord <br> * 3. print rec <br> */ SDTMRecord _sdtm = new SDTMRecord(); MultiMap mhm = new SDTM_CSVReader().readCSVFile(_csvFileName); // Iterate over the keys in the map Iterator it = mhm.keySet().iterator(); while (it.hasNext()) { // SDTMRecord _sdtm = new SDTMRecord(_csvDataFromFile); // Get key Object key = it.next(); if (_mappedData.containsKey(key)) { Collection coll = (Collection) mhm.get(key); for (Iterator it1 = coll.iterator(); it1.hasNext();) { Object mappedKey = it1.next(); StringBuffer _value = (StringBuffer) _mappedData.get(key); // System.out.println("=============================================="); // System.out.println("Mappedvalues " + _value); // System.out.println("CSVValues are " + mappedKey); StringTokenizer _level0 = new StringTokenizer(_value.toString(), ","); while (_level0.hasMoreTokens()) { StringTokenizer str = new StringTokenizer(_level0.nextToken(), "?"); int pos = new Integer(str.nextToken().substring(0, 2).trim()).intValue(); String dataKey = str.nextToken(); EmptyStringTokenizer emp = new EmptyStringTokenizer(mappedKey.toString(), ","); createRecord1(_sdtm, emp.getTokenAt(pos - 1).toString(), dataKey.replace('.', '_')); } } } } _sdtm.print(defineXMLList.toString(), _saveSDTMPath); }
/** * @return the groupEntityFields */ public MultiMap getGroupEntityFields() { return groupEntityFields; }
/** * @param groupEntityFields the groupEntityFields to set */ public void setGroupEntityFields(MultiMap groupEntityFields) { this.groupEntityFields = groupEntityFields; }
/** * @see MetadataHelper#getGroupedMetadata(Element,MultiMap,String) * @verifies group correctly */ @Test public void getGroupedMetadata_shouldGroupCorrectly() throws Exception { Map<String, List<Map<String, Object>>> fieldConfigurations = Configuration.getInstance().getFieldConfiguration(); List<Map<String, Object>> fieldInformation = fieldConfigurations.get("MD_AUTHOR"); Assert.assertNotNull(fieldInformation); Assert.assertEquals(1, fieldInformation.size()); Map<String, Object> fieldValues = fieldInformation.get(0); MultiMap groupEntity = (MultiMap) fieldValues.get("groupEntity"); Assert.assertNotNull(groupEntity); Document docMods = JDomXP.readXmlFile("resources/test/METS/aggregation_mods_test.xml"); Assert.assertNotNull(docMods); Assert.assertNotNull(docMods.getRootElement()); Element eleName = docMods.getRootElement().getChild("name", Configuration.getInstance().getNamespaces().get("mods")); Assert.assertNotNull(eleName); GroupedMetadata gmd = MetadataHelper.getGroupedMetadata(eleName, groupEntity, "label"); Assert.assertFalse(gmd.getFields().isEmpty()); Assert.assertEquals("label", gmd.getLabel()); Assert.assertEquals("display_form", gmd.getMainValue()); String label = null; String metadataType = null; String corporation = null; String lastName = null; String firstName = null; String displayForm = null; String groupField = null; String date = null; String termsOfAddress = null; String link = null; for (LuceneField field : gmd.getFields()) { switch (field.getField()) { case SolrConstants.METADATATYPE: metadataType = field.getValue(); break; case "LABEL": label = field.getValue(); break; case "MD_CORPORATION": corporation = field.getValue(); break; case "MD_LASTNAME": lastName = field.getValue(); break; case "MD_FIRSTNAME": firstName = field.getValue(); break; case "MD_DISPLAYFORM": displayForm = field.getValue(); break; case SolrConstants.GROUPFIELD: groupField = field.getValue(); break; case "MD_LIFEPERIOD": date = field.getValue(); break; case "MD_TERMSOFADDRESS": termsOfAddress = field.getValue(); break; case "MD_LINK": link = field.getValue(); break; } } Assert.assertEquals(MetadataGroupType.PERSON.name(), metadataType); Assert.assertEquals("corporate_name", corporation); Assert.assertEquals("last", lastName); Assert.assertEquals("first", firstName); Assert.assertEquals("display_form", displayForm); Assert.assertEquals("date", date); Assert.assertEquals("terms_of_address", termsOfAddress); Assert.assertEquals("xlink", link); Assert.assertEquals("label_display_form", groupField); }
@Override public MultiMap getConfigsByConfig() { return null; }
@Override public MultiMap initEmbeddedPageActions() { return null; }
public MultiMap getEmbeddedPageActions() { return embeddedPageActions; }
public String getParameterStringWithParameter(HttpServletRequest request, String parameterName, String parameterValue) { MultiMap parameters = getParameterMap(request); parameters.put(parameterName, parameterValue); return Utility.createQueryStringFromParameterMultiMap(parameters); }
public String cohesionGroup(ArrayList<String> actors, MultiMap interactions){ DirectedSparseMultigraph<String, String> graph = this.generateGhaph(actors, interactions); Collection<String> edges = graph.getEdges(); double numArcs = (double)edges.size(); double numActors = (double)actors.size(); double density = (numArcs / (numActors * (numActors - 1))); Double density1 = new Double(density); double p = Math.pow(10, 4); Double densityFormated = Math.round(density1 * p) / p; // Save graph this.saveGraph(graph); return this.reportCohesion(densityFormated.toString()); }
public String prestigePerStudent(ArrayList<String> actors, MultiMap interactions){ Map<String,Integer> indegreeValues = this.prestigeStudentsValued(actors, interactions); Map<String,Integer> sortedMap = this.sortMap(indegreeValues); // Save graph DirectedSparseMultigraph<String, String> graph = this.generateGhaph(actors, interactions); this.saveGraph(graph); return this.reportPrestige(sortedMap); }
public String engagementPerStudent(ArrayList<String> actors, MultiMap interactions){ Map<String,Integer> outdegreeValues = this.engagementStudentsValued(actors, interactions); Map<String,Integer> sortedMap = this.sortMap(outdegreeValues); // Save graph DirectedSparseMultigraph<String, String> graph = this.generateGhaph(actors, interactions); this.saveGraph(graph); return this.reportEngagement(sortedMap); }
public String heterogeneityGroup(ArrayList<String> actors, MultiMap interactions){ Map<String,Integer> outdegreeValues = this.outdegree(actors, interactions); Map<String,Integer> sortedMap = this.sortMap(outdegreeValues); Map<String,Double> visibilityResult = centralityPerStudent(sortedMap); Map<String,Double> biggerCentralityMinusCentralities = this.calculateDifferenceBetweenBiggerAndOthers(visibilityResult); Double heterogeneityDegree = this.calculateHeterogeneityDegree(biggerCentralityMinusCentralities); return this.reportHeterogeneity(heterogeneityDegree); }
public Map<String,Integer> indegree(ArrayList<String> actors, MultiMap interactions){ DirectedSparseMultigraph<String, String> graph = this.generateGhaph(actors, interactions); Collection<String> vertices = graph.getVertices(); Map<String,Integer> indegreeValue = new HashMap<String, Integer>(); int in; for (String student:vertices){ in = graph.inDegree(student); indegreeValue.put(student, in); } // Save graph this.saveGraph(graph); return indegreeValue; }
public Map<String,Integer> outdegree(ArrayList<String> actors, MultiMap interactions){ DirectedSparseMultigraph<String, String> graph = this.generateGhaph(actors, interactions); Collection<String> vertices = graph.getVertices(); Map<String,Integer> outdegreeValue = new HashMap<String, Integer>(); int in; for (String student:vertices){ in = graph.outDegree(student); outdegreeValue.put(student, in); } // Save graph this.saveGraph(graph); return outdegreeValue; }
public MultiMap getFunctionalizingentity() { return functionalizingentity; }
public void setFunctionalizingentity(MultiMap functionalizingentity) { this.functionalizingentity = functionalizingentity; }
public MultiMap getNanomaterialentity() { return nanomaterialentity; }
public void setNanomaterialentity(MultiMap nanomaterialentity) { this.nanomaterialentity = nanomaterialentity; }
public MultiMap getPointOfContactMap() { return pointOfContactMap; }
public void setPointOfContactMap(MultiMap pointOfContactMap) { this.pointOfContactMap = pointOfContactMap; }
public MultiMap getChemicalassociation() { return chemicalassociation; }