[mhk] r1072 committed - Dynamic tree level @mhk_families

1 view
Skip to first unread message

codesite...@google.com

unread,
May 27, 2013, 8:07:33 PM5/27/13
to mhk-dis...@googlegroups.com
Revision: 1072
Author: tbc...@gmail.com
Date: Mon May 27 17:06:48 2013
Log: Dynamic tree level @mhk_families
http://code.google.com/p/mhk/source/detail?r=1072

Deleted:
/branches/mhk_families/idb/pt/uc/cisuc/jrc/mhk/parser/Gedcom551ToXml.java
Modified:

/branches/mhk_families/idb/pt/uc/cisuc/jrc/mhk/geneology/FamilyManagement.java
/branches/mhk_families/idb/pt/uc/cisuc/jrc/mhk/servlet/DoExecFamily.java

=======================================
---
/branches/mhk_families/idb/pt/uc/cisuc/jrc/mhk/parser/Gedcom551ToXml.java
Fri Mar 8 08:55:20 2013
+++ /dev/null
@@ -1,2467 +0,0 @@
-//
-// Gedcom551ToXml.java
-// idb
-//
-// Created by Tiago Ceia on Mar 05 2013.
-package pt.uc.cisuc.jrc.mhk.parser;
-
-import java.io.FileWriter;
-import java.io.IOException;
-import org.xml.sax.SAXException;
-import java.util.HashMap;
-import org.gedcom4j.model.Family;
-import org.gedcom4j.model.Individual;
-import org.gedcom4j.parser.GedcomParser;
-import org.gedcom4j.parser.GedcomParserException;
-import org.jdom2.Document;
-import org.jdom2.Element;
-import org.jdom2.output.Format;
-import org.jdom2.output.XMLOutputter;
-
-/** Translates a Gedcom 5.5.1 or 5.5 file to a XML format consistent with
the Kleio translation
-*/
-public class Gedcom551ToXml extends SAXException {
- private GedcomParser gp;
- private HashMap <String,String> id_dictionary=new
HashMap<String,String>();
- private HashMap <String,String> sex_dictionary=new
HashMap<String,String>();
-
- public Gedcom551ToXml(){}
-
- public void gedcom551ToXML(String path,String filename){
-
- gp=new GedcomParser();
- try {
- gp.load(path+"\\"+filename);
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (GedcomParserException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- filename=filename.substring(0,filename.length()-4);
- Element root = new Element("KLEIO");
- root.setAttribute("STRUCTURE","GEDCOM");
- root.setAttribute("SOURCE",path+"\\"+filename);
-
-
- //criação do XML
-
- //-------------------------------------------------------------getSource
- Element source_class=getSourceClass();
- root.addContent(source_class);
- String sourceId="GEDCOM-"+filename;
-
- Element source=new Element("GROUP");
-
source.setAttribute("source_data",gp.gedcom.header.sourceSystem.sourceData.name);
- source.setAttribute("ID","GEDCOM-"+filename);
- source.setAttribute("NAME","gedcom_fonte");
- source.setAttribute("CLASS","source");
- source.setAttribute("ORDER","1");
- source.setAttribute("LEVEL","1");
- source.setAttribute("LINE","0");
-
- Element s=new Element("ELEMENT");
- s.setAttribute("NAME","line");
- s.setAttribute("CLASS","line");
- Element core=new Element("core");
- core.addContent("0");
- s.addContent(core);
-
- source.addContent(s);
-
- s=new Element("ELEMENT");
- s.setAttribute("NAME","id");
- s.setAttribute("CLASS","id");
- core=new Element("core");
- core.addContent(sourceId);
- s.addContent(core);
-
- source.addContent(s);
-
- s=new Element("ELEMENT");
- s.setAttribute("NAME","groupname");
- s.setAttribute("CLASS","groupname");
- core=new Element("core");
- core.addContent("gedcom_source");
- s.addContent(core);
-
- source.addContent(s);
-
- s=new Element("ELEMENT");
- s.setAttribute("NAME","inside");
- s.setAttribute("CLASS","inside");
- core=new Element("core");
- core.addContent("root");
- s.addContent(core);
-
- source.addContent(s);
-
- s=new Element("ELEMENT");
- s.setAttribute("NAME","class");
- s.setAttribute("CLASS","class");
- core=new Element("core");
- core.addContent("source");
- s.addContent(core);
-
- source.addContent(s);
-
- s=new Element("ELEMENT");
- s.setAttribute("NAME","order");
- s.setAttribute("CLASS","order");
- core=new Element("core");
- core.addContent("1");
- s.addContent(core);
-
- source.addContent(s);
-
- s=new Element("ELEMENT");
- s.setAttribute("NAME","level");
- s.setAttribute("CLASS","level");
- core=new Element("core");
- core.addContent("1");
- s.addContent(core);
-
- source.addContent(s);
-
- if(gp.gedcom.header.date!=null){
- s=new Element("ELEMENT");
- s.setAttribute("NAME","date");
- s.setAttribute("CLASS","date");
- core=new Element("core");
- core.addContent(gp.gedcom.header.date.value);
- s.addContent(core);
-
- source.addContent(s);
- }
-
-
- s=new Element("ELEMENT");
- s.setAttribute("NAME","kleiofile");
- s.setAttribute("CLASS","kleiofile");
- core=new Element("core");
- core.addContent(filename);
- s.addContent(core);
-
- source.addContent(s);
-
- s=new Element("ELEMENT");
- s.setAttribute("NAME","type");
- s.setAttribute("CLASS","type");
- core=new Element("core");
- core.addContent("GEDCOM");
- s.addContent(core);
- source.addContent(s);
-
- if(!gp.gedcom.header.notes.isEmpty()){
- s=new Element("ELEMENT");
- s.setAttribute("NAME","obs");
- s.setAttribute("CLASS","obs");
- core=new Element("core");
- core.addContent(gp.gedcom.header.notes.get(0));
- s.addContent(core);
- source.addContent(s);
- }
-
- if(gp.gedcom.header.sourceSystem!=null &&
gp.gedcom.header.sourceSystem.sourceData!=null){
- s=new Element("ELEMENT");
- s.setAttribute("NAME","ref");
- s.setAttribute("CLASS","ref");
- core=new Element("core");
- core.addContent(gp.gedcom.header.sourceSystem.sourceData.name);
- s.addContent(core);
- source.addContent(s);
- }
-
- root.addContent(source);
-
- //----------------------GET INDIVIDUALS, THEIR ATTRIBUTES AND EVENTS
- Element individual_class=getIndividualClass();
- root.addContent(individual_class);
-
- int count_individuals=1;
- int count_attributes=1;
- int count_relations=1;
- int count_events=1;
- int count_person_ocur=1;
- for(Individual i : gp.gedcom.individuals.values()){
- Element individuals=new Element("GROUP");
- String individualId=filename+"-person-"+count_individuals;
- id_dictionary.put(i.xref,individualId);
- individuals.setAttribute("ID",individualId);
- individuals.setAttribute("NAME","n");
- individuals.setAttribute("CLASS","person");
- individuals.setAttribute("GROUP","n");
- individuals.setAttribute("ORDER","0");
- individuals.setAttribute("LEVEL","0");
- individuals.setAttribute("LINE","0");
-
- s=new Element("ELEMENT");
- s.setAttribute("NAME","line");
- s.setAttribute("CLASS","line");
- core=new Element("core");
- core.addContent("0");
- s.addContent(core);
-
- individuals.addContent(s);
-
- s=new Element("ELEMENT");
- s.setAttribute("NAME","id");
- s.setAttribute("CLASS","id");
- core=new Element("core");
- core.addContent(individualId);
- s.addContent(core);
-
- individuals.addContent(s);
-
- s=new Element("ELEMENT");
- s.setAttribute("NAME","groupname");
- s.setAttribute("CLASS","groupname");
- core=new Element("core");
- core.addContent("n");
- s.addContent(core);
-
- individuals.addContent(s);
-
- s=new Element("ELEMENT");
- s.setAttribute("NAME","inside");
- s.setAttribute("CLASS","inside");
- core=new Element("core");
- core.addContent(filename);
- s.addContent(core);
-
- individuals.addContent(s);
-
- s=new Element("ELEMENT");
- s.setAttribute("NAME","class");
- s.setAttribute("CLASS","class");
- core=new Element("core");
- core.addContent("person");
- s.addContent(core);
-
- individuals.addContent(s);
-
- s=new Element("ELEMENT");
- s.setAttribute("NAME","order");
- s.setAttribute("CLASS","order");
- core=new Element("core");
- core.addContent("0");
- s.addContent(core);
-
- individuals.addContent(s);
-
- s=new Element("ELEMENT");
- s.setAttribute("NAME","level");
- s.setAttribute("CLASS","level");
- core=new Element("core");
- core.addContent("0");
- s.addContent(core);
-
- individuals.addContent(s);
-
- for(int j=0;j<i.names.size();j++){//define just one name, we test
all in case of no basic name
- if(i.names.get(j).basic!=null){
- s=new Element("ELEMENT");
- s.setAttribute("NAME","nome");
- s.setAttribute("CLASS","name");
- core=new Element("core");
- core.addContent(i.names.get(j).basic);
- s.addContent(core);
- individuals.addContent(s);
- break;
- }
- if(i.names.get(j).nickname!=null){
- s=new Element("ELEMENT");
- s.setAttribute("NAME","nome");
- s.setAttribute("CLASS","name");
- core=new Element("core");
- core.addContent(i.names.get(j).nickname.value);
- s.addContent(core);
- individuals.addContent(s);
- break;
- }
- if(i.names.get(j).givenName!=null){
- s=new Element("ELEMENT");
- s.setAttribute("NAME","nome");
- s.setAttribute("CLASS","name");
- core=new Element("core");
- core.addContent(i.names.get(j).givenName.value);
- s.addContent(core);
- individuals.addContent(s);
- break;
- }
- if(i.names.get(j).surname!=null){
- s=new Element("ELEMENT");
- s.setAttribute("NAME","nome");
- s.setAttribute("CLASS","name");
- core=new Element("core");
- core.addContent(i.names.get(j).surname.value);
- s.addContent(core);
- individuals.addContent(s);
- break;
- }
- }
-
- if(i.sex!=null){
- sex_dictionary.put(i.xref+"-sex", i.sex.value);
- s=new Element("ELEMENT");
- s.setAttribute("NAME","sex");
- s.setAttribute("CLASS","sex");
- core=new Element("core");
- core.addContent(i.sex.value);
- s.addContent(core);
- individuals.addContent(s);
- }
-
- root.addContent(individuals);
-
-
- //---------------GET INDIVIDUAL ATTRIBUTES
- if(!i.attributes.isEmpty()){
- if(count_attributes==1){
- Element attribute_class=getAttributeClass();
- root.addContent(attribute_class);
- }
- for(int j=0;j<i.attributes.size();j++){
-
- Element attribute=new Element("GROUP");
- String attributeId=filename+"-attribute-"+count_attributes;
- attribute.setAttribute("ID",attributeId);
- attribute.setAttribute("NAME","ls");
- attribute.setAttribute("CLASS","attribute");
- attribute.setAttribute("ORDER","5");
- attribute.setAttribute("LEVEL","4");
- attribute.setAttribute("LINE","0");
-
- s=new Element("ELEMENT");
- s.setAttribute("NAME","line");
- s.setAttribute("CLASS","line");
- core=new Element("core");
- core.addContent("0");
- s.addContent(core);
- attribute.addContent(s);
-
- s=new Element("ELEMENT");
- s.setAttribute("NAME","id");
- s.setAttribute("CLASS","id");
- core=new Element("core");
- core.addContent(attributeId);
- s.addContent(core);
- attribute.addContent(s);
-
- s=new Element("ELEMENT");
- s.setAttribute("NAME","groupname");
- s.setAttribute("CLASS","groupname");
- core=new Element("core");
- core.addContent("ls");
- 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("attribute");
- s.addContent(core);
- attribute.addContent(s);
-
- s=new Element("ELEMENT");
- s.setAttribute("NAME","order");
- s.setAttribute("CLASS","order");
- core=new Element("core");
- core.addContent("0");
- s.addContent(core);
- attribute.addContent(s);
-
- s=new Element("ELEMENT");
- s.setAttribute("NAME","level");
- s.setAttribute("CLASS","level");
- core=new Element("core");
- core.addContent("0");
- s.addContent(core);
- attribute.addContent(s);
-
- if(i.attributes.get(j).type!=null &&
i.attributes.get(j).description!=null){
- s=new Element("ELEMENT");
- s.setAttribute("NAME","tipo");
- s.setAttribute("CLASS","type");
- core=new Element("core");
- core.addContent(i.attributes.get(j).type.display);
- s.addContent(core);
- attribute.addContent(s);
-
- s=new Element("ELEMENT");
- s.setAttribute("NAME","valor");
- s.setAttribute("CLASS","value");
- core=new Element("core");
- core.addContent(i.attributes.get(j).description.value);
- s.addContent(core);
- attribute.addContent(s);
- }
-
- s=new Element("ELEMENT");
- s.setAttribute("NAME","entity");
- s.setAttribute("CLASS","entity");
- core=new Element("core");
- core.addContent(individualId);
- s.addContent(core);
- attribute.addContent(s);
-
- s=new Element("ELEMENT");
- s.setAttribute("NAME","date");
- s.setAttribute("CLASS","date");
- core=new Element("core");
- core.addContent("0");
- s.addContent(core);
- attribute.addContent(s);
-
- count_attributes++;
- root.addContent(attribute);
- }
- //---------------END GET INDIVIDUAL ATTRIBUTES
-
- //----------------------CHECK FOR MORE ATTRUBUTES
- HashMap<String,String> attributes=new HashMap<String,String>();
- for(int j=0;j<i.attributes.size();j++){
- if(i.attributes.get(j).place!=null)
- attributes.put("place "+j, "place "+j);
- if(i.attributes.get(j).respAgency!=null)
- attributes.put("agency "+j, "agency "+j);
- if(i.attributes.get(j).cause!=null)
- attributes.put("cause "+j, "cause "+j);
- if(i.attributes.get(j).address!=null){
- if(i.attributes.get(j).address.country!=null)
- attributes.put("country "+j, "country "+j);
- if(i.attributes.get(j).address.city!=null)
- attributes.put("city "+j, "city "+j);
- if(i.attributes.get(j).address.addr1!=null)
- attributes.put("address1 "+j, "address1 "+j);
- if(i.attributes.get(j).address.addr2!=null)
- attributes.put("address2 "+j, "address2 "+j);
- if(i.attributes.get(j).address.postalCode!=null)
- attributes.put("postalcode "+j, "postalcode "+j);
- if(i.attributes.get(j).address.stateProvince!=null)
- attributes.put("stateprovidence "+j, "stateprovidence "+j);
- }
- for(int k=0;k<i.attributes.get(j).emails.size();k++)
- attributes.put("emails "+j+" "+k, "emails "+j+" "+k);
- for (int k=0;k<i.attributes.get(j).phoneNumbers.size();k++)
-
attributes.put("phoneNumbers "+j+" "+k, "phoneNumbers "+j+" "+k);
- for (int k=0;k<i.attributes.get(j).notes.size();k++)
- attributes.put("notes "+j+" "+k, "notes "+j+" "+k);
- for (int k=0;k<i.attributes.get(j).faxNumbers.size();k++)
- attributes.put("faxnumbers "+j+" "+k, "faxnumbers "+j+" "+k);
- }
- for(int j=0;j<i.names.size();j++){
- if(i.names.get(j).nickname!=null)
- attributes.put("nickname "+j,"nickname "+j);
- if(i.names.get(j).givenName!=null)
- attributes.put("givenName "+j,"givenName "+j);
- if(i.names.get(j).surname!=null)
- attributes.put("surname "+j,"surname "+j);
- }
-
- for(int j=0;j<i.aliases.size();j++){
- if(i.aliases.get(j).value!=null)
- attributes.put("alias "+j,"alias "+j);
- }
-
- if(!i.attributes.isEmpty()){
- if(i.attributes.get(0).age!=null)
- attributes.put("age","age");
- }
- //-----------------------------------END CHECK FOR MORE ATTRIBUTES
-
- //-----------------------------------GET MORE INDIVUDUAL ATTRIBUTES IF
DETECTED ON CHECK
- if(count_attributes==1 && !attributes.isEmpty()){
- Element attribute_class=getAttributeClass();
- root.addContent(attribute_class);
- }
- for(String type : attributes.values()){
- Element attribute=new Element("GROUP");
- String attributeId=filename+"-attribute-"+count_attributes;
- attribute.setAttribute("ID",attributeId);
- attribute.setAttribute("NAME","ls");
- attribute.setAttribute("CLASS","attribute");
- attribute.setAttribute("ORDER","0");
- attribute.setAttribute("LEVEL","0");
- attribute.setAttribute("LINE","0");
-
- s=new Element("ELEMENT");
- s.setAttribute("NAME","line");
- s.setAttribute("CLASS","line");
- core=new Element("core");
- core.addContent("0");
- s.addContent(core);
- attribute.addContent(s);
-
- s=new Element("ELEMENT");
- s.setAttribute("NAME","id");
- s.setAttribute("CLASS","id");
- core=new Element("core");
- core.addContent(attributeId);
- s.addContent(core);
- attribute.addContent(s);
-
- s=new Element("ELEMENT");
- s.setAttribute("NAME","groupname");
- s.setAttribute("CLASS","groupname");
- core=new Element("core");
- core.addContent("ls");
- 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("attribute");
- s.addContent(core);
- attribute.addContent(s);
-
- s=new Element("ELEMENT");
- s.setAttribute("NAME","order");
- s.setAttribute("CLASS","order");
- core=new Element("core");
- core.addContent("0");
- s.addContent(core);
- attribute.addContent(s);
-
- s=new Element("ELEMENT");
- s.setAttribute("NAME","level");
- s.setAttribute("CLASS","level");
- core=new Element("core");
- core.addContent("0");
- s.addContent(core);
- attribute.addContent(s);
-
- s=new Element("ELEMENT");
- s.setAttribute("NAME","entity");
- s.setAttribute("CLASS","entity");
- core=new Element("core");
- core.addContent(individualId);
- s.addContent(core);
- attribute.addContent(s);
-
- s=new Element("ELEMENT");
- s.setAttribute("NAME","date");
- s.setAttribute("CLASS","date");
- core=new Element("core");
- core.addContent("0");
- s.addContent(core);
- attribute.addContent(s);
-
- if(type.contains("place")){
- s=new Element("ELEMENT");
- s.setAttribute("NAME","valor");
- s.setAttribute("CLASS","value");
- core=new Element("core");
- String [] substrings=type.split(" ");
-
core.addContent(i.attributes.get(Integer.parseInt(substrings[1])).place.placeName);
- s.addContent(core);
- attribute.addContent(s);
-
- s=new Element("ELEMENT");
- s.setAttribute("NAME","tipo");
- s.setAttribute("CLASS","type");
- core=new Element("core");
- core.addContent("Place");
- s.addContent(core);
- attribute.addContent(s);
-
- count_attributes++;
- root.addContent(attribute);
- }
- else if(type.contains("agency")){
- s=new Element("ELEMENT");
- s.setAttribute("NAME","valor");
- s.setAttribute("CLASS","value");
- core=new Element("core");
- String [] substrings=type.split(" ");
-
core.addContent(i.attributes.get(Integer.parseInt(substrings[1])).respAgency.value);
- s.addContent(core);
- attribute.addContent(s);
-
- s=new Element("ELEMENT");
- s.setAttribute("NAME","tipo");
- s.setAttribute("CLASS","type");
- core=new Element("core");
- core.addContent("Agency");
- s.addContent(core);
- attribute.addContent(s);
-
- count_attributes++;
- root.addContent(attribute);
- }
-
- else if(type.contains("cause")){
- s=new Element("ELEMENT");
- s.setAttribute("NAME","valor");
- s.setAttribute("CLASS","value");
- core=new Element("core");
- String [] substrings=type.split(" ");
-
core.addContent(i.attributes.get(Integer.parseInt(substrings[1])).cause.value);
- s.addContent(core);
- attribute.addContent(s);
-
- s=new Element("ELEMENT");
- s.setAttribute("NAME","tipo");
- s.setAttribute("CLASS","type");
- core=new Element("core");
- core.addContent("Cause");
- s.addContent(core);
- attribute.addContent(s);
-
- count_attributes++;
- root.addContent(attribute);
- }
-
- else if(type.contains("country")){
- s=new Element("ELEMENT");
- s.setAttribute("NAME","valor");
- s.setAttribute("CLASS","value");
- core=new Element("core");
- String [] substrings=type.split(" ");
-
core.addContent(i.attributes.get(Integer.parseInt(substrings[1])).address.country.value);
- s.addContent(core);
- attribute.addContent(s);
-
- s=new Element("ELEMENT");
- s.setAttribute("NAME","tipo");
- s.setAttribute("CLASS","type");
- core=new Element("core");
- core.addContent("Country");
- s.addContent(core);
- attribute.addContent(s);
-
- count_attributes++;
- root.addContent(attribute);
- }
-
- else if(type.contains("city")){
- s=new Element("ELEMENT");
- s.setAttribute("NAME","valor");
- s.setAttribute("CLASS","value");
- core=new Element("core");
- String [] substrings=type.split(" ");
-
core.addContent(i.attributes.get(Integer.parseInt(substrings[1])).address.city.value);
- s.addContent(core);
- attribute.addContent(s);
-
- s=new Element("ELEMENT");
- s.setAttribute("NAME","tipo");
- s.setAttribute("CLASS","type");
- core=new Element("core");
- core.addContent("City");
- s.addContent(core);
- attribute.addContent(s);
- count_attributes++;
- root.addContent(attribute);
- }
-
- else if(type.contains("address1")){
- s=new Element("ELEMENT");
- s.setAttribute("NAME","valor");
- s.setAttribute("CLASS","value");
- core=new Element("core");
- String [] substrings=type.split(" ");
-
core.addContent(i.attributes.get(Integer.parseInt(substrings[1])).address.addr1.value);
- s.addContent(core);
- attribute.addContent(s);
-
- s=new Element("ELEMENT");
- s.setAttribute("NAME","tipo");
- s.setAttribute("CLASS","type");
- core=new Element("core");
- core.addContent("Address");
- s.addContent(core);
- attribute.addContent(s);
-
- count_attributes++;
- root.addContent(attribute);
- }
- else if(type.contains("address2")){
- s=new Element("ELEMENT");
- s.setAttribute("NAME","valor");
- s.setAttribute("CLASS","value");
- core=new Element("core");
- String [] substrings=type.split(" ");
-
core.addContent(i.attributes.get(Integer.parseInt(substrings[1])).address.addr2.value);
- s.addContent(core);
- attribute.addContent(s);
-
- s=new Element("ELEMENT");
- s.setAttribute("NAME","tipo");
- s.setAttribute("CLASS","type");
- core=new Element("core");
- core.addContent("Address");
- s.addContent(core);
- attribute.addContent(s);
-
- count_attributes++;
- root.addContent(attribute);
- }
- else if(type.contains("postalcode")){
- s=new Element("ELEMENT");
- s.setAttribute("NAME","valor");
- s.setAttribute("CLASS","value");
- core=new Element("core");
- String [] substrings=type.split(" ");
-
core.addContent(i.attributes.get(Integer.parseInt(substrings[1])).address.postalCode.value);
- s.addContent(core);
- attribute.addContent(s);
-
- s=new Element("ELEMENT");
- s.setAttribute("NAME","tipo");
- s.setAttribute("CLASS","type");
- core=new Element("core");
- core.addContent("Postal Code");
- s.addContent(core);
- attribute.addContent(s);
-
- count_attributes++;
- root.addContent(attribute);
- }
-
- else if(type.contains("stateprovidence")){
- s=new Element("ELEMENT");
- s.setAttribute("NAME","valor");
- s.setAttribute("CLASS","value");
- core=new Element("core");
- String [] substrings=type.split(" ");
-
core.addContent(i.attributes.get(Integer.parseInt(substrings[1])).address.stateProvince.value);
- s.addContent(core);
- attribute.addContent(s);
-
- s=new Element("ELEMENT");
- s.setAttribute("NAME","tipo");
- s.setAttribute("CLASS","type");
- core=new Element("core");
- core.addContent("State Providence");
- s.addContent(core);
- attribute.addContent(s);
-
- count_attributes++;
- root.addContent(attribute);
- }
- else if(type.contains("alias")){
- s=new Element("ELEMENT");
- s.setAttribute("NAME","valor");
- s.setAttribute("CLASS","value");
- core=new Element("core");
- String [] substrings=type.split(" ");
-
//System.out.println(i.aliases.get(Integer.parseInt(substring)).value);
-
core.addContent(i.aliases.get(Integer.parseInt(substrings[1])).value);
- s.addContent(core);
- attribute.addContent(s);
-
- s=new Element("ELEMENT");
- s.setAttribute("NAME","tipo");
- s.setAttribute("CLASS","type");
- core=new Element("core");
- core.addContent("Alias");
- s.addContent(core);
- attribute.addContent(s);
-
- count_attributes++;
- root.addContent(attribute);
- }
- else if(type.contains("nickname")){
- s=new Element("ELEMENT");
- s.setAttribute("NAME","valor");
- s.setAttribute("CLASS","value");
- core=new Element("core");
- String [] substrings=type.split(" ");
-
//System.out.println(i.aliases.get(Integer.parseInt(substring)).value);
-
core.addContent(i.names.get(Integer.parseInt(substrings[1])).nickname.value);
- s.addContent(core);
- attribute.addContent(s);
-
- s=new Element("ELEMENT");
- s.setAttribute("NAME","tipo");
- s.setAttribute("CLASS","type");
- core=new Element("core");
- core.addContent("Nickname");
- s.addContent(core);
- attribute.addContent(s);
-
- count_attributes++;
- root.addContent(attribute);
- }
- else if(type.contains("givenName")){
- s=new Element("ELEMENT");
- s.setAttribute("NAME","valor");
- s.setAttribute("CLASS","value");
- core=new Element("core");
- String [] substrings=type.split(" ");
-
//System.out.println(i.aliases.get(Integer.parseInt(substring)).value);
-
core.addContent(i.names.get(Integer.parseInt(substrings[1])).givenName.value);
- s.addContent(core);
- attribute.addContent(s);
-
- s=new Element("ELEMENT");
- s.setAttribute("NAME","tipo");
- s.setAttribute("CLASS","type");
- core=new Element("core");
- core.addContent("Given Name");
- s.addContent(core);
- attribute.addContent(s);
-
- count_attributes++;
- root.addContent(attribute);
- }
- else if(type.contains("surname")){
- s=new Element("ELEMENT");
- s.setAttribute("NAME","valor");
- s.setAttribute("CLASS","value");
- core=new Element("core");
- String [] substrings=type.split(" ");
-
//System.out.println(i.names.get(Integer.parseInt(substring)).surname.value);
-
core.addContent(i.names.get(Integer.parseInt(substrings[1])).surname.value);
- s.addContent(core);
- attribute.addContent(s);
-
- s=new Element("ELEMENT");
- s.setAttribute("NAME","tipo");
- s.setAttribute("CLASS","type");
- core=new Element("core");
- core.addContent("SurName");
- s.addContent(core);
- attribute.addContent(s);
-
- count_attributes++;
- root.addContent(attribute);
- }
- else if(type.contains("emails")){
- s=new Element("ELEMENT");
- s.setAttribute("NAME","valor");
- s.setAttribute("CLASS","value");
- core=new Element("core");
- String [] substrings=type.split(" ");
-
//System.out.println(i.names.get(Integer.parseInt(substring)).surname.value);
-
core.addContent(i.attributes.get(Integer.parseInt(substrings[1])).emails.get(Integer.parseInt(substrings[2])).value);
- s.addContent(core);
- attribute.addContent(s);
-
- s=new Element("ELEMENT");
- s.setAttribute("NAME","tipo");
- s.setAttribute("CLASS","type");
- core=new Element("core");
- core.addContent("Email");
- s.addContent(core);
- attribute.addContent(s);
-
- count_attributes++;
- root.addContent(attribute);
- }
- else if(type.contains("phoneNumbers")){
- s=new Element("ELEMENT");
- s.setAttribute("NAME","valor");
- s.setAttribute("CLASS","value");
- core=new Element("core");
- String [] substrings=type.split(" ");
-
//System.out.println(i.names.get(Integer.parseInt(substring)).surname.value);
-
core.addContent(i.attributes.get(Integer.parseInt(substrings[1])).phoneNumbers.get(Integer.parseInt(substrings[2])).value);
- s.addContent(core);
- attribute.addContent(s);
-
- s=new Element("ELEMENT");
- s.setAttribute("NAME","tipo");
- s.setAttribute("CLASS","type");
- core=new Element("core");
- core.addContent("Phone Number");
- s.addContent(core);
- attribute.addContent(s);
-
- count_attributes++;
- root.addContent(attribute);
- }
- else if(type.contains("notes")){
- s=new Element("ELEMENT");
- s.setAttribute("NAME","valor");
- s.setAttribute("CLASS","value");
- core=new Element("core");
- String [] substrings=type.split(" ");
-
core.addContent(i.attributes.get(Integer.parseInt(substrings[1])).notes.get(Integer.parseInt(substrings[2])).lines.toString());
- s.addContent(core);
- attribute.addContent(s);
-
- s=new Element("ELEMENT");
- s.setAttribute("NAME","tipo");
- s.setAttribute("CLASS","type");
- core=new Element("core");
- core.addContent("Note");
- s.addContent(core);
- attribute.addContent(s);
-
- count_attributes++;
- root.addContent(attribute);
- }
- else if(type.contains("faxnumbers")){
- s=new Element("ELEMENT");
- s.setAttribute("NAME","valor");
- s.setAttribute("CLASS","value");
- core=new Element("core");
- String [] substrings=type.split(" ");
-
core.addContent(i.attributes.get(Integer.parseInt(substrings[1])).faxNumbers.get(Integer.parseInt(substrings[2])).value);
- s.addContent(core);
- attribute.addContent(s);
-
- s=new Element("ELEMENT");
- s.setAttribute("NAME","tipo");
- s.setAttribute("CLASS","type");
- core=new Element("core");
- core.addContent("Fax Number");
- s.addContent(core);
- attribute.addContent(s);
-
- count_attributes++;
- root.addContent(attribute);
- }
- else if(type.equals("age")){
- s=new Element("ELEMENT");
- s.setAttribute("NAME","valor");
- s.setAttribute("CLASS","value");
- core=new Element("core");
- core.addContent(i.attributes.get(0).age.value);
- s.addContent(core);
- attribute.addContent(s);
-
- s=new Element("ELEMENT");
- s.setAttribute("NAME","tipo");
- s.setAttribute("CLASS","type");
- core=new Element("core");
- core.addContent("Age");
- s.addContent(core);
- attribute.addContent(s);
-
- count_attributes++;
- root.addContent(attribute);
- }
- }
- }
- //--------------------------END MORE INDIVUDUAL ATTRIBUTES IF
DETECTED ON CHECK
-
-
//-----------------------------------------------------------------GET
INDIVIDUAL EVENTS IF ANY AND TREAT THEM LIKE EVENTS, GET FUNCTIONS IN ACT
- if(!i.events.isEmpty()){
- if(count_events==1){
- Element event_class=getEventClass();
- root.addContent(event_class);
- }
- for(int j=0;j<i.events.size();j++){
- Element attribute=new Element("GROUP");
- String eventId=filename+"-act-"+count_events;
- attribute.setAttribute("ID",eventId);
- attribute.setAttribute("NAME",i.events.get(j).type.display);
- attribute.setAttribute("CLASS","act");
-
- 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("act");
- 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");
***The diff for this file has been truncated for email.***
=======================================
---
/branches/mhk_families/idb/pt/uc/cisuc/jrc/mhk/geneology/FamilyManagement.java
Tue May 21 10:39:41 2013
+++
/branches/mhk_families/idb/pt/uc/cisuc/jrc/mhk/geneology/FamilyManagement.java
Mon May 27 17:06:48 2013
@@ -50,7 +50,7 @@
int counter = 1000;
DBSystem system;
Connection conn;
- Vector <FamilyNode> tree;
+ //Vector <FamilyNode> tree;
HashMap <String,Integer> locked_ids;
HashMap <String,String> locked_child_ids;
int control_level;
@@ -75,7 +75,7 @@
/**
* Get the families from relations table and fills in the family table
*/
- public ArrayList <PersonFamilies> createFamilies(String rid){
+ public ArrayList <PersonFamilies> createFamilies(String rid,Integer
level){
ResultSet persons=null,relations=null;
Statement stmt;
conn = system.getConn();
@@ -156,7 +156,7 @@
}
} catch (Exception e) {e.printStackTrace();}
//calculate tree receiving person id
- tree=new Vector<FamilyNode>();
+ //tree=new Vector<FamilyNode>();
locked_ids=new HashMap <String,Integer>();
control_level=0;
//calculateTree("alarcao-1-6",person_families);
@@ -168,8 +168,9 @@
//sort tree by level
//Collections.sort(tree);

-
- calculatePersons(rids.get(rid),db_person_families);
+ if(level==0)
+ level=Integer.MAX_VALUE;
+ calculatePersons(rids.get(rid),db_person_families,level);
// System.out.println("VALUES");
// for (String value : locked_ids.keySet()){
// System.out.println(value);
@@ -238,7 +239,7 @@
* @param String id from the person
* @return
*/
- public void calculatePersons(String id,HashMap<String,PersonFamilies>
person_families){
+ public void calculatePersons(String id,HashMap<String,PersonFamilies>
person_families,Integer max_level){

//System.out.println("IF "+person_families.get(id).getId()+"="+id+" "+locked_ids.containsKey(id));
//System.out.println(id);
if(!locked_ids.containsKey(id)){
@@ -251,7 +252,8 @@
if(pf.getFamiliesMpn().get(j).getChild()!=null){
//System.out.println("CHILD RECURSIVE CALL
FOR "+pf.getFamiliesMpn().get(j).getChild());
control_level--;
-
calculatePersons(pf.getFamiliesMpn().get(j).getChild(),person_families);
+ if(control_level>=-max_level && control_level<=max_level)
+
calculatePersons(pf.getFamiliesMpn().get(j).getChild(),person_families,max_level);
control_level++;
}
}
@@ -261,7 +263,8 @@
//System.out.println("HAS FATHER");
//System.out.println("FATHER RECURSIVE CALL
FOR "+pf.getFamiliesN().get(0).getFather());
control_level++;
- calculatePersons(pf.getFamiliesN().get(0).getFather(),person_families);
+ if(control_level>=-max_level && control_level<=max_level)
+
calculatePersons(pf.getFamiliesN().get(0).getFather(),person_families,max_level);
control_level--;
}
//get mother tree
@@ -269,7 +272,8 @@
//System.out.println("HAS MOTHER");
//System.out.println("MOTHER RECURSIVE CALL
FOR "+pf.getFamiliesN().get(0).getMother());
control_level++;
- calculatePersons(pf.getFamiliesN().get(0).getMother(),person_families);
+ if(control_level>=-max_level && control_level<=max_level)
+
calculatePersons(pf.getFamiliesN().get(0).getMother(),person_families,max_level);
control_level--;
}
}
=======================================
---
/branches/mhk_families/idb/pt/uc/cisuc/jrc/mhk/servlet/DoExecFamily.java
Tue May 21 10:39:41 2013
+++
/branches/mhk_families/idb/pt/uc/cisuc/jrc/mhk/servlet/DoExecFamily.java
Mon May 27 17:06:48 2013
@@ -70,7 +70,7 @@


System.out.println("[DoExec] executing script "+script);
- System.out.println("GEDCOM ID====="+gedcomId);
+
String title = request.getParameter("title");

ctx.put("script",script);
Reply all
Reply to author
Forward
0 new messages