[mhk] r1088 committed - Acts and functions on server @mhk_families

1 view
Skip to first unread message

codesite...@google.com

unread,
Jun 29, 2013, 5:24:07 PM6/29/13
to mhk-dis...@googlegroups.com
Revision: 1088
Author: tbc...@gmail.com
Date: Sat Jun 29 14:23:44 2013
Log: Acts and functions on server @mhk_families
http://code.google.com/p/mhk/source/detail?r=1088

Modified:
/branches/mhk_families/idb/etc/template/new/create_source.vm
/branches/mhk_families/idb/pt/uc/cisuc/jrc/mhk/parser/SaveWebSource.java

=======================================
--- /branches/mhk_families/idb/etc/template/new/create_source.vm Sat Jun 29
13:19:41 2013
+++ /branches/mhk_families/idb/etc/template/new/create_source.vm Sat Jun 29
14:23:44 2013
@@ -179,7 +179,6 @@
if (box==false){
return;
}
-

##get act id
var i=row.parentNode.parentNode.rowIndex;
@@ -455,6 +454,8 @@
jsonDataObject.persons = persons;
jsonDataObject.attributes = attributes;
jsonDataObject.relations = relations;
+ jsonDataObject.acts = acts;
+ jsonDataObject.functions = functions;

##turn the jsonData object into a string so it can be passed to the
servlet
var jsonData = JSON.stringify(jsonDataObject);
=======================================
---
/branches/mhk_families/idb/pt/uc/cisuc/jrc/mhk/parser/SaveWebSource.java
Sat Jun 29 08:47:29 2013
+++
/branches/mhk_families/idb/pt/uc/cisuc/jrc/mhk/parser/SaveWebSource.java
Sat Jun 29 14:23:44 2013
@@ -18,8 +18,9 @@
//private int count_person_ocur;
private int count_relations;
private int count_individuals;
- //private int count_events;
+ private int count_events;
private String filename;
+ String sourceId;

public SaveWebSource() {}

@@ -27,7 +28,7 @@
count_attributes=1;
count_relations=1;
count_individuals=1;
- //count_events=1;
+ count_events=1;
//count_person_ocur=1;

//XML root
@@ -49,9 +50,8 @@
define_class=getRelationClass();
root.addContent(define_class);

-// define_class=getEventClass();
-// root.addContent(define_class);
-// writeRpt("[GedcomParser] Writing Event class...\n");
+ define_class=getEventClass();
+ root.addContent(define_class);

createXML(jsonData);

@@ -75,6 +75,8 @@
JSONArray persons_array = (JSONArray) jsonData.get("persons");
JSONArray relations_array = (JSONArray) jsonData.get("relations");
JSONArray attributes_array = (JSONArray)
jsonData.get("attributes");
+ JSONArray acts_array = (JSONArray) jsonData.get("acts");
+ JSONArray functions_array = (JSONArray) jsonData.get("functions");

this.filename=(String)source_obj.get("name");

@@ -82,10 +84,179 @@
writeIndividuals(persons_array);
writeAttributes(attributes_array);
writeRelations(relations_array);
+ writeActs(acts_array);
+ writeFunctions(functions_array);
+ }
+
+ private void writeActs(JSONArray acts){
+ for (int i=0;i<acts.size();i++){
+ JSONObject act = (JSONObject)acts.get(i);
+ Element attribute=new Element("GROUP");
+ String eventId="WEBSOURCE-"+this.filename+"-act-"+count_events;
+ String type=(String)act.get("type");
+ attribute.setAttribute("ID",eventId);
+ attribute.setAttribute("NAME",type);
+ attribute.setAttribute("CLASS","act");
+
+ Element s,core;
+
+ s=new Element("ELEMENT");
+ s.setAttribute("NAME","id");
+ s.setAttribute("CLASS","id");
+ core=new Element("core");
+ core.addContent(eventId);
+ s.addContent(core);
+ attribute.addContent(s);
+
+ s=new Element("ELEMENT");
+ s.setAttribute("NAME","groupname");
+ s.setAttribute("CLASS","groupname");
+ core=new Element("core");
+ core.addContent(type);
+ s.addContent(core);
+ attribute.addContent(s);
+
+ s=new Element("ELEMENT");
+ s.setAttribute("NAME","inside");
+ s.setAttribute("CLASS","inside");
+ core=new Element("core");
+ core.addContent(sourceId);
+ s.addContent(core);
+ attribute.addContent(s);
+
+ s=new Element("ELEMENT");
+ s.setAttribute("NAME","class");
+ s.setAttribute("CLASS","class");
+ core=new Element("core");
+ core.addContent("act");
+ s.addContent(core);
+ attribute.addContent(s);
+
+ String localization=(String)act.get("localization");
+ if(!localization.equals("")){
+ s=new Element("ELEMENT");
+ s.setAttribute("NAME","local");
+ s.setAttribute("CLASS","loc");
+ core=new Element("core");
+ core.addContent(localization);
+ s.addContent(core);
+ attribute.addContent(s);
+ }
+
+ String observation=(String)act.get("observation");
+ if(!observation.equals("")){
+ s=new Element("ELEMENT");
+ s.setAttribute("NAME","obs");
+ s.setAttribute("CLASS","obs");
+ core=new Element("core");
+ core.addContent(observation);
+ s.addContent(core);
+ attribute.addContent(s);
+ }
+
+ root.addContent(attribute);
+
+ count_events++;
+ }
+ }
+
+ private void writeFunctions(JSONArray functions){
+ for (int i=0;i<functions.size();i++){
+ JSONObject function = (JSONObject)functions.get(i);
+ Element attribute=new Element("GROUP");
+ String
relationId="WEBSOURCE-"+this.filename+"-relation-"+count_relations;
+ attribute.setAttribute("ID",relationId);
+ attribute.setAttribute("NAME","relation");
+ attribute.setAttribute("CLASS","relation");
+
+ String
individualId="WEBSOURCE-"+this.filename+"-person-"+(String)function.get("origin");
+
+ Element s,core;
+
+ s=new Element("ELEMENT");
+ s.setAttribute("NAME","groupname");
+ s.setAttribute("CLASS","groupname");
+ core=new Element("core");
+ core.addContent("relation");
+ s.addContent(core);
+ attribute.addContent(s);
+
+ s=new Element("ELEMENT");
+ s.setAttribute("NAME","inside");
+ s.setAttribute("CLASS","inside");
+ core=new Element("core");
+ core.addContent(individualId);
+ s.addContent(core);
+ attribute.addContent(s);
+
+ s=new Element("ELEMENT");
+ s.setAttribute("NAME","class");
+ s.setAttribute("CLASS","class");
+ core=new Element("core");
+ core.addContent("relation");
+ s.addContent(core);
+ attribute.addContent(s);
+
+ s=new Element("ELEMENT");
+ s.setAttribute("NAME","tipo");
+ s.setAttribute("CLASS","type");
+ core=new Element("core");
+ core.addContent("function-in-act");
+ s.addContent(core);
+ attribute.addContent(s);
+
+ String destname=(String)function.get("destname");
+ if(!destname.equals("")){
+ s=new Element("ELEMENT");
+ s.setAttribute("NAME","destname");
+ s.setAttribute("CLASS","destname");
+ core=new Element("core");
+ core.addContent(destname);
+ s.addContent(core);
+ attribute.addContent(s);
+ }
+
+ s=new Element("ELEMENT");
+ s.setAttribute("NAME","origin");
+ s.setAttribute("CLASS","origin");
+ core=new Element("core");
+ core.addContent(individualId);
+ s.addContent(core);
+ attribute.addContent(s);
+
+ String
actId="WEBSOURCE-"+this.filename+"-act-"+(String)function.get("act_id");
+ s=new Element("ELEMENT");
+ s.setAttribute("NAME","destination");
+ s.setAttribute("CLASS","destination");
+ core=new Element("core");
+ core.addContent(actId);
+ s.addContent(core);
+ attribute.addContent(s);
+
+ s=new Element("ELEMENT");
+ s.setAttribute("NAME","id");
+ s.setAttribute("CLASS","id");
+ core=new Element("core");
+ core.addContent(relationId);
+ s.addContent(core);
+ attribute.addContent(s);
+
+ s=new Element("ELEMENT");
+ s.setAttribute("NAME","value");
+ s.setAttribute("CLASS","value");
+ core=new Element("core");
+ core.addContent((String)function.get("value"));
+ s.addContent(core);
+ attribute.addContent(s);
+
+ root.addContent(attribute);
+
+ count_relations++;
+ }
}

private void writeSource(JSONObject source_obj){
- String sourceId="WEBSOURCE-"+this.filename;
+ sourceId="WEBSOURCE-"+this.filename;
Element source=new Element("GROUP");
source.setAttribute("ID",sourceId);
source.setAttribute("NAME","web_fonte");
@@ -165,7 +336,6 @@
individual.setAttribute("NAME","n");
individual.setAttribute("CLASS","person");
individual.setAttribute("GROUP","n");
- individual.setAttribute("LEVEL","0");

s=new Element("ELEMENT");
s.setAttribute("NAME","id");
@@ -199,14 +369,6 @@
s.addContent(core);
individual.addContent(s);

- s=new Element("ELEMENT");
- s.setAttribute("NAME","level");
- s.setAttribute("CLASS","level");
- core=new Element("core");
- core.addContent("0");
- s.addContent(core);
- individual.addContent(s);
-
s=new Element("ELEMENT");
s.setAttribute("NAME","nome");
s.setAttribute("CLASS","name");
Reply all
Reply to author
Forward
0 new messages