Revision: 1085
Author:
tbc...@gmail.com
Date: Sat Jun 29 08:47:29 2013
Log: Input data protection on browser data introduction @mhk_families
http://code.google.com/p/mhk/source/detail?r=1085
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 Fri Jun 28
15:36:49 2013
+++ /branches/mhk_families/idb/etc/template/new/create_source.vm Sat Jun 29
08:47:29 2013
@@ -116,6 +116,12 @@
person.sex=document.getElementById("person_sex").value;
person.observation=document.getElementById("person_observation").value;
person.id=count_persons;
+
+ if(
person.name==""){
+ alert("You need to fill in the required fields.");
+ return;
+ }
+
persons.push(person);
var table = document.getElementById("persons_table");
@@ -147,6 +153,12 @@
relation.value=document.getElementById("relation_value").value;
relation.observation=document.getElementById("relation_observation").value;
relation.id=count_relations;
+
+ if(relation.origin=="" || relation.destination=="" || relation.value==""
|| relation.type==""){
+ alert("You need to fill in the required fields.");
+ return;
+ }
+
relations.push(relation);
var table = document.getElementById("relations_table");
@@ -183,6 +195,12 @@
attribute.person_id=document.getElementById("person_id").value;
attribute.observation=document.getElementById("attribute_observation").value;
attribute.id=count_attributes;
+
+ if(
attribute.name=="" || attribute.value=="" || attribute.person_id==""){
+ alert("You need to fill in the required fields.");
+ return;
+ }
+
attributes.push(attribute);
var table = document.getElementById("attributes_table");
@@ -268,7 +286,7 @@
<td>Person Observation</td>
</tr>
</table>
- Person Name: <input type="text" id="person_name">Person Sex: <input
type="text" id="person_sex">Person Observation: <input type="text"
id="person_observation"><input type="button" value="Add Person"
onClick="printPersonsTable()"><br>
+ Person Name*: <input type="text" id="person_name">Person Sex: <input
type="text" id="person_sex">Person Observation: <input type="text"
id="person_observation"><input type="button" value="Add Person"
onClick="printPersonsTable()"><br>
<h3>Attributes »</h3>
<table id="attributes_table">
@@ -280,7 +298,7 @@
<td>Attribute Observation</td>
</tr>
</table>
- Attribute Name: <input type="text" id="attribute_name">Attribute Value:
<input type="text" id="attribute_value">Person Id: <input type="text"
id="person_id">Attribute Observation: <input type="text"
id="attribute_observation"><input type="button" value="Add Attribute"
onClick="printAttributesTable()"><br>
+ Attribute Name*: <input type="text" id="attribute_name">Attribute
Value*: <input type="text" id="attribute_value">Person Id*: <input
type="text" id="person_id">Attribute Observation: <input type="text"
id="attribute_observation"><input type="button" value="Add Attribute"
onClick="printAttributesTable()"><br>
<h3>Relations »</h3>
<table id="relations_table">
@@ -293,7 +311,7 @@
<td>Relation Observation</td>
</tr>
</table>
- Relation Type: <input type="text" id="relation_type">Relation Value:
<input type="text" id="relation_value">Origin Id: <input type="text"
id="origin_id">Destination Id: <input type="text"
id="destination_id">Relation Observation: <input type="text"
id="relation_observation"><input type="button" value="Add Relation"
onClick="printRelationsTable()"><br>
+ Relation Type*: <input type="text" id="relation_type">Relation Value*:
<input type="text" id="relation_value">Origin Id*: <input type="text"
id="origin_id">Destination Id*: <input type="text"
id="destination_id">Relation Observation: <input type="text"
id="relation_observation"><input type="button" value="Add Relation"
onClick="printRelationsTable()"><br>
<input type="button" value="Save" onclick="submitForm()">
</form>
=======================================
---
/branches/mhk_families/idb/pt/uc/cisuc/jrc/mhk/parser/SaveWebSource.java
Fri Jun 28 15:36:49 2013
+++
/branches/mhk_families/idb/pt/uc/cisuc/jrc/mhk/parser/SaveWebSource.java
Sat Jun 29 08:47:29 2013
@@ -34,9 +34,6 @@
root = new Element("KLEIO");
root.setAttribute("STRUCTURE","WEBSOURCE");
root.setAttribute("SOURCE",path);
-
-
-
//Write XML classes
Element define_class;
@@ -144,13 +141,16 @@
s.addContent(core);
source.addContent(s);
- s=new Element("ELEMENT");
- s.setAttribute("NAME","obs");
- s.setAttribute("CLASS","obs");
- core=new Element("core");
- core.addContent((String)source_obj.get("observation"));
- s.addContent(core);
- source.addContent(s);
+ String obs=(String)source_obj.get("observation");
+ if(!obs.equals("")){
+ s=new Element("ELEMENT");
+ s.setAttribute("NAME","obs");
+ s.setAttribute("CLASS","obs");
+ core=new Element("core");
+ core.addContent(obs);
+ s.addContent(core);
+ source.addContent(s);
+ }
root.addContent(source);
}
@@ -215,21 +215,36 @@
s.addContent(core);
individual.addContent(s);
- s=new Element("ELEMENT");
- s.setAttribute("NAME","sex");
- s.setAttribute("CLASS","sex");
- core=new Element("core");
- core.addContent((String)person.get("sex"));
- s.addContent(core);
- individual.addContent(s);
+ String sex=(String)person.get("sex");
+ if(!sex.equals("")){
+ s=new Element("ELEMENT");
+ s.setAttribute("NAME","sex");
+ s.setAttribute("CLASS","sex");
+ core=new Element("core");
+ core.addContent(sex);
+ s.addContent(core);
+ individual.addContent(s);
+ }
+ else{
+ s=new Element("ELEMENT");
+ s.setAttribute("NAME","sex");
+ s.setAttribute("CLASS","sex");
+ core=new Element("core");
+ core.addContent("N/A");
+ s.addContent(core);
+ individual.addContent(s);
+ }
- s=new Element("ELEMENT");
- s.setAttribute("NAME","obs");
- s.setAttribute("CLASS","obs");
- core=new Element("core");
- core.addContent((String)person.get("observation"));
- s.addContent(core);
- individual.addContent(s);
+ String obs=(String)person.get("observation");
+ if(!obs.equals("")){
+ s=new Element("ELEMENT");
+ s.setAttribute("NAME","obs");
+ s.setAttribute("CLASS","obs");
+ core=new Element("core");
+ core.addContent(obs);
+ s.addContent(core);
+ individual.addContent(s);
+ }
root.addContent(individual);
writeSameAsRelation(individualId);
@@ -305,13 +320,16 @@
s.addContent(core);
attribute.addContent(s);
- s=new Element("ELEMENT");
- s.setAttribute("NAME","obs");
- s.setAttribute("CLASS","obs");
- core=new Element("core");
- core.addContent((String)attribute_obj.get("observation"));
- s.addContent(core);
- attribute.addContent(s);
+ String obs=(String)attribute_obj.get("observation");
+ if(!obs.equals("")){
+ s=new Element("ELEMENT");
+ s.setAttribute("NAME","obs");
+ s.setAttribute("CLASS","obs");
+ core=new Element("core");
+ core.addContent(obs);
+ s.addContent(core);
+ attribute.addContent(s);
+ }
root.addContent(attribute);
count_attributes++;
@@ -404,13 +422,16 @@
s.addContent(core);
attribute.addContent(s);
- s=new Element("ELEMENT");
- s.setAttribute("NAME","obs");
- s.setAttribute("CLASS","ons");
- core=new Element("core");
- core.addContent((String)relation_obj.get("observation"));
- s.addContent(core);
- attribute.addContent(s);
+ String obs=(String)relation_obj.get("observation");
+ if(!obs.equals("")){
+ s=new Element("ELEMENT");
+ s.setAttribute("NAME","obs");
+ s.setAttribute("CLASS","obs");
+ core=new Element("core");
+ core.addContent(obs);
+ s.addContent(core);
+ attribute.addContent(s);
+ }
root.addContent(attribute);
count_relations++;