Skip to content

Commit 7da7a16

Browse files
committed
Cleanup code and comments
2 parents 6c37224 + ddf67d8 commit 7da7a16

3 files changed

Lines changed: 26 additions & 1617 deletions

File tree

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,8 @@ buildNumber.properties
2424
.mvn/timing.properties
2525
.idea/
2626
*.iml
27+
28+
.DS_Store
29+
.classpath
30+
.project
31+
.settings/

src/main/java/org/semanticwb/model/SWBRuleMgr.java

Lines changed: 15 additions & 128 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
*
1919
* Si usted tiene cualquier duda o comentario sobre SemanticWebBuilder, INFOTEC pone a su disposición la siguiente
2020
* dirección electrónica:
21-
* http://www.semanticwebbuilder.org
21+
* http://www.semanticwebbuilder.org.mx
2222
*/
2323
package org.semanticwb.model;
2424

@@ -126,74 +126,20 @@ public void init()
126126
// }
127127
// }
128128
}
129-
130-
// /**
131-
// * @param User user
132-
// * @param Occurrence occ
133-
// * @return boolean
134-
// */
135-
// public boolean eval(User user, Occurrence occ)
136-
// {
137-
// //System.out.println("EvalOcc:"+occ);
138-
// boolean ret=false;
139-
// String topicmap=occ.getDbdata().getIdtm();
140-
// String occid=occ.getId();
141-
// HashMap map=(HashMap)occDoms.get(topicmap);
142-
// HashMap mapUpd=(HashMap)occUpds.get(topicmap);
143-
// if(map==null)
144-
// {
145-
// map=new HashMap();
146-
// occDoms.put(topicmap,map);
147-
// mapUpd=new HashMap();
148-
// occUpds.put(topicmap,mapUpd);
149-
// }
150-
//
151-
// Document dom=(Document)map.get(occid);
152-
// Timestamp update=(Timestamp)mapUpd.get(occid);
153-
//
154-
// if(dom==null || update==null || !occ.getDbdata().getLastupdate().equals(update))
155-
// {
156-
// //System.out.println("AddOcc:"+occ);
157-
// String raux=occ.getResourceData();
158-
//// raux=AFUtils.replaceAll(raux, "{|{","<");
159-
//// raux=AFUtils.replaceAll(raux, "}|}",">");
160-
// //dom=AFUtils.getInstance().XmltoDom(AFUtils.replaceXMLTags(raux));
161-
// dom=AFUtils.getInstance().XmltoDom(raux);
162-
// update=occ.getDbdata().getLastupdate();
163-
// map.put(occid, dom);
164-
// mapUpd.put(occid,update);
165-
// }
166-
//
167-
// if (user.getDom() != null && dom != null)
168-
// {
169-
// NodeList nl = dom.getElementsByTagName("rule");
170-
// if(nl.getLength()>0)
171-
// {
172-
// Node node = nl.item(0);
173-
// //System.out.println("Start:"+node.getNodeName());
174-
// if (node != null)
175-
// {
176-
// ret=and(node, user, topicmap);
177-
// }
178-
// }
179-
// }
180-
// return ret;
181-
// }
129+
182130

183131
/**
184-
* Eval.
185-
*
186-
* @param user the user
187-
* @param rule_uri the rule_uri
188-
* @return true, if successful
189-
* @return
190-
*/
132+
* Eval.
133+
*
134+
* @param user the user
135+
* @param rule_uri the rule_uri
136+
* @return true, if successful
137+
* @return
138+
*/
191139
public boolean eval(User user, String rule_uri)
192140
{
193-
//System.out.println("rule:"+rule_uri+" "+user);
194141
boolean ret=false;
195142
Document rul = doms.get(rule_uri);
196-
//System.out.println("xml:"+SWBUtils.XML.domToXml(rul));
197143
if(rul==null)
198144
{
199145
synchronized(this)
@@ -217,14 +163,12 @@ public boolean eval(User user, String rule_uri)
217163
if (user != null && rul != null)
218164
{
219165
Node node = rul.getChildNodes().item(0);
220-
//System.out.println("Start:"+node.getNodeName());
221166
if (node != null && node.getNodeName().equals("rule"))
222167
{
223168
ret=and(node, user);
224169
}
225170
}
226-
//System.out.println("user:"+user.getId()+" rule:"+rule+" site:"+topicmap+" ret:"+ret);
227-
//System.out.println(" ret:"+ret);
171+
228172
return ret;
229173
}
230174

@@ -258,13 +202,12 @@ else if ("or".equals(nl.item(x).getNodeName()))
258202
}
259203
if (!ret)
260204
{
261-
//System.out.println(" AND false");
262205
ret=false;
263206
break;
264207
}
265208
}
266209
}
267-
//System.out.println(" AND true");
210+
268211
return ret;
269212
}
270213

@@ -279,7 +222,7 @@ else if ("or".equals(nl.item(x).getNodeName()))
279222
public boolean or(Node node, User user)
280223
{
281224
boolean ret=false;
282-
//System.out.println("or:"+node.getNodeName());
225+
283226
NodeList nl = node.getChildNodes();
284227
for (int x = 0; x < nl.getLength(); x++)
285228
{
@@ -317,7 +260,7 @@ else if ("or".equals(nl.item(x).getNodeName()))
317260
public boolean exp(Node node, User user)
318261
{
319262
boolean ret = false;
320-
//System.out.println("exp:"+node.getNodeName());
263+
321264
try
322265
{
323266
Node aux = node.getChildNodes().item(0);
@@ -334,9 +277,6 @@ public boolean exp(Node node, User user)
334277
}
335278
String value = aux.getNodeValue();
336279

337-
//System.out.println("name:"+name+" cond:"+cond +" value:"+value);
338-
//new Exception().printStackTrace();
339-
340280
//validacion de Reglas
341281
if(name.equals(TAG_INT_RULE))
342282
{
@@ -447,7 +387,7 @@ public boolean exp(Node node, User user)
447387
if(prop!=null && prop.isDataTypeProperty())
448388
{
449389
String usrval = user.getSemanticObject().getProperty(prop);
450-
//System.out.println(usrval+cond+value);
390+
451391
if(usrval==null && value==null)
452392
{
453393
ret=true;
@@ -501,15 +441,13 @@ public boolean exp(Node node, User user)
501441
}
502442
}
503443
}
504-
//System.out.println(ret);
505-
//if (ret) return true;
506444
}
507445
}
508446
} catch (Exception e)
509447
{
510448
log.error("SWBRuleMgr.exp:"+user+" -> "+SWBUtils.XML.domToXml(node.getOwnerDocument()),e);
511449
}
512-
//System.out.println(ret);
450+
513451
return ret;
514452
}
515453

@@ -544,55 +482,4 @@ public void reloadRule(Rule rule)
544482
log.error("Rule:"+rule.getURI(), e);
545483
}
546484
}
547-
548-
// /** Avisa al observador de que se ha producido un cambio.
549-
// * @param s
550-
// * @param obj */
551-
// public void sendDBNotify(String s, Object obj)
552-
// {
553-
// RecRule rule=(RecRule)obj;
554-
// if(rule==null)return;
555-
// HashMap map=(HashMap)doms.get(rule.getTopicMapId());
556-
// if(map==null)
557-
// {
558-
// map=new HashMap();
559-
// doms.put(rule.getTopicMapId(),map);
560-
// }
561-
//
562-
// if (s.equals("remove"))
563-
// {
564-
// map.remove(new Integer(rule.getId()));
565-
// } else if (s.equals("create"))
566-
// {
567-
// try
568-
// {
569-
// if (rule.getXml() != null)
570-
// {
571-
// Document dom = com.infotec.appfw.util.AFUtils.getInstance().XmltoDom(rule.getXml());
572-
// if (dom != null) map.put(new Integer(rule.getId()), dom);
573-
// }
574-
// } catch (Exception e)
575-
// {
576-
// AFUtils.log(e, com.infotec.appfw.util.AFUtils.getLocaleString("locale_core", "error_RuleMgr_sendDBNotify_trasnXML") + rule.getId(), true);
577-
// }
578-
// } else if (s.equals("update") || s.equals("load"))
579-
// {
580-
// try
581-
// {
582-
// if (rule.getXml() != null)
583-
// {
584-
// Document dom = com.infotec.appfw.util.AFUtils.getInstance().XmltoDom(rule.getXml());
585-
// if (dom != null)
586-
// {
587-
// map.remove(new Integer(rule.getId()));
588-
// map.put(new Integer(rule.getId()), dom);
589-
// }
590-
// }
591-
// } catch (Exception e)
592-
// {
593-
// AFUtils.log(e, com.infotec.appfw.util.AFUtils.getLocaleString("locale_core", "error_RuleMgr_sendDBNotify_trasnXML") + rule.getId(), true);
594-
// }
595-
// }
596-
// }
597-
598485
}

0 commit comments

Comments
 (0)