You can subscribe to this list here.
| 2004 |
Jan
|
Feb
(11) |
Mar
(106) |
Apr
(146) |
May
(79) |
Jun
(233) |
Jul
(218) |
Aug
(160) |
Sep
(155) |
Oct
(80) |
Nov
(176) |
Dec
(115) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2005 |
Jan
(77) |
Feb
(106) |
Mar
(10) |
Apr
(54) |
May
(29) |
Jun
(29) |
Jul
(65) |
Aug
(80) |
Sep
|
Oct
(42) |
Nov
(45) |
Dec
(33) |
| 2006 |
Jan
(49) |
Feb
(52) |
Mar
(8) |
Apr
(3) |
May
(108) |
Jun
(43) |
Jul
(13) |
Aug
(1) |
Sep
(58) |
Oct
(66) |
Nov
(70) |
Dec
(115) |
| 2007 |
Jan
(26) |
Feb
(3) |
Mar
(17) |
Apr
(1) |
May
(4) |
Jun
(3) |
Jul
(2) |
Aug
(1) |
Sep
|
Oct
(1) |
Nov
(1) |
Dec
(1) |
| 2008 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(4) |
Jun
|
Jul
(10) |
Aug
|
Sep
|
Oct
(1) |
Nov
|
Dec
(1) |
| 2009 |
Jan
(5) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(3) |
Sep
|
Oct
|
Nov
|
Dec
|
Update of /cvsroot/cobricks/cobricks2/src/org/cobricks/course In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1451/src/org/cobricks/course Modified Files: Course.java CourseDate.java CourseManager.java CourseManagerImpl.java Added Files: CourseRoom.java Log Message: --- NEW FILE: CourseRoom.java --- /* * Copyright (c) 2004 Cobricks Group. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted under the terms of the Cobricks Software * License, either version 1.0 of the License, or (at your option) any * later version (see www.cobricks.de). * * The above copyright notice and this permission notice shall be * included in all copies or substantial portions of the Software. */ package org.cobricks.course; import java.util.*; import org.apache.log4j.*; /** * * @author mic...@ac... * @version $Date: 2004/03/01 07:09:04 $ */ public class CourseRoom { static Logger logger = Logger.getLogger(CourseRoom.class); int crid; String crname; String crinfo; String crgroup; String crcontact; String crextid; int crhidden; /** * */ public CourseRoom() { } public int getId() { return crid; } public String getName() { return crname; } public String getInfo() { return crinfo; } public String getGroup() { return crgroup; } public String getContact() { return crcontact; } public String getExtId() { return crextid; } public int getHidden() { return crhidden; } public void loadFromMap(Map map, CourseManager courseManager) { Integer tmpi = (Integer)map.get("crid"); crid = tmpi.intValue(); crname = (String)map.get("crname"); crinfo = (String)map.get("crinfo"); crgroup = (String)map.get("crgroup"); crcontact = (String)map.get("crcontact"); crextid = (String)map.get("crextid"); tmpi = (Integer)map.get("crhidden"); if (tmpi != null) crhidden = tmpi.intValue(); } } Index: Course.java =================================================================== RCS file: /cvsroot/cobricks/cobricks2/src/org/cobricks/course/Course.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** Course.java 26 Feb 2004 16:27:22 -0000 1.4 --- Course.java 1 Mar 2004 07:09:04 -0000 1.5 *************** *** 26,29 **** --- 26,32 ---- * @author mic...@ac... * @version $Date$ + * + * @see org.cobricks.course.CourseDate + * @see org.cobricks.course.CourseRoom */ *************** *** 239,242 **** --- 242,255 ---- /** + * Return the date/room information about the course + * @return set of CourseDate objects + */ + public Set getDates() + { + return courseDates; + } + + + /** * Load course attributes from a Map object - e.g. one retrieved * from a database *************** *** 310,313 **** --- 323,330 ---- if (tmpd != null) cextlastrep = tmpd; + + try { + courseDates = courseManager.getCourseDates(cid); + } catch (Exception e) { } } Index: CourseDate.java =================================================================== RCS file: /cvsroot/cobricks/cobricks2/src/org/cobricks/course/CourseDate.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** CourseDate.java 24 Feb 2004 14:25:13 -0000 1.1 --- CourseDate.java 1 Mar 2004 07:09:04 -0000 1.2 *************** *** 42,45 **** --- 42,47 ---- int dcrid; + CourseRoom droom; + /** *************** *** 50,53 **** --- 52,115 ---- } + public int getId() + { + return did; + } + + public int getCourseId() + { + return cid; + } + + public int getCycle() + { + return dcycle; + } + + public Date getStartDate() + { + return dstartdate; + } + + public Date getEndDate() + { + return denddate; + } + + public int getWeekday() + { + return dweekday; + } + + public int getStartHour() + { + return dstarthour; + } + + public int getStartMin() + { + return dstartmin; + } + + public int getEndHour() + { + return dendhour; + } + + public int getEndMin() + { + return dendmin; + } + + public int getRoomId() + { + return dcrid; + } + + public CourseRoom getRoom() + { + return droom; + } + public void loadFromMap(Map map, CourseManager courseManager) { *************** *** 56,61 **** tmpi = (Integer)map.get("cid"); cid = tmpi.intValue(); ! // tbd } } --- 118,173 ---- tmpi = (Integer)map.get("cid"); cid = tmpi.intValue(); ! Character tmpc = (Character)map.get("dtype"); ! if (tmpc != null) ! dtype = tmpc.charValue(); ! tmpi = (Integer)map.get("dcycle"); ! if (tmpi != null) ! dcycle = tmpi.intValue(); ! else ! dcycle = 0; ! dstartdate = (Date)map.get("dstartdate"); ! denddate = (Date)map.get("denddate"); ! tmpi = (Integer)map.get("dweekday"); ! if (tmpi != null) ! dweekday = tmpi.intValue(); ! tmpi = (Integer)map.get("dstarthour"); ! if (tmpi != null) ! dstarthour = tmpi.intValue(); ! tmpi = (Integer)map.get("dstartmin"); ! if (tmpi != null) ! dstartmin = tmpi.intValue(); ! tmpi = (Integer)map.get("dendhour"); ! if (tmpi != null) ! dendhour = tmpi.intValue(); ! tmpi = (Integer)map.get("dendmin"); ! if (tmpi != null) ! dendmin = tmpi.intValue(); ! tmpi = (Integer)map.get("dcrid"); ! if (tmpi != null) { ! dcrid = tmpi.intValue(); ! try { ! droom = courseManager.getCourseRoom(dcrid); ! } catch (Exception e) { } ! } ! } ! ! ! public Map getAttrs() ! { ! Map result = new HashMap(); ! result.put("did", new Integer(did)); ! result.put("cid", new Integer(cid)); ! result.put("dtype", new Character(dtype)); ! result.put("dweekday", new Integer(dweekday)); ! result.put("dstarthour", new Integer(dstarthour)); ! result.put("dstartmin", new Integer(dstartmin)); ! result.put("dendhour", new Integer(dendhour)); ! result.put("dendmin", new Integer(dendmin)); ! result.put("dcrid", new Integer(dcrid)); ! if (dstartdate != null) result.put("dstartdate", dstartdate); ! if (denddate != null) result.put("denddate", denddate); ! return result; } + } Index: CourseManager.java =================================================================== RCS file: /cvsroot/cobricks/cobricks2/src/org/cobricks/course/CourseManager.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** CourseManager.java 26 Feb 2004 08:12:58 -0000 1.3 --- CourseManager.java 1 Mar 2004 07:09:04 -0000 1.4 *************** *** 56,58 **** --- 56,64 ---- public void deleteCourseTemplate(int ctid, User user) throws CobricksException; + + public Set getCourseDates(int cid) + throws CobricksException; + public CourseRoom getCourseRoom(int crid) + throws CobricksException; + } Index: CourseManagerImpl.java =================================================================== RCS file: /cvsroot/cobricks/cobricks2/src/org/cobricks/course/CourseManagerImpl.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** CourseManagerImpl.java 26 Feb 2004 08:12:58 -0000 1.4 --- CourseManagerImpl.java 1 Mar 2004 07:09:04 -0000 1.5 *************** *** 55,58 **** --- 55,59 ---- Map courseCache; Map courseTemplateCache; + Map courseRoomCache; *************** *** 104,107 **** --- 105,109 ---- courseCache = new HashMap(); courseTemplateCache = new HashMap(); + courseRoomCache = new HashMap(); // and finally initialize the access handler *************** *** 235,238 **** --- 237,263 ---- * */ + public void updateCourseDates(int cid, Set cdates) + { + String sql = "delete from course_date where cid = " + +Integer.toString(cid); + Iterator i = cdates.iterator(); + while (i.hasNext()) { + Object o = i.next(); + Map attrs = null; + if (o instanceof CourseDate) { + attrs = ((CourseDate)o).getAttrs(); + } else { + attrs = (Map)o; + } + attrs.remove("did"); + attrs.put("cid", new Integer(cid)); + int did = dbAccess.sqlInsert("course_date", attrs); + } + } + + + /** + * + */ public void updateCourse(int cid, Map attrs, User user) throws CobricksException *************** *** 353,355 **** --- 378,409 ---- + /** + * + */ + public Set getCourseDates(int cid) + throws CobricksException + { + // tbd + return null; + } + + + /** + * + */ + public CourseRoom getCourseRoom(int crid) + throws CobricksException + { + CourseRoom result = (CourseRoom)courseRoomCache.get(new Integer(crid)); + if (result != null) return result; + // load from database + Map dbres = dbAccess. + sqlQuerySingleRow("select * from course_room where crid = " + +Integer.toString(crid)); + result = new CourseRoom(); + result.loadFromMap(dbres, this); + courseRoomCache.put(new Integer(crid), result); + return result; + } + } |
|
From: <ko...@us...> - 2004-03-01 07:27:45
|
Update of /cvsroot/cobricks/cobricks2/web/course In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1451/web/course Modified Files: ccreate1.html.en Log Message: Index: ccreate1.html.en =================================================================== RCS file: /cvsroot/cobricks/cobricks2/web/course/ccreate1.html.en,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ccreate1.html.en 26 Feb 2004 08:15:51 -0000 1.1 --- ccreate1.html.en 1 Mar 2004 07:09:04 -0000 1.2 *************** *** 113,116 **** --- 113,137 ---- </table> + <h3>Dates</h3> + + <table border="0"> + <tr><td>Weekday</td><td colspan=3>Begin</td><td> </td> + <td colspan=3>End</td><td>Room</td><td>Startdate</td><td>Enddate</td> + <td>Type</td></tr> + <tr><td><select name="dweekday1"><option value="0">-- + <option value="1">Mo<option value="2">Tu<option value="3">We + <option value="4">Th<option value="5">Fr + <option value="7">Sa<option value="7">Su</select></td> + <td><input name="dstarthour1" size="2"></td><td>:</td> + <td><input name="dstartmin1" size="2"></td><td>-</td> + <td><input name="dendhour1" size="2"></td><td>:</td> + <td><input name="dendmin1" size="2"></td> + <td><input name="droom1" size="7"></td> + <td><input name="dstartdate1" size="10"></td> + <td><input name="denddate1" size="10"></td> + <td><select name="dtype1"><option value="1">weekly<option + value="2">biweekly<option value="0">dayly/once</select></td></tr> + </table> + <p> <input type="submit" class="submit" value="Create Course"/> *************** *** 120,122 **** #parse ( "pagefooter.html" ) - --- 141,142 ---- |
|
From: <ko...@us...> - 2004-03-01 07:27:45
|
Update of /cvsroot/cobricks/cobricks2/src/org/cobricks/portal/velocity In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1451/src/org/cobricks/portal/velocity Modified Files: PortalResourceLoader.java Log Message: Index: PortalResourceLoader.java =================================================================== RCS file: /cvsroot/cobricks/cobricks2/src/org/cobricks/portal/velocity/PortalResourceLoader.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** PortalResourceLoader.java 16 Feb 2004 15:49:46 -0000 1.3 --- PortalResourceLoader.java 1 Mar 2004 07:09:04 -0000 1.4 *************** *** 27,31 **** import org.cobricks.core.CoreManager; import org.cobricks.core.util.LogUtil; ! import org.cobricks.portal.Page; import org.cobricks.portal.PortalManager; --- 27,32 ---- import org.cobricks.core.CoreManager; import org.cobricks.core.util.LogUtil; ! import org.cobricks.portal.PortalFolder; ! import org.cobricks.portal.PortalPage; import org.cobricks.portal.PortalManager; *************** *** 85,89 **** pageName = pageName.substring(pos+1); } ! Page page = portalManager.getPage(pagePath, pageName); if (page != null) { Map pc = page.getStringContent(null); --- 86,90 ---- pageName = pageName.substring(pos+1); } ! PortalPage page = portalManager.getPage(pagePath, pageName); if (page != null) { Map pc = page.getStringContent(null); |
|
From: <ko...@us...> - 2004-03-01 07:27:45
|
Update of /cvsroot/cobricks/cobricks2/web/portal In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1451/web/portal Modified Files: create.html Added Files: createfolder.html Log Message: --- NEW FILE: createfolder.html --- #parse ( "pageheader.html" ) <em><a href="index.html">Portal Component</a> - <a href="createfolder.html">Create Folder</a></em> <h1>Create Portal Folder</h1> #if ( $returnCode > 1999 ) <font color="red">Failed creating PortalFolder object.</font><p> #end <form action="/PORTAL" method="post"> <input type="hidden" name="cmd" value="createfolder"> <input type="hidden" name="cmd.noaccess" value="/noaccess.html"> <input type="hidden" name="cmd.success" value="create.html"> <input type="hidden" name="cmd.error" value="createfolder.html"> <input type="hidden" name="path" value="$portalRequest.getPagePath()"/> Parent Folder: <select name="ppath"> #foreach ($p in $portalManager.getPortalFolderPaths()) <option value="$p">$p #end </select> <p> Folder Name:<br> <input name="pname" size="50"> <p> Title:<br> <input name="title" size="60"> <p> <input type="submit" value="Create Folder"> </form> #parse ( "pagefooter.html" ) Index: create.html =================================================================== RCS file: /cvsroot/cobricks/cobricks2/web/portal/create.html,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** create.html 11 Feb 2004 14:37:02 -0000 1.1 --- create.html 1 Mar 2004 07:09:05 -0000 1.2 *************** *** 7,13 **** <h1>Create Portal Page</h1> ! List of possible portal directories - from category component. ! ! <p> <form action="/PORTAL" method="post"> --- 7,16 ---- <h1>Create Portal Page</h1> ! #if ( $returnCode == 1001 ) ! <font color="green">Successfully created PortalFolder object.</font><p> ! #end ! #if ( $returnCode > 1999 ) ! <font color="red">Failed creating PortalPage object.</font><p> ! #end <form action="/PORTAL" method="post"> *************** *** 16,25 **** <input type="hidden" name="cmd.success" value="index.html"> <input type="hidden" name="cmd.error" value="create.html"> ! Path:<br> ! <input name="ppath" size="50"> <p> ! Name:<br> ! <input name="pname" size="50"> <select name="plang"> <option value="de">Deutsch <option value="en">English --- 19,35 ---- <input type="hidden" name="cmd.success" value="index.html"> <input type="hidden" name="cmd.error" value="create.html"> + <input type="hidden" name="path" value="$portalRequest.getPagePath()"/> ! Path: ! <select name="ppath"> ! #foreach ($p in $portalManager.getPortalFolderPaths()) ! <option value="$p">$p ! #end ! </select> <a href="createfolder.html">Create New Folder</a> <p> ! Page Name (without ".html"):<br> ! <input name="pname" size="50"> ! <p> ! Language: <select name="plang"> <option value="de">Deutsch <option value="en">English |
|
From: <ko...@us...> - 2004-03-01 07:27:44
|
Update of /cvsroot/cobricks/cobricks2/src/org/cobricks/category In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1451/src/org/cobricks/category Modified Files: Category.java CategoryManagerImpl.java Log Message: Index: Category.java =================================================================== RCS file: /cvsroot/cobricks/cobricks2/src/org/cobricks/category/Category.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Category.java 12 Feb 2004 06:25:26 -0000 1.2 --- Category.java 1 Mar 2004 07:09:03 -0000 1.3 *************** *** 93,107 **** public int getObjectType() { ! return 0; } public String getObjectClass() { ! return "category"; } public String getObjectUri() { ! return null; } --- 93,107 ---- public int getObjectType() { ! return 0; } public String getObjectClass() { ! return "category"; } public String getObjectUri() { ! return null; } *************** *** 109,123 **** public int getCategoryId() { ! return catid; } public int getId() { ! return catid; } protected void setCategoryId(int catid) { ! this.catid = catid; } --- 109,123 ---- public int getCategoryId() { ! return catid; } public int getId() { ! return catid; } protected void setCategoryId(int catid) { ! this.catid = catid; } *************** *** 132,136 **** return getTitle(defaultLanguage); } ! public String getTitle(String lang) { --- 132,136 ---- return getTitle(defaultLanguage); } ! public String getTitle(String lang) { *************** *** 151,155 **** setAttribute("title_"+lang, title); } ! public void setTitles(Map m) { --- 151,155 ---- setAttribute("title_"+lang, title); } ! public void setTitles(Map m) { *************** *** 160,164 **** } } ! public String getCategoryClass() --- 160,164 ---- } } ! public String getCategoryClass() Index: CategoryManagerImpl.java =================================================================== RCS file: /cvsroot/cobricks/cobricks2/src/org/cobricks/category/CategoryManagerImpl.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** CategoryManagerImpl.java 16 Feb 2004 15:01:24 -0000 1.3 --- CategoryManagerImpl.java 1 Mar 2004 07:09:03 -0000 1.4 *************** *** 309,314 **** String globalid = uuid.getNewUuidAsString(); attrs.put("globalid", globalid); ! attrs.put("creatorid", new Integer(creator.getUserId())); ! attrs.put("updaterid", new Integer(creator.getUserId())); attrs.put("creationtime", new Date()); attrs.put("updatetime", new Date()); --- 309,320 ---- String globalid = uuid.getNewUuidAsString(); attrs.put("globalid", globalid); ! if (creator!=null) ! attrs.put("creatorid", new Integer(creator.getUserId())); ! else ! attrs.put("creatorid", new Integer(0)); ! if (creator!=null) ! attrs.put("updaterid", new Integer(creator.getUserId())); ! else ! attrs.put("updaterid", new Integer(0)); attrs.put("creationtime", new Date()); attrs.put("updatetime", new Date()); *************** *** 352,356 **** // additional attributes ! // tbd // set attributes in object --- 358,371 ---- // additional attributes ! i = attrsAttrs.keySet().iterator(); ! while (i.hasNext()) { ! String aname = (String)i.next(); ! Object avalue = attrsAttrs.get(aname); ! HashMap dbattrs = new HashMap(); ! dbattrs.put("catid",new Integer(catid)); ! dbattrs.put("aname", aname); ! dbattrs.put("avalue", avalue); ! dbAccess.sqlInsert("cat_attrs", dbattrs); ! } // set attributes in object *************** *** 365,369 **** new ComponentEventImpl("category", "category", "create"); event.setObjectId(catid); ! event.setUserId(creator.getId()); this.publishEvent(event); --- 380,387 ---- new ComponentEventImpl("category", "category", "create"); event.setObjectId(catid); ! if (creator!=null) ! event.setUserId(creator.getId()); ! else ! event.setUserId(0); this.publishEvent(event); |
|
From: <ko...@us...> - 2004-03-01 07:27:44
|
Update of /cvsroot/cobricks/cobricks2/conf/org.cobricks.portal In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1451/conf/org.cobricks.portal Modified Files: categoryontology.xml itemontology.xml Log Message: Index: categoryontology.xml =================================================================== RCS file: /cvsroot/cobricks/cobricks2/conf/org.cobricks.portal/categoryontology.xml,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** categoryontology.xml 11 Feb 2004 14:53:24 -0000 1.1 --- categoryontology.xml 1 Mar 2004 07:09:03 -0000 1.2 *************** *** 1,5 **** <categoryontology> ! <class name="portalfolder" parent="category"> <description lang="en">Portal Folder (for Page items)</description> <attr name="path" type="string(50)"/> --- 1,5 ---- <categoryontology> ! <class name="portalfolder" parent="category" javaclassname="org.cobricks.portal.PortalFolder"> <description lang="en">Portal Folder (for Page items)</description> <attr name="path" type="string(50)"/> Index: itemontology.xml =================================================================== RCS file: /cvsroot/cobricks/cobricks2/conf/org.cobricks.portal/itemontology.xml,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** itemontology.xml 11 Feb 2004 14:53:24 -0000 1.1 --- itemontology.xml 1 Mar 2004 07:09:03 -0000 1.2 *************** *** 1,5 **** <itemontology> ! <class name="portalpage" parent="item" javaclassname="org.cobricks.portal.Page"> <description lang="de">Portalseite</description> <attr name="mimetype" type="string(20)"/> --- 1,5 ---- <itemontology> ! <class name="portalpage" parent="item" javaclassname="org.cobricks.portal.PortalPage"> <description lang="de">Portalseite</description> <attr name="mimetype" type="string(20)"/> |
|
From: <ko...@us...> - 2004-03-01 07:27:43
|
Update of /cvsroot/cobricks/cobricks2/conf/org.cobricks.course/db In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1451/conf/org.cobricks.course/db Modified Files: course_date.xml Log Message: Index: course_date.xml =================================================================== RCS file: /cvsroot/cobricks/cobricks2/conf/org.cobricks.course/db/course_date.xml,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** course_date.xml 24 Feb 2004 14:25:12 -0000 1.1 --- course_date.xml 1 Mar 2004 07:09:03 -0000 1.2 *************** *** 1,3 **** ! <tabledescriptor tablename="termin"> <table version="1"> --- 1,3 ---- ! <tabledescriptor tablename="course_date"> <table version="1"> |
|
From: <ko...@us...> - 2004-03-01 07:27:43
|
Update of /cvsroot/cobricks/cobricks2 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1451 Modified Files: todo.txt Log Message: Index: todo.txt =================================================================== RCS file: /cvsroot/cobricks/cobricks2/todo.txt,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** todo.txt 27 Feb 2004 08:13:15 -0000 1.5 --- todo.txt 1 Mar 2004 07:09:03 -0000 1.6 *************** *** 29,36 **** Course: ! - implement functionality based on cobricks-1 component ! - convert data to items and categories (Version 2) - search: only search for courses that still fit into the users timetable test --- 29,38 ---- Course: ! - CourseManager.getCourseDates() ! - CourseSevlet: insert, update dates ! - CoursePrograms (shall we do it as categories already?!) - search: only search for courses that still fit into the users timetable + - convert data to items and categories (Version 2) test |
|
From: <j_m...@us...> - 2004-02-29 12:30:55
|
Update of /cvsroot/cobricks/cobricks2/conf/org.cobricks.item In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12502/conf/org.cobricks.item Modified Files: properties.txt Log Message: Index: properties.txt =================================================================== RCS file: /cvsroot/cobricks/cobricks2/conf/org.cobricks.item/properties.txt,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** properties.txt 23 Feb 2004 08:20:56 -0000 1.3 --- properties.txt 29 Feb 2004 12:12:34 -0000 1.4 *************** *** 29,30 **** --- 29,36 ---- item.xmldb.hostname=localhost item.xmldb.portnumber=4080 + item.xmldb.initdelay=10000 + + + # Encoding settings - changing may cause problems - see doc + item.java.file.encoding=UTF-8 + item.xml.encoding=UTF-8 |
|
From: <j_m...@us...> - 2004-02-29 12:24:42
|
Update of /cvsroot/cobricks/cobricks2/src/org/cobricks/item/xmldb In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11635/src/org/cobricks/item/xmldb Modified Files: XMLDBAccess.java Log Message: Index: XMLDBAccess.java =================================================================== RCS file: /cvsroot/cobricks/cobricks2/src/org/cobricks/item/xmldb/XMLDBAccess.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** XMLDBAccess.java 21 Feb 2004 18:49:56 -0000 1.3 --- XMLDBAccess.java 29 Feb 2004 12:06:38 -0000 1.4 *************** *** 1,21 **** package org.cobricks.item.xmldb; ! import org.apache.log4j.*; ! ! import org.apache.xindice.client.xmldb.*; ! import org.apache.xindice.client.xmldb.services.*; ! import org.apache.xindice.xml.*; ! import org.apache.xindice.xml.dom.*; ! ! import org.cobricks.category.Category; ! ! import org.cobricks.core.ComponentManagerAdaptor; ! import org.cobricks.core.CoreManager; ! import org.cobricks.core.Ontology; ! import org.cobricks.core.OntologyClass; ! import org.cobricks.core.db.DBAccess; ! import org.cobricks.core.util.LogUtil; ! ! import org.cobricks.user.User; import org.w3c.dom.Document; --- 1,7 ---- package org.cobricks.item.xmldb; ! import org.apache.log4j.Logger; ! import org.apache.xindice.client.xmldb.services.CollectionManager; ! import org.apache.xindice.xml.dom.DocumentImpl; import org.w3c.dom.Document; *************** *** 29,41 **** import org.xml.sax.SAXException; - import org.xmldb.api.*; import org.xmldb.api.DatabaseManager; ! import org.xmldb.api.base.*; ! import org.xmldb.api.modules.*; - import java.io.File; - import java.io.FileNotFoundException; import java.io.StringReader; import java.util.HashMap; import java.util.Iterator; --- 15,32 ---- import org.xml.sax.SAXException; import org.xmldb.api.DatabaseManager; ! import org.xmldb.api.base.Collection; ! import org.xmldb.api.base.Database; ! import org.xmldb.api.base.XMLDBException; ! import org.xmldb.api.base.Resource; ! import org.xmldb.api.base.ResourceSet; ! import org.xmldb.api.base.ResourceIterator; ! import org.xmldb.api.modules.XMLResource; ! import org.xmldb.api.modules.XPathQueryService; ! import org.xmldb.api.modules.XUpdateQueryService; import java.io.StringReader; + import java.util.HashMap; import java.util.Iterator; *************** *** 43,69 **** import java.util.Properties; import java.util.Set; ! import java.sql.Date; ! import java.sql.Timestamp; ! import java.util.Calendar; ! import java.util.TimeZone; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; - import javax.xml.parsers.FactoryConfigurationError; import javax.xml.parsers.ParserConfigurationException; import javax.xml.transform.OutputKeys; ! import javax.xml.transform.Result; ! import javax.xml.transform.Source; ! import javax.xml.transform.Templates; import javax.xml.transform.Transformer; ! import javax.xml.transform.TransformerConfigurationException; ! import javax.xml.transform.TransformerException; import javax.xml.transform.TransformerFactory; ! import javax.xml.transform.dom.DOMResult; import javax.xml.transform.dom.DOMSource; ! import javax.xml.transform.sax.SAXResult; ! import javax.xml.transform.sax.SAXSource; ! import javax.xml.transform.sax.SAXTransformerFactory; import javax.xml.transform.stream.StreamResult; ! import javax.xml.transform.stream.StreamSource; --- 34,53 ---- import java.util.Properties; import java.util.Set; ! ! import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; import javax.xml.transform.OutputKeys; ! ! import javax.xml.transform.Transformer; ! import javax.xml.transform.TransformerFactory; ! import javax.xml.transform.dom.DOMSource; ! import javax.xml.transform.stream.StreamResult; ! *************** *** 82,86 **** * */ ! public class XMLDBAccess { /** * The classname where to find the database impl. (at the moment only xindice) --- 66,70 ---- * */ ! public class XMLDBAccess implements Runnable { /** * The classname where to find the database impl. (at the moment only xindice) *************** *** 103,107 **** */ private static final int DEFAULT_PORTNUMBER = 4080; ! /** * The XML prologue to a XUpdate command. --- 87,94 ---- */ private static final int DEFAULT_PORTNUMBER = 4080; ! /** ! * Default delay in milli seconds for the init thread to wait ! */ ! private static final int DEFAULT_INIT_DELAY = 10000; /** * The XML prologue to a XUpdate command. *************** *** 149,166 **** /** ! *This constructor also initalizes the connection to the db by connecting to ! *the specified collection name using the properties to determine where to ! *connect to. * @param submittedProperties Needed information for the init method. ! * @param collectionName Each instance of XMLDBAccess is tied to one * specific collection * @param pathCollectionDescriptor Path to the descriptor file of this * collection. - * @throws Exception TMP */ ! public XMLDBAccess(Properties submittedProperties, String collectionName, ! String pathCollectionDescriptor) throws Exception { this.properties = submittedProperties; ! online = this.init(collectionName, pathCollectionDescriptor); } --- 136,182 ---- /** ! * Some methods have to add an extra xml version / encoding prologue ! */ ! private String xmlEncoding = "UTF-8"; ! /** ! * The collection name; stored as instance variable because the run() method ! * does not have the ability to get parameters. ! */ ! private String collectionName; ! /** ! * The path to the collection descriptor; stored as instance variable because ! * the run() method does not have the ability to get parameters. ! */ ! private String pathToCollection; ! /** ! * The initial delay; stored as instance variable because the run() method ! * does not have the ability to get parameters. ! */ ! private int initDelay = XMLDBAccess.DEFAULT_INIT_DELAY; ! /** ! * This constructor constructs a new XMLDBAccess instance. It does <b>not</b> ! * initialize the connection. * @param submittedProperties Needed information for the init method. ! * @param submCollectionName Each instance of XMLDBAccess is tied to one * specific collection * @param pathCollectionDescriptor Path to the descriptor file of this * collection. */ ! public XMLDBAccess(Properties submittedProperties, String submCollectionName, ! String pathCollectionDescriptor) { this.properties = submittedProperties; ! this.pathToCollection = pathCollectionDescriptor; ! this.collectionName = submCollectionName; ! int delay = -1; ! try { ! delay = Integer.parseInt( ! properties.getProperty("item.xmldb.initdelay")); ! } catch (Exception e) { ! logger.info("No / illegal delay property. Using default value"); ! } ! if (delay >= 0) { ! this.initDelay = delay; ! } ! //this.init(collectionName, pathCollectionDescriptor); } *************** *** 170,186 **** * exist, they are created. Also needed indexer are created (if there is * a correct descriptor). ! * @param collectionName The name of the collection which should be * initialized * @param pathCollectionDescriptor Path to the descriptor file of this * collection. - * @return Was the attempt to initalize successfull? * @throws Exception */ ! private boolean init(String collectionName, String pathCollectionDescriptor) { // I. Setting up the xmldb Engine Class c; Database database; logger.info("Initializing the DB access for collection: " ! + collectionName); if (properties.getProperty("item.xmldb.hostname") != null) { --- 186,203 ---- * exist, they are created. Also needed indexer are created (if there is * a correct descriptor). ! * @param submCollectionName The name of the collection which should be * initialized * @param pathCollectionDescriptor Path to the descriptor file of this * collection. * @throws Exception */ ! ! private void init(String submCollectionName, String pathCollectionDescriptor) ! { // I. Setting up the xmldb Engine Class c; Database database; logger.info("Initializing the DB access for collection: " ! + submCollectionName); if (properties.getProperty("item.xmldb.hostname") != null) { *************** *** 190,193 **** --- 207,214 ---- } + if (properties.getProperty("item.xml.encoding") != null) { + this.xmlEncoding = properties.getProperty("item.xml.encoding"); + } + try { this.portnumber = *************** *** 205,234 **** "Fatal error while trying to instantiate org.apache.xindice." + "client.xmldb.DatabaseImpl. Giving up to launch XindiceHelper"); ! ! return false; } //II. Verify the correct collection structure and create it,if necessary ! collection = this.getConnected("/db/cobricks/" + collectionName); ! if (!this.verifyCollectionStructure(collectionName, collection)) { // There was a fatal error, the collection structure could neither // be verified nor be "repaired" --> Exit init and set offline logger.warn("Could not verify the collection structure for: " ! + collectionName); ! return false; } else { //The collection is o.k. now, let's check the indexes. //If there are problems whith this check, proceed. ! collectionDesc = new XMLDBCollectionDescriptor(collectionName); try { collectionDesc.readFromFile(new java.io.File( pathCollectionDescriptor)); ! this.checkIndexes(collectionDesc, collectionName); } catch (NullPointerException e) { //Is thrown when the path is not correct. ! logger.warn("Tabledescriptor " + collectionName + "not found." + "path: " + pathCollectionDescriptor); } --- 226,256 ---- "Fatal error while trying to instantiate org.apache.xindice." + "client.xmldb.DatabaseImpl. Giving up to launch XindiceHelper"); ! this.online = false; ! return; } //II. Verify the correct collection structure and create it,if necessary ! collection = this.getConnected("/db/cobricks/" + submCollectionName); ! if (!this.verifyCollectionStructure(submCollectionName, collection)) { // There was a fatal error, the collection structure could neither // be verified nor be "repaired" --> Exit init and set offline logger.warn("Could not verify the collection structure for: " ! + submCollectionName); ! this.online = false; ! return; } else { //The collection is o.k. now, let's check the indexes. //If there are problems whith this check, proceed. ! collectionDesc = new XMLDBCollectionDescriptor(submCollectionName); try { collectionDesc.readFromFile(new java.io.File( pathCollectionDescriptor)); ! this.checkIndexes(collectionDesc, submCollectionName); } catch (NullPointerException e) { //Is thrown when the path is not correct. ! logger.warn("Tabledescriptor " + submCollectionName + "not found." + "path: " + pathCollectionDescriptor); } *************** *** 250,255 **** + " is not open"); } ! ! return true; } } --- 272,277 ---- + " is not open"); } ! this.online = tmpStatus; ! return; } } *************** *** 298,310 **** * @param desc The descriptor contains all the necessary information about * the indexer ! * @param collectionName The name of the collcetion to be checked.. mainly ! * needed for logging purposes. */ private void checkIndexes(XMLDBCollectionDescriptor desc, ! String collectionName) { CollectionManager colman; String[] indexArr; boolean hasMismatch = false; ! logger.info("Checking the indexes for: " + collectionName); try { --- 320,332 ---- * @param desc The descriptor contains all the necessary information about * the indexer ! * @param submCollectionName The name of the collcetion to be checked.. ! * mainly needed for logging purposes. */ private void checkIndexes(XMLDBCollectionDescriptor desc, ! String submCollectionName) { CollectionManager colman; String[] indexArr; boolean hasMismatch = false; ! logger.info("Checking the indexes for: " + submCollectionName); try { *************** *** 322,326 **** if ((indexArr != null) && (indexArr.length > 0)) { for (int i = 0; i < indexArr.length; i++) { ! if (!(this.collectionDesc.getIndexes().containsKey(indexArr[i]))) { // IMPORTANT TO KNOW: COMPARING RELIES ONLY ON THE NAMES! logger.info("Index not found in the collection descriptor:" --- 344,349 ---- if ((indexArr != null) && (indexArr.length > 0)) { for (int i = 0; i < indexArr.length; i++) { ! if (!(this.collectionDesc.getIndexes() ! .containsKey(indexArr[i]))) { // IMPORTANT TO KNOW: COMPARING RELIES ONLY ON THE NAMES! logger.info("Index not found in the collection descriptor:" *************** *** 334,338 **** } else { logger.info("No indexer in indexdescriptor in collection: " ! + collectionName); } --- 357,361 ---- } else { logger.info("No indexer in indexdescriptor in collection: " ! + submCollectionName); } *************** *** 415,419 **** * subcollection of the cobricks collection. If the cobricks collection * doesn't exist, it tries to create both. ! * @param collectionName Name the collection should have * (needed if creation is necessary). * @param submittedCollection The collection to verify. --- 438,442 ---- * subcollection of the cobricks collection. If the cobricks collection * doesn't exist, it tries to create both. ! * @param submCollectionName Name the collection should have * (needed if creation is necessary). * @param submittedCollection The collection to verify. *************** *** 421,425 **** * problems, false otherwise */ ! private boolean verifyCollectionStructure(String collectionName, Collection submittedCollection) { //If the collection is null: The collection doesn't exist. --- 444,448 ---- * problems, false otherwise */ ! private boolean verifyCollectionStructure(String submCollectionName, Collection submittedCollection) { //If the collection is null: The collection doesn't exist. *************** *** 428,432 **** Collection cobricks = null; ! logger.info("The subcollection" + collectionName + "was not found. Trying to find the cobricks collection"); --- 451,455 ---- Collection cobricks = null; ! logger.info("The subcollection" + submCollectionName + "was not found. Trying to find the cobricks collection"); *************** *** 470,474 **** // (Because we would have been returned with false, //if we had a failure while creating it) ! collection = this.createCollection(collectionName, cobricks); if (collection == null) { --- 493,497 ---- // (Because we would have been returned with false, //if we had a failure while creating it) ! collection = this.createCollection(submCollectionName, cobricks); if (collection == null) { *************** *** 493,503 **** (XMLResource) collection.createResource(String.valueOf(key), "XMLResource"); ! document.setContent(xmlData); collection.storeResource(document); logger.debug("Data inserted, id is:" + key); ! logger.debug("inserted:"+xmlData); } catch (Exception e) { logger.warn("Exception occured while trying to insert data" ! + (key)); } } else { --- 516,526 ---- (XMLResource) collection.createResource(String.valueOf(key), "XMLResource"); ! document.setContent(this.addXMLPrologue(xmlData)); collection.storeResource(document); logger.debug("Data inserted, id is:" + key); ! logger.debug("inserted:" + xmlData); } catch (Exception e) { logger.warn("Exception occured while trying to insert data" ! + (key), e); } } else { *************** *** 616,620 **** result = result + (String) res.getContent(); ! logger.debug("retrieved: "+ (String) res.getContent()); } } catch (XMLDBException e) { --- 639,643 ---- result = result + (String) res.getContent(); ! logger.debug("retrieved: " + (String) res.getContent()); } } catch (XMLDBException e) { *************** *** 630,634 **** * This method removes all xml data (NO whole documents) which is found * @param xPath The xPath of the data to delete. - * @throws Exception TBD! */ public final void removeEntry(String xPath) { --- 653,656 ---- *************** *** 647,651 **** /** ! * This method updates SIMPLE (no child nodes) xml data via passing it * directly to the XUpdate-Engine. * Also very important: The old note to update <b>must not</b> have any --- 669,673 ---- /** ! * This method updates SIMPLE (no child nodes) XML data via passing it * directly to the XUpdate-Engine. * Also very important: The old note to update <b>must not</b> have any *************** *** 653,660 **** * text, use XPath: ../text() to match. * @see http://www.xmldb.org/xupdate/xupdate-wd.html#N6d2633 ! * @param xPath The xPath where the data to update is located ! * @param simpleXML The xml data to update - no child nodes * @throws XMLDBException Common Reasons: Problem accessing the db, ! * invalid arguments (XPath wrong, xml data not simple /invalid), * old node has child nodes. */ --- 675,682 ---- * text, use XPath: ../text() to match. * @see http://www.xmldb.org/xupdate/xupdate-wd.html#N6d2633 ! * @param xPath The XPath where the data to update is located ! * @param simpleXML The XML data to update - no child nodes * @throws XMLDBException Common Reasons: Problem accessing the db, ! * invalid arguments (XPath wrong, XML data not simple /invalid), * old node has child nodes. */ *************** *** 666,671 **** " <xu:update select=\"" + xPath + "\">" + simpleXML + "</xu:update>"; ! logger.debug("Performing data update:" + xupdate); ! this.performXUpdate(xupdate); /*} catch (Exception e) { --- 688,692 ---- " <xu:update select=\"" + xPath + "\">" + simpleXML + "</xu:update>"; ! this.performXUpdate(xupdate); /*} catch (Exception e) { *************** *** 675,679 **** }*/ } else { ! logger.warn("DBAccess status is offline-can't insert" + xPath); } } --- 696,700 ---- }*/ } else { ! logger.warn("DBAccess status is offline -can't insert" + xPath); } } *************** *** 733,738 **** xupdate = xupdate + "</xu:append>"; } - - logger.debug("Performing data update:" + xupdate); this.performXUpdate(xupdate); --- 754,757 ---- *************** *** 757,761 **** * @param xml The xml data to insert * @param useInsertAfter Perform an append or an insert-after? - * @throws XMLDBException TBD! */ public final void insertEntry(String xPath, String xml, --- 776,779 ---- *************** *** 788,792 **** * @param e The base node as an dom element node. * @param useInsertAfter Use insert-after or append? ! * @throws XMLDBException TBD! */ private void insertEntry(String xPath, Element e, boolean useInsertAfter) --- 806,811 ---- * @param e The base node as an dom element node. * @param useInsertAfter Use insert-after or append? ! * @throws XMLDBException May occur - is thrown because this is only an ! * utility. */ private void insertEntry(String xPath, Element e, boolean useInsertAfter) *************** *** 830,837 **** } ! logger.debug("Perform xupdate: " + DATABASE_UPDATE_PROLOGUE + xUpdate ! + DATABASE_UPDATE_EPILOGUE); ! service.update(DATABASE_UPDATE_PROLOGUE + xUpdate ! + DATABASE_UPDATE_EPILOGUE); } --- 849,856 ---- } ! logger.debug("Perform xupdate: " + this.addXMLPrologue( ! DATABASE_UPDATE_PROLOGUE + xUpdate + DATABASE_UPDATE_EPILOGUE)); ! service.update(this.addXMLPrologue(DATABASE_UPDATE_PROLOGUE + xUpdate ! + DATABASE_UPDATE_EPILOGUE)); } *************** *** 840,847 **** * @param xPath XPath Expression: Match the nodes where to remove the attr. * @param attributeName The name of the attribute to remove ! * @throws Exception TBD! */ private void removeAttribute(String xPath, String attributeName) ! throws Exception { this.removeEntry(xPath + "/@" + attributeName); } --- 859,866 ---- * @param xPath XPath Expression: Match the nodes where to remove the attr. * @param attributeName The name of the attribute to remove ! * @throws XMLDBException May occur in case there are db problems. */ private void removeAttribute(String xPath, String attributeName) ! throws XMLDBException { this.removeEntry(xPath + "/@" + attributeName); } *************** *** 867,874 **** * @param attributeName The name of the attribute to append * @param newval The value of the attribe to append. ! * @throws Exception TBD! */ private void addAttribute(String xPath, String attributeName, String newval) ! throws Exception { String xUp = "<xu:append select=\"" + xPath + xPath + "@" + attributeName --- 886,893 ---- * @param attributeName The name of the attribute to append * @param newval The value of the attribe to append. ! * @throws XMLDBException May occur in case there are db problems. */ private void addAttribute(String xPath, String attributeName, String newval) ! throws XMLDBException { String xUp = "<xu:append select=\"" + xPath + xPath + "@" + attributeName *************** *** 1010,1017 **** * @param baseXPath The XPath which points <b>exactly</b> to the node to * update, it must not match to several nodes. - * @throws Exception TBD */ public final void update(final String oldXML, final String newXML, ! final String baseXPath) { Document oldDoc = null; Document newDoc = null; --- 1029,1035 ---- * @param baseXPath The XPath which points <b>exactly</b> to the node to * update, it must not match to several nodes. */ public final void update(final String oldXML, final String newXML, ! final String baseXPath) throws XMLDBException{ Document oldDoc = null; Document newDoc = null; *************** *** 1024,1030 **** + "Check if your old XML data is equivalent to the data in the" + " db."); ! ! return; ! } try { --- 1042,1049 ---- + "Check if your old XML data is equivalent to the data in the" + " db."); ! IllegalArgumentException ee = new IllegalArgumentException(); ! ee.setStackTrace(e.getStackTrace()); ! throw ee; ! } try { *************** *** 1033,1041 **** logger.warn("Error during update: The new XML data is not valid." + "Aborting update."); ! ! return; } - - try { logger.debug("Traversing the old data"); visitOldNode(oldDoc.getDocumentElement(), --- 1052,1059 ---- logger.warn("Error during update: The new XML data is not valid." + "Aborting update."); ! IllegalArgumentException ee = new IllegalArgumentException(); ! ee.setStackTrace(e.getStackTrace()); ! throw ee; } logger.debug("Traversing the old data"); visitOldNode(oldDoc.getDocumentElement(), *************** *** 1046,1052 **** baseXPath + "/" + oldDoc.getDocumentElement().getTagName(), newDoc.getDocumentElement()); - } catch (Exception e) { - logger.error("Exception during update", e); - } } --- 1064,1067 ---- *************** *** 1062,1069 **** * @param newNode The node corresponding to the old node (or null if * it doesn't exist). ! * @throws Exception TBD! */ private void visitOldNode(final Node oldNode, final String currentXPath, ! final Node newNode) throws Exception { if (oldNode instanceof Element && newNode instanceof Element) { //logger.debug("--Current tag: "+((Element)oldNode).getTagName()); --- 1077,1084 ---- * @param newNode The node corresponding to the old node (or null if * it doesn't exist). ! * @throws XMLDBException Is thrown if any problem is encountered. */ private void visitOldNode(final Node oldNode, final String currentXPath, ! final Node newNode) throws XMLDBException { if (oldNode instanceof Element && newNode instanceof Element) { //logger.debug("--Current tag: "+((Element)oldNode).getTagName()); *************** *** 1077,1081 **** if (((Element) newNode).hasAttribute(currAttrName)) { //Attribute was found: ! if (!((Element) newNode).getAttribute(currAttrName).equals(currAttrValue)) { //There is a difference logger.debug("Difference in attr. found: " --- 1092,1097 ---- if (((Element) newNode).hasAttribute(currAttrName)) { //Attribute was found: ! if (!((Element) newNode).getAttribute(currAttrName) ! .equals(currAttrValue)) { //There is a difference logger.debug("Difference in attr. found: " *************** *** 1181,1188 **** * @param currentXPath The XPath points to the current new node. * @param newNode The current new node. ! * @throws Exception TBD */ private void visitNewNode(final Node oldNode, final String currentXPath, ! final Node newNode) throws Exception { if (newNode instanceof Element && oldNode instanceof Element) { //Comparing the attributes: --- 1197,1204 ---- * @param currentXPath The XPath points to the current new node. * @param newNode The current new node. ! * @throws XMLDBException Is thrown if any problem is encountered. */ private void visitNewNode(final Node oldNode, final String currentXPath, ! final Node newNode) throws XMLDBException { if (newNode instanceof Element && oldNode instanceof Element) { //Comparing the attributes: *************** *** 1328,1345 **** used[j] = true; //Mark as used matchFound = true; // we have a good match - - //logger.debug("paired:"+String.valueOf(i)+"<->"+String.valueOf(j)); res[i][1] = secNodes.item(j); //store the match } - - /* - //There was no match found, but this node is still available - if (indexOfSecondChoice == -1) { //There is no second choice - - //yet - indexOfSecondChoice = j; - } - */ - // } j++; --- 1344,1349 ---- *************** *** 1348,1363 **** } - /* - - if (!matchFound && (indexOfSecondChoice != -1)) { - // There was no ideal partner found, let's give it the second - //choice - res[i][1] = secNodes.item(indexOfSecondChoice); - used[indexOfSecondChoice] = true; - } else if (!matchFound) { - //There was no ideal partner and no unused partner. - res[i][1] = null; - } - */ } --- 1352,1355 ---- *************** *** 1421,1442 **** return equals; } ! public void normalizeNodes(String docKey) throws XMLDBException { XMLResource current = (XMLResource) collection.getResource(docKey); String res = (String) current.getContent(); res = res.replaceAll(">( )*\n( )*\n", ">\n"); ! this.removeDocument(docKey); this.insertDocument(res, docKey); } /** * This method normalizes all elements of this collection. * In the current version of xindice, 1.1b3 there is still an issue that * modifiying elements with xupdate may produce blank lines between the tags ! * This can lead to huge growth. This normalizer tool removes these blank ! * lines. */ ! ! public void normalizeAllNodes() { ResourceSet toNorm = this.retrieveResources("/*"); logger.info("Starting to normalize all Elements."); --- 1413,1440 ---- return equals; } + /** + * This method normalizes one document by removing new lines between tags. + * @param docKey The document key to normalize. + * @throws XMLDBException Low-level helper method, may throw Exceptions + * from underlying engine. + */ ! private void normalizeNodes(String docKey) throws XMLDBException { XMLResource current = (XMLResource) collection.getResource(docKey); String res = (String) current.getContent(); res = res.replaceAll(">( )*\n( )*\n", ">\n"); ! this.removeDocument(docKey); this.insertDocument(res, docKey); } + /** * This method normalizes all elements of this collection. * In the current version of xindice, 1.1b3 there is still an issue that * modifiying elements with xupdate may produce blank lines between the tags ! * This can lead to huge growth. This normalizer tool removes these blank ! * lines. */ ! public final void normalizeAllNodes() { ResourceSet toNorm = this.retrieveResources("/*"); logger.info("Starting to normalize all Elements."); *************** *** 1444,1448 **** ResourceIterator it = null; int counter = 0; ! try { if (toNorm != null) { --- 1442,1446 ---- ResourceIterator it = null; int counter = 0; ! try { if (toNorm != null) { *************** *** 1480,1496 **** logger.info("Normalizing complete. Normalized " + counter); - } /** ! * Updates an existing entry by removing the old one and creating a new one * @param xmlData The new XML data to be inserted * @param key The key is needed in order to find the old information which * should be replaced. - * @deprecated don't use it anymore... use the single update/remove/insert - * entries... * */ ! public final void updateData(String xmlData, String key) { try { this.removeDocument(key); --- 1478,1493 ---- logger.info("Normalizing complete. Normalized " + counter); } /** ! * Updates an existing whole document ! * by removing the old one and creating a new one. ! * <b>Very inefficent. Use only in emergency case </b> * @param xmlData The new XML data to be inserted * @param key The key is needed in order to find the old information which * should be replaced. * */ ! public final void updateWholeDocument(String xmlData, String key) { try { this.removeDocument(key); *************** *** 1499,1504 **** + "for updating."); } ! this.insertDocument(xmlData, key); } } --- 1496,1538 ---- + "for updating."); } + this.insertDocument(xmlData, key); + } + /** + * In case the XML db is on the same machine and the new xindice 1.1 is used + * the xml db server starts at the same time cobricks does. So it is necessary + * to make a seperate init thread and let this thread wait a certain time. + */ + public final void run() { + try { + Thread.sleep(this.initDelay); + } catch (Exception e) { + logger.error("Fatal error during sleeping - init could fail", e); + } + this.init(this.collectionName, this.pathToCollection); + } ! /** ! * This method adds a xml version and encoding declaration if necessary ( ! * in case it is missing and the encoding is different from UTF-8. ! * There are known issues with xindice and encoding other than UTF-8. ! * At this time, there is no support for documents other than UTF-8 by ! * Cobricks. Maybe Xindice does in future releases a better encoding handling, ! * that's why this method is implemented. ! * But in the default case this method <b> does nothing </b>. ! * <i>There are known issues with xml encoding other than UTF-8 and there ! * might be other problems with using e.g. XUpdate-Commands with non-UTF-8 ! * encoding. </i> ! * @param input The xml data to add the prologue ! * @return xml data with prologue (if needed). ! */ ! ! ! private String addXMLPrologue(String input) { ! if ((!input.startsWith("<?")) && (!this.xmlEncoding.equals("UTF-8"))) { ! return "<?xml version=\"1.0\" encoding=\"" + this.xmlEncoding ! + "\"?>" + "\n" + input; ! } else { ! return input; ! } } } |
|
From: <j_m...@us...> - 2004-02-29 12:24:05
|
Update of /cvsroot/cobricks/cobricks2/src/org/cobricks/core In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11565/src/org/cobricks/core Modified Files: Ontology.java OntologyClass.java OntologyClassAttr.java Added Files: OntologyDataType.java Log Message: added isMultiLanguage, introduced OntologyDataType, introduced deriving of attributes --- NEW FILE: OntologyDataType.java --- package org.cobricks.core; /** * This method is a more detailed representation of the type keyword in the * OntologyClassAttr. It provides all necessary methods for handling an * ontology data type. * @author Johannes Mathes ma...@in... * */ public class OntologyDataType { /** * This constant contains all cobricks types defined in the specification. */ private static final String[] COBRICKS_TYPES = {"item", "category", "user"}; /** * The ontology type name. */ private String typeName; /** * The name of the sub type (in case there is one)- */ private String subtypeName; /** * Is this data type a set of elements? */ private boolean isSet = false; /** * Is this data type a list of elements? */ private boolean isList = false; /** * Is there a maximal length? */ private boolean hasMaxLength = false; /** * Has this data type a sub type constraint? */ private boolean hasSubtype = false; /** * The maximal length (in case there is one) */ private int maxLength; /** * Constructs a new instance of OntologyDataType using the given ontology * keyword * @param ontKeyWord The ontology keyword specifying the type (e.g. string[]) */ public OntologyDataType(String ontKeyWord) { typeName = ""; String inBrackets = ""; String inParenthesis = ""; boolean hasParenthesis; boolean hasBrackets; hasParenthesis = ontKeyWord.matches(".*\\(.*"); hasBrackets = ontKeyWord.matches(".*\\[.*"); if (hasParenthesis) { typeName = ontKeyWord.split("\\(")[0]; inParenthesis = ontKeyWord.substring(ontKeyWord.indexOf("(") + 1, ontKeyWord.indexOf(")")); if (hasBrackets) { inBrackets = ontKeyWord.substring(ontKeyWord.indexOf("[") + 1, ontKeyWord.indexOf("]")); } } else if (hasBrackets) { typeName = ontKeyWord.split("\\[")[0]; inBrackets = ontKeyWord.substring(ontKeyWord.indexOf("[") + 1, ontKeyWord.indexOf("]")); } else { typeName = ontKeyWord; } if (inParenthesis.length() > 0) { if (typeName.equals("string")) { //length constraint hasMaxLength = true; maxLength = Integer.parseInt(inParenthesis.trim()); } else { //sub type constraint hasSubtype = true; subtypeName = inParenthesis; } } if (hasBrackets) { //List or Set if (inBrackets.equals("$")) { isList = true; } else { isSet = true; } } } /** * In case the ontology data type is a Set or a List, you can use this method * to get the corresponding single data type, e.g. if the data type is set * of string (keyword: string[]), this method returns a new instance of * the string data type (keyword: string). * @return The generated data type of the collection elements. */ public final OntologyDataType getCollectionElementType() { OntologyDataType elementType = new OntologyDataType(this.getTypeName()); elementType.hasMaxLength = this.hasMaxLength(); elementType.hasSubtype = this.hasSubtype(); if (elementType.hasMaxLength) { elementType.maxLength = this.getMaxLength(); } if (elementType.hasSubtype) { elementType.subtypeName = this.getSubtypeName(); } return elementType; } /** * Is this data type a List of elements? According to the specification this * is only possible for strings. * @return true in case it is a list, false otherwise. */ public final boolean isList() { return isList; } /**Is this data type a Set of elements? * @return true in case it is a Set, false otherwise. */ public final boolean isSet() { return isSet; } /** In case there is a maximum length constraint (according to the * specification this is only possible for strings) this method returns * the maximal number of characters. * @return The maximal length in case there is one, -1 otherwise. */ public final int getMaxLength() { if (hasMaxLength) { return maxLength; } else { return -1; } } /** It is possible to define that a cobricks data type has to be a specific * sub type, e.g. the data type with the keyword item(date) is of general * type item and sub type named date (has to be defined in the ontology). * @return The sub type of a cobricks data type or null in case there is no * sub type (and / or the data type is no cobricks data type). */ public final String getSubtypeName() { if (hasSubtype) { return subtypeName; } else { return null; } } /** This method returns the name of the ontology data type (not the whole * ontology keyword), e.g. the ontology key word is int[] this method returns * "int". * @return The ontology name of this data type */ public final String getTypeName() { return typeName; } /** Is there a max length constraint for this data type? * @return true in case there is a constraint, false otherwise. */ public final boolean hasMaxLength() { return hasMaxLength; } /** Is there a sub type constraint? (Relevant for cobricks data types). * @return True in case the data type is a specific sub type of a data type, * e.g. the data type with the keyword item(date) has a sub type. */ public final boolean hasSubtype() { return hasSubtype; } /** * Is this data type a list or a set of element? * @return true in case it is a set / list, false otherwise. */ public final boolean isCollection() { return (isList || isSet); } /** * Is this data type a cobricks data type? * @return true in case it is a cobricks data type (e.g. user, category, item) * false otherwise. */ public final boolean isCobricksType() { boolean result = false; for (int i = 0; i < COBRICKS_TYPES.length; i++) { if (this.typeName.equals(COBRICKS_TYPES[i])) { result = true; } } return result; } /**@see Object.toString() * @return A String representation. */ public final String toString() { String string = typeName; if (hasSubtype) { string += ("(" + subtypeName + ")"); } if (hasMaxLength) { string += ("(" + maxLength + ")"); } if (isSet) { string += "[]"; } if (isList) { string += "[$]"; } return string; } } Index: Ontology.java =================================================================== RCS file: /cvsroot/cobricks/cobricks2/src/org/cobricks/core/Ontology.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Ontology.java 12 Feb 2004 06:25:26 -0000 1.2 --- Ontology.java 29 Feb 2004 12:06:01 -0000 1.3 *************** *** 181,190 **** String name = ((Element)n).getAttribute("name"); String type = ((Element)n).getAttribute("type"); ! String isRequired = ((Element)n).getAttribute("required"); ! OntologyClassAttr oca = new OntologyClassAttr(name, type, currentClass); if (isRequired != null && isRequired.equals("true")) { oca.setIsRequired(true); } currentClass.addAttribute(oca); currentClassAttr = oca; --- 181,197 ---- String name = ((Element)n).getAttribute("name"); String type = ((Element)n).getAttribute("type"); ! String isRequired = ((Element) n).getAttribute("required"); ! String isMultiLanguage = ! ((Element) n).getAttribute("multilanguage"); ! OntologyClassAttr oca = new OntologyClassAttr(name, type, currentClass); + // Look for things that are not obligatory to define + // in the ontology XML. if (isRequired != null && isRequired.equals("true")) { oca.setIsRequired(true); } + if (isMultiLanguage != null && isMultiLanguage.equals("true")) { + oca.setIsMultiLanguage(true); + } currentClass.addAttribute(oca); currentClassAttr = oca; *************** *** 211,215 **** else if (tagname.equals("default")) { String tmps = n.getFirstChild().getNodeValue(); ! currentClassAttr.addValue(tmps); } else if (tagname.equals("contextclass")) { --- 218,224 ---- else if (tagname.equals("default")) { String tmps = n.getFirstChild().getNodeValue(); ! //TBD: How to handle this? ! //currentClassAttr.addValue(tmps); ! currentClassAttr.setDefault(tmps); } else if (tagname.equals("contextclass")) { Index: OntologyClass.java =================================================================== RCS file: /cvsroot/cobricks/cobricks2/src/org/cobricks/core/OntologyClass.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** OntologyClass.java 12 Feb 2004 06:25:26 -0000 1.2 --- OntologyClass.java 29 Feb 2004 12:06:01 -0000 1.3 *************** *** 127,138 **** } ! public OntologyClassAttr getAttribute(String attrname) ! { ! return (OntologyClassAttr)attrs.get(attrname); } ! public Set getAttributeNames() ! { ! return attrs.keySet(); } --- 127,148 ---- } ! public OntologyClassAttr getAttribute(String attrname) { ! OntologyClassAttr oca = (OntologyClassAttr) attrs.get(attrname); ! if (this.getParent() != null && oca == null) { ! //there is a parent ontology class and the attribute was not found, ! //-->lookup at the parent ontology class. ! return this.getParent().getAttribute(attrname); ! } else { ! return oca; ! } } ! public Set getAttributeNames() { ! if (getParent()!= null) { ! return this.getParent().getAttributeNamesRecursive(attrs.keySet()); ! } else { ! return attrs.keySet(); ! } ! } *************** *** 165,167 **** --- 175,188 ---- } + protected Set getAttributeNamesRecursive(Set previous){ + Set tmp = new HashSet(previous); + //Because this method is only for attribute names, there is no problem + // with eventually overwriting entries with parent entries. + tmp.addAll(this.attrs.keySet()); + if (this.getParent() != null) { + return this.getParent().getAttributeNamesRecursive(tmp); + } else { + return tmp; + } + } } Index: OntologyClassAttr.java =================================================================== RCS file: /cvsroot/cobricks/cobricks2/src/org/cobricks/core/OntologyClassAttr.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** OntologyClassAttr.java 12 Feb 2004 06:25:26 -0000 1.2 --- OntologyClassAttr.java 29 Feb 2004 12:06:01 -0000 1.3 *************** *** 38,49 **** protected OntologyClass oclass; ! protected String name; protected boolean required; - protected String type; protected String defaultValue; protected String contextClassName; protected List values; protected Map descriptions; --- 38,50 ---- protected OntologyClass oclass; ! protected String type; //TBD: Is it still necessary? protected String name; protected boolean required; protected String defaultValue; protected String contextClassName; protected List values; protected Map descriptions; + protected OntologyDataType ontologyDataType; + protected boolean multiLanguage; *************** *** 53,61 **** public OntologyClassAttr(String name, String type, OntologyClass oclass) { this.name = name; ! this.type = type; this.oclass = oclass; values = new ArrayList(); descriptions = new HashMap(); required = false; } --- 54,65 ---- public OntologyClassAttr(String name, String type, OntologyClass oclass) { this.name = name; ! this.ontologyDataType = new OntologyDataType(type); this.oclass = oclass; + this.type = type; values = new ArrayList(); descriptions = new HashMap(); required = false; + this.multiLanguage = false; + this.defaultValue = null; } *************** *** 73,82 **** } ! public String getType() { ! return type; } ! public void setType(String type) { ! this.type = type; } --- 77,86 ---- } ! public OntologyDataType getOntologyDataType() { ! return ontologyDataType; } ! public void setOntologyDataType(String type) { ! this.ontologyDataType = new OntologyDataType(type); } *************** *** 102,105 **** --- 106,110 ---- public List getValues() { + return values; } *************** *** 129,132 **** return this.required; } ! } --- 134,157 ---- return this.required; } ! public void setType(String type) { //TBD: Still necessary? ! this.type = type; ! this.ontologyDataType = new OntologyDataType(type); ! } ! public String getType(){ //TBD: Still necessary? ! return this.type; ! } ! /** Is this attribute used in multiple languages? ! * @return True in case it is a multiple language attribute, false otherwise ! */ ! public boolean isMultiLanguage() { ! return multiLanguage; ! } ! ! /** Sets if this attribute is used in multiple languages ! * @param b True in case it is a multiple language attribute, false otherwise ! */ ! public void setIsMultiLanguage(boolean b) { ! multiLanguage = b; ! } ! } |
|
From: <j_m...@us...> - 2004-02-29 12:22:43
|
Update of /cvsroot/cobricks/cobricks2/src/org/cobricks/item In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11346/src/org/cobricks/item Modified Files: ItemServlet.java Log Message: Index: ItemServlet.java =================================================================== RCS file: /cvsroot/cobricks/cobricks2/src/org/cobricks/item/ItemServlet.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ItemServlet.java 11 Feb 2004 14:31:52 -0000 1.1 --- ItemServlet.java 29 Feb 2004 12:04:39 -0000 1.2 *************** *** 6,18 **** * Copyright (c) 2003 Michael Koch, mic...@co... */ - package org.cobricks.item; - import java.io.*; - import java.net.URL; - import java.util.*; - import javax.servlet.*; - import javax.servlet.http.*; - import org.apache.log4j.*; --- 6,11 ---- *************** *** 20,61 **** import org.cobricks.core.ComponentManagerInterface; import org.cobricks.core.util.LogUtil; import org.cobricks.portal.PortalServletAdaptor; import org.cobricks.portal.PortalUser; ! public class ItemServlet extends PortalServletAdaptor ! { ! static Logger logger = Logger.getLogger(ItemServlet.class); protected ItemManager itemManager; - /** * */ ! public void performLogin(HttpServletRequest request, ! HttpServletResponse response, ! PrintWriter out, PortalUser user) { ! logger.info(">>>>>>>>perfomLogin()!!!!!"); } - /** * */ ! public void init(ServletConfig config) ! throws ServletException { ! super.init(config); ! ! this.addTarget("login", "performLogin", "", false); ! ! ComponentDirectory componentDirectory = ! coreManager.getComponentDirectory(); ! itemManager = (ItemManager)componentDirectory.getManager("item"); ! if (itemManager==null) { ! logger.error("Did not find item manager in ComponentDirectory!"); ! } } } --- 13,128 ---- import org.cobricks.core.ComponentManagerInterface; import org.cobricks.core.util.LogUtil; + + import org.cobricks.portal.PortalRequest; import org.cobricks.portal.PortalServletAdaptor; import org.cobricks.portal.PortalUser; + import java.io.*; ! import java.net.URL; ! import java.util.*; + import javax.servlet.*; + import javax.servlet.http.*; + + + public class ItemServlet extends PortalServletAdaptor { + static Logger logger = Logger.getLogger(ItemServlet.class); protected ItemManager itemManager; /** * */ ! public void performLogin(HttpServletRequest request, ! HttpServletResponse response, PrintWriter out, PortalUser user) { ! logger.info(">>>>>>>>perfomLogin()!!!!!"); } /** * */ ! public void init(ServletConfig config) throws ServletException { ! super.init(config); ! ! this.addTarget("login", "performLogin", "", false); ! this.addTarget("createitem", "performCreateItem", "Create a new item"); ! ! ComponentDirectory componentDirectory = ! coreManager.getComponentDirectory(); ! itemManager = ! (ItemManager) componentDirectory.getManager("itemManager"); ! ! if (itemManager == null) { ! logger.error("Did not find item manager in ComponentDirectory!"); ! } } + public final String performCreateItem(PortalRequest prequest, PrintWriter out) { + Map attrs = this.buildItemAttrsMap(prequest); + List messages = new LinkedList(); + if (attrs.containsKey("errors")) { + logger.info("Errors encountered"); + prequest.setContextObject("errors",attrs.get("errors")); + out.write(attrs.get("errors").toString()); + + return null; + + //return "error"; + } else { + Item it = itemManager.createItem(attrs); + + if (it != null) { + out.write("Success:+" + it.getLocalId()); + + return null; + } else { + out.write("Null error"); + + return null; + } + + //return "success"; + } + } + + private Map buildItemAttrsMap(PortalRequest pRequest) { + Set errors = new HashSet(); + Map tmp = pRequest.getRequestParameters(); + Map result = new HashMap(); + String itemClassName = (String) tmp.get("itemclass"); + + // (String) tmp.remove("itemclass"); + Iterator it = tmp.keySet().iterator(); + + while (it.hasNext()) { + String currentParam = (String) it.next(); + String input = (String) pRequest.getRequestParameter(currentParam); + + if (!currentParam.matches("cmd.*") && input != null && input.length()>0) { + logger.debug(currentParam); + + Object attr = + ItemAttrs.instantiateAttribute(this.itemManager, + input, currentParam, + itemClassName); + + if (attr instanceof InputError) { + ((InputError) attr).setEnvironment(currentParam); + errors.add(attr); + } else if (attr != null) { + result.put(currentParam, attr); + } else { + logger.warn("can't handle: " + currentParam); + } + } + } + + if (errors.isEmpty()) { + return result; + } else {result = new HashMap(); + result.put("errors", errors); + return result; + } + } } |
|
From: <j_m...@us...> - 2004-02-29 12:22:29
|
Update of /cvsroot/cobricks/cobricks2/src/org/cobricks/item In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11310/src/org/cobricks/item Modified Files: ItemPresenter.java Log Message: Index: ItemPresenter.java =================================================================== RCS file: /cvsroot/cobricks/cobricks2/src/org/cobricks/item/ItemPresenter.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ItemPresenter.java 11 Feb 2004 14:31:52 -0000 1.1 --- ItemPresenter.java 29 Feb 2004 12:04:25 -0000 1.2 *************** *** 16,19 **** --- 16,24 ---- import org.cobricks.core.ComponentPresenterInterface; import org.cobricks.core.util.LogUtil; + import org.cobricks.core.Ontology; + import org.cobricks.core.OntologyClassAttr; + import org.cobricks.core.OntologyDataType; + import org.cobricks.core.OntologyClass; + import java.util.List; *************** *** 21,28 **** implements ComponentPresenterInterface { ! static Logger logger = Logger.getLogger(ItemPresenter.class); ! /** * --- 26,36 ---- implements ComponentPresenterInterface { ! private static String DEFAULT_ITEM_CREATION_ITEM_CLASS = "item"; ! private static String[] LANGUAGES = {"de", "en", "fr"}; static Logger logger = Logger.getLogger(ItemPresenter.class); + private Ontology ontology = null; ! private ItemManager itemManager = null; ! private CoreManager coreManager = null; /** * *************** *** 36,39 **** --- 44,51 ---- throws Exception { logger.info("Initializing item presenter"); + this.itemManager = (ItemManager) coreManager.getComponentDirectory(). + getManager("itemManager"); + this.coreManager = coreManager; + ontology = itemManager.getOntology(); } *************** *** 49,53 **** return "/item/itemclass=item"; } - } --- 61,164 ---- return "/item/itemclass=item"; } + public String printAttrInput(String itemClass, String aname, int rows,int cols){ + String result = ""; + OntologyClassAttr oca = this.ontology.getClass(itemClass).getAttribute(aname); + OntologyDataType odat = oca.getOntologyDataType(); + String defaultVal = oca.getDefault(); + if (!oca.getValues().isEmpty()){ //There are possible values + result += "<select name=\""+aname+"\" size=\"1\">\n"; + List options = oca.getValues(); + Iterator it = options.iterator(); + //result += "<option selected=\"selected\">" + + //(String) it.next() + "</option>"; + String next; + while (it.hasNext()){ + result += "<option"; + next = (String) it.next(); + if (defaultVal !=null && next.equals(defaultVal)) { + result+=" selected=\"selected\""; + } + result +=">" + next + "</option>\n"; + } + result += "</select>"; + } else if (odat.getTypeName().equals("boolean")){ + result += "<input type=\"checkbox\" name=\"" + aname + "\" value=" + + "\"true\""; + if (defaultVal !=null && defaultVal.equals("true")) { + result+=" checked=\"checked\""; + } + result+= "/>"; + } else if (rows < 2){ + result += "<input name=\"" + aname + "\" type=\"text\""; + if (odat.hasMaxLength()){ + result += " size=\"" + odat.getMaxLength() + "\" maxlength=\""+ + odat.getMaxLength() + "\""; + }else{ + result += " size=\"" + cols + "\""; + } + if (defaultVal != null) { + result += " value=\"" + defaultVal + "\""; + } + result += "/>"; + } else { + result += "<textarea name=\"" + aname + "\" cols=\"" + cols + + "\" rows=\"" + rows + "\">"; + if (defaultVal != null) { + result += defaultVal; + } + result += "</textarea>"; + } + return result; + } + + public String printMultiLangDropDown(String defaultLang){ + String result = "<select size=1>\n"; + for(int i=0; i<LANGUAGES.length; i++){ + result += "<option"; + if(LANGUAGES[i].equals(defaultLang)){ + result += " selected=\"selected\""; + } + result += ">" + LANGUAGES[i] + "</option>\n"; + } + result += "</select>"; + return result; + } + + public String printItemClassesDropDown(String defaultClassName){ + String result = "<select size=1>\n"; + Collection classes = this.ontology.getClasses(); + Iterator iter = classes.iterator(); + String className; + while(iter.hasNext()){ + className = ((OntologyClass)iter.next()).getName(); + result += "<option"; + if(className.equals(defaultClassName)){ + result += " selected=\"selected\""; + } + result += ">" + className + "</option>\n"; + } + result += "</select>"; + return result; + } + + public String printHiddenAttr(String name, String value){ + return "<input type=\"hidden\" name=\"" + name + "\" value=\"" + + value +"\"/>"; + } + + + public Set getAttributeNames(String itemClassName) { + OntologyClass oc = ontology.getClass(itemClassName); + if (oc == null && !itemClassName.equals(DEFAULT_ITEM_CREATION_ITEM_CLASS) ) { + logger.warn("Item class "+ itemClassName + " not found. Returning default"); + return this.getAttributeNames(DEFAULT_ITEM_CREATION_ITEM_CLASS); + } else if (oc==null){ + logger.error("Default item class not available. Check Ontology!"); + return new HashSet(); + } else { + return oc.getAttributeNames(); + } + } + } |
|
From: <j_m...@us...> - 2004-02-29 12:22:16
|
Update of /cvsroot/cobricks/cobricks2/src/org/cobricks/item In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11268/src/org/cobricks/item Modified Files: ItemManagerImpl.java Log Message: Index: ItemManagerImpl.java =================================================================== RCS file: /cvsroot/cobricks/cobricks2/src/org/cobricks/item/ItemManagerImpl.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** ItemManagerImpl.java 21 Feb 2004 18:49:40 -0000 1.4 --- ItemManagerImpl.java 29 Feb 2004 12:04:12 -0000 1.5 *************** *** 12,15 **** --- 12,16 ---- import org.cobricks.core.OntologyClass; import org.cobricks.core.OntologyClassAttr; + import org.cobricks.core.OntologyDataType; import org.cobricks.core.db.DBAccess; import org.cobricks.core.util.LogUtil; *************** *** 84,87 **** --- 85,100 ---- private XMLDBAccess xmlDBAccess; private ItemManagerDB itemManagerDB; + /** + * This is used for setting the System Property file encoding. + * See documentation for details, be careful! + */ + private String javaEncoding = "UTF-8"; + + /** + * This has to be equivalent with the java setting. (Sometimes java encoding + * names differ from xml encoding names). + */ + + private String xmlEncoding = "UTF-8"; //private org.cobricks.item.xmldb.XMLDBAccess xmlDB; *************** *** 168,178 **** itemCache = new ItemCache(cacheSize); logger.info("Initializing the XML database"); ! xmlDBAccess = new XMLDBAccess(properties, "item", (String) properties.get("configdir") + File.separator + componentId + File.separator + "dbxml" + File.separator + "item.xml"); this.itemManagerDB = new ItemManagerDB(this, coreManager.getDBAccess(), this.xmlDBAccess); } --- 181,208 ---- itemCache = new ItemCache(cacheSize); logger.info("Initializing the XML database"); ! xmlDBAccess = new XMLDBAccess(properties, "item", (String) properties.get("configdir") + File.separator + componentId + File.separator + "dbxml" + File.separator + "item.xml"); + + /*xmlDBAccess = new XMLDBAccess(properties); + xmlDBAccess.init("item", (String) + properties.get("configdir") + File.separator + + componentId + File.separator + "dbxml" + File.separator + + "item.xml"); */ + Thread init = new Thread((Runnable) this.xmlDBAccess , "init"); + + init.start(); + this.itemManagerDB = new ItemManagerDB(this, coreManager.getDBAccess(), this.xmlDBAccess); + if (properties.getProperty("item.java.file.encoding") != null){ + this.javaEncoding = properties.getProperty("item.java.file.encoding"); + } + if (properties.getProperty("item.xml.encoding")!= null){ + this.xmlEncoding = properties.getProperty("item.xml.encoding"); + } + System.setProperty("file.encoding" , this.javaEncoding); } *************** *** 239,246 **** public final Item createItem(Map attrs) { ! //I. Handle the two itemids String globalid; ! //Default policy: This is a create Method, so there must not be a given //id - it has to be created by the system, --> no interference with //other items! --- 269,276 ---- public final Item createItem(Map attrs) { ! //I. Handle the two item ids String globalid; ! //Default policy: This is a create method, so there must not be a given //id - it has to be created by the system, --> no interference with //other items! *************** *** 257,268 **** if (attrs != null) { ! //get the correct itemclass Object (not the string name) ! OntologyClass[] itemclasses = ! ItemAttrs.getItemClasses(ontology, itemClassName); //This step ensures that in case the itemClassName is //null / incorrect, the correct name is used ! itemClassName = itemclasses[0].getName(); ! //From now on, attrs contains only correct atrributes and an itemclass //value //III. Distribute the items in the correct tables --- 287,298 ---- if (attrs != null) { ! //get the correct item class object (not the string name) ! OntologyClass itemclass = ! ItemAttrs.getItemClass(ontology, itemClassName); //This step ensures that in case the itemClassName is //null / incorrect, the correct name is used ! itemClassName = itemclass.getName(); ! //From now on, attributes contains only correct attributes and an itemclass //value //III. Distribute the items in the correct tables *************** *** 299,303 **** String ckey = (String) keys[i]; itemManagerDB.storeAttribute(attrs.get(ckey), ckey, ! itemclasses, itemid); attrs.remove(ckey); } --- 329,333 ---- String ckey = (String) keys[i]; itemManagerDB.storeAttribute(attrs.get(ckey), ckey, ! itemclass, itemid); attrs.remove(ckey); } *************** *** 519,524 **** //get the correct itemclasses (not the string name) ! OntologyClass[] itemclasses = ! ItemAttrs.getItemClasses(ontology, itemClassName); //See the differences between the attributes --- 549,554 ---- //get the correct itemclasses (not the string name) ! OntologyClass itemclass = ! ItemAttrs.getItemClass(ontology, itemClassName); //See the differences between the attributes *************** *** 536,540 **** //This step ensures that in case the itemClassName is //null / incorrect, the correct name is used ! itemClassName = itemclasses[0].getName(); //III. Distribute the items in the correct tables --- 566,570 ---- //This step ensures that in case the itemClassName is //null / incorrect, the correct name is used ! itemClassName = itemclass.getName(); //III. Distribute the items in the correct tables *************** *** 542,546 **** //remove the attributes they insert: HashMap itemCacheAtts = new HashMap(attrs); ! //dbItem=all values which are stored in the table named item //III. a) Update the attributes to the special table item, if necessary --- 572,577 ---- //remove the attributes they insert: HashMap itemCacheAtts = new HashMap(attrs); ! Item it = new Item(this, itemid, globalid, itemClassName); ! it.setFromHashMap(itemCacheAtts); //dbItem=all values which are stored in the table named item //III. a) Update the attributes to the special table item, if necessary *************** *** 575,579 **** //Remove from RDB if (!ItemAttrs.attributeIsInMainTable(next)) { ! itemManagerDB.removeAttribute(next, itemclasses, itemid); } //Remove from XMLDB --- 606,610 ---- //Remove from RDB if (!ItemAttrs.attributeIsInMainTable(next)) { ! itemManagerDB.removeAttribute(next, itemclass, itemid); } //Remove from XMLDB *************** *** 584,602 **** //III. b) update the changed attrs ite = ((Set) diff.get("updated")).iterator(); ! while (ite.hasNext()) { ! String currentName = (String) ite.next(); ! if (!ItemAttrs.attributeIsInMainTable(currentName)) { ! itemManagerDB.updateAttribute(attrs.get(currentName), ! oldAtts.get(currentName), ! currentName, ! itemclasses, ! itemid); } ! ! itemManagerDB.updateAttributeXMLDB(currentName, ! oldItem, ! item, ! itemclasses); ! logger.debug("updated: " + currentName); } --- 615,637 ---- //III. b) update the changed attrs ite = ((Set) diff.get("updated")).iterator(); + try { + while (ite.hasNext()) { + String currentName = (String) ite.next(); + if (!ItemAttrs.attributeIsInMainTable(currentName)) { + itemManagerDB.updateAttribute(attrs.get(currentName), + oldAtts.get(currentName), + currentName, + itemclass, + itemid); } ! itemManagerDB.updateAttributeXMLDB(currentName, ! oldItem, ! item, ! itemclass); ! logger.debug("updated: " + currentName); ! } ! } catch (Exception e) { ! logger.warn("Exception occured while updating single attributes" + "in xmldb."); ! this.itemManagerDB.performSafeUpdate(it); } *************** *** 608,618 **** if (!ItemAttrs.attributeIsInMainTable(currentName)) { itemManagerDB.storeAttribute(attrs.get(currentName), currentName, ! itemclasses, itemid); } itemManagerDB.insertAttributeXML(currentName, item); logger.debug("added: " + currentName); } //instantiate item for the item cache ! Item it = new Item(this, itemid, globalid, itemClassName); ! it.setFromHashMap(itemCacheAtts); itemCache.updateItem(it); } --- 643,652 ---- if (!ItemAttrs.attributeIsInMainTable(currentName)) { itemManagerDB.storeAttribute(attrs.get(currentName), currentName, ! itemclass, itemid); } itemManagerDB.insertAttributeXML(currentName, item); logger.debug("added: " + currentName); } //instantiate item for the item cache ! itemCache.updateItem(it); } *************** *** 627,650 **** /** ! * Instantiates an Object of type User, Item or Category ! * @param ontologyType HashMap consisting of: String: keyWordName, ! * String:inBrackets, String:inParanthesis, Boolean:hasBrackets, ! * Boolean:hasParanthesis * @param id The ID of the specified attribute ! * @return An Object of type User, Item or Category */ ! private Object instantiate(HashMap ontologyType, int id) { ! boolean hasBrackets = ! ((Boolean) ontologyType.get("hasBrackets")).booleanValue(); ! boolean hasParanthesis = ! ((Boolean) ontologyType.get("hasParanthesis")).booleanValue(); ! String keyWordName = (String) ontologyType.get("keyWordName"); ! String inBrackets = (String) ontologyType.get("inBrackets"); ! String inParanthesis = (String) ontologyType.get("inParanthesis"); ! logger.debug("instantiate: " + keyWordName + " with ID " + new Integer(id).toString()); ! if (keyWordName.equals("user")) { try { UserManager userManager = --- 661,677 ---- /** ! * Instantiates an object of type User, Item or Category ! * @param ontType The ontology data type * @param id The ID of the specified attribute ! * @return An object of type User, Item or Category */ ! protected Object instantiate(OntologyDataType ontType, int id) { ! String typeName = ontType.getTypeName(); ! ! logger.debug("instantiate: " + typeName + " with ID " + new Integer(id).toString()); ! if (typeName.equals("user")) { try { UserManager userManager = *************** *** 653,659 **** User user = userManager.getUser(id); ! if (hasParanthesis) { //user(userclassname) ! if (user.getObjectClass().equals(inParanthesis)) { //tbd: getObjectClass() is the wrong method //and do another check (user could be in a userclass --- 680,686 ---- User user = userManager.getUser(id); ! if (ontType.hasSubtype()) { //user(userclassname) ! if (user.getObjectClass().equals(ontType.getSubtypeName())) { //tbd: getObjectClass() is the wrong method //and do another check (user could be in a userclass *************** *** 679,683 **** return null; } ! } else if (keyWordName.equals("category")) { try { CategoryManager categoryManager = --- 706,710 ---- return null; } ! } else if (typeName.equals("category")) { try { CategoryManager categoryManager = *************** *** 686,692 **** Category category = categoryManager.getCategory(id); ! if (hasParanthesis) { //category(categoryclassname) ! if (category.getCategoryClass().equals(inParanthesis)) { //category belongs to the correct categoryclass return category; --- 713,719 ---- Category category = categoryManager.getCategory(id); ! if (ontType.hasSubtype()) { //category(categoryclassname) ! if (category.getCategoryClass().equals(ontType.getSubtypeName())) { //category belongs to the correct categoryclass return category; *************** *** 708,718 **** return null; } ! } else if (keyWordName.equals("item")) { try { Item item = this.getItem(id); ! if (hasParanthesis) { //item(itemclassname) ! if (item.getItemClass().equals(inParanthesis)) { //item belongs to the correct itemclass return item; --- 735,745 ---- return null; } ! } else if (typeName.equals("item")) { try { Item item = this.getItem(id); ! if (ontType.hasSubtype()) { //item(itemclassname) ! if (item.getItemClass().equals(ontType.getSubtypeName())) { //item belongs to the correct itemclass return item; *************** *** 735,739 **** } } else { ! logger.warn("instantiate: Illegal argument: " + keyWordName); return null; --- 762,766 ---- } } else { ! logger.warn("instantiate: Illegal argument: " + typeName); return null; *************** *** 746,774 **** * @param n Node where the information about the String or the Set of String * is stored ! * @param ontologyType HashMap consisting of: String: keyWordName, ! * String:inBrackets, String:inParanthesis, Boolean:hasBrackets, ! * Boolean:hasParanthesis ! * @param ontKeyWord String that specifies the datatype for org.w3c.dom.Node * n according to the ontology * @return String or Set of String */ ! private Object handleString(Node n, HashMap ontologyType, String ontKeyWord) { ! boolean hasBrackets = ! ((Boolean) ontologyType.get("hasBrackets")).booleanValue(); ! boolean hasParanthesis = ! ((Boolean) ontologyType.get("hasParanthesis")).booleanValue(); ! String keyWordName = (String) ontologyType.get("keyWordName"); ! String inBrackets = (String) ontologyType.get("inBrackets"); ! String inParanthesis = (String) ontologyType.get("inParanthesis"); ! if (hasBrackets) { ! if (hasParanthesis) { //error (wrong syntax) logger.warn("handleString: Error while processing an " ! + "ontology keyword. Check syntax of " + ontKeyWord); ! return null; } ! if (inBrackets.equals("$")) { //List of string LinkedList list = new LinkedList(); --- 773,791 ---- * @param n Node where the information about the String or the Set of String * is stored ! * @param ontologyType The ontology data type * n according to the ontology * @return String or Set of String */ ! private Object handleString(Node n, OntologyDataType ontologyType) ! throws java.lang.StringIndexOutOfBoundsException { ! if (ontologyType.isCollection()) { ! if (ontologyType.hasMaxLength()) { //error (wrong syntax) logger.warn("handleString: Error while processing an " ! + "ontology keyword. Check syntax of " + ontologyType.toString()); return null; } ! if (ontologyType.isList()) { //List of string LinkedList list = new LinkedList(); *************** *** 776,780 **** while (child != null) { ! Object temp = extractFromXMLNode(child, "string"); if (temp != null) { --- 793,797 ---- while (child != null) { ! Object temp = extractFromXMLNode(child, ontologyType.getCollectionElementType()); if (temp != null) { *************** *** 790,794 **** return null; } ! } else if (inBrackets.equals("")) { //Set of string HashSet set = new HashSet(); --- 807,811 ---- return null; } ! } else if (ontologyType.isSet()) { //Set of string HashSet set = new HashSet(); *************** *** 796,800 **** while (child != null) { ! Object temp = extractFromXMLNode(child, keyWordName); if (temp != null) { --- 813,818 ---- while (child != null) { ! ! Object temp = extractFromXMLNode(child, ontologyType.getCollectionElementType()); if (temp != null) { *************** *** 812,840 **** } else { //error (wrong syntax) logger.warn("handleString: Error while processing an " ! + "ontology keyword. Check syntax of " + ontKeyWord); ! ! return null; ! } ! } else if (hasParanthesis) { //string with length descriptor ! ! int length; ! ! try { ! length = Integer.parseInt(inParanthesis); ! } catch (NumberFormatException e) { ! logger.warn(LogUtil.exception("handleString: Error while " ! + "trying to get the length descriptor of " ! + ontKeyWord, e)); return null; } String value = n.getFirstChild().getNodeValue(); ! if (value.length() > length) { //string is too long logger.info("handleString: String " + value + " is too " + "long. I have to shorten it."); ! return value.substring(0, length); } else { return value; --- 830,846 ---- } else { //error (wrong syntax) logger.warn("handleString: Error while processing an " ! + "ontology keyword. Check syntax of " + ontologyType.toString()); return null; } + } else if (ontologyType.hasMaxLength()) { //string with length descriptor String value = n.getFirstChild().getNodeValue(); ! if (value.length() > ontologyType.getMaxLength()) { //string is too long logger.info("handleString: String " + value + " is too " + "long. I have to shorten it."); ! return value.substring(0, ontologyType.getMaxLength()); } else { return value; *************** *** 851,879 **** * @param n Node where the information about the Integer or the Set of * Integer is stored ! * @param ontologyType HashMap consisting of: String: keyWordName, ! * String:inBrackets, String:inParanthesis, Boolean:hasBrackets, ! * Boolean:hasParanthesis ! * @param ontKeyWord String that specifies the datatype for org.w3c.dom.Node * n according to the ontology * @return Integer or Set of Integer */ ! private Object handleInt(Node n, HashMap ontologyType, String ontKeyWord) { ! boolean hasBrackets = ! ((Boolean) ontologyType.get("hasBrackets")).booleanValue(); ! boolean hasParanthesis = ! ((Boolean) ontologyType.get("hasParanthesis")).booleanValue(); ! String keyWordName = (String) ontologyType.get("keyWordName"); ! String inBrackets = (String) ontologyType.get("inBrackets"); ! String inParanthesis = (String) ontologyType.get("inParanthesis"); ! if (hasParanthesis) { //error (wrong syntax) logger.warn("handleInt: Error while processing an " ! + "ontology keyword. Check syntax of " + ontKeyWord); return null; } ! if (hasBrackets) { ! if (inBrackets.equals("")) { //Set of Integer HashSet set = new HashSet(); --- 857,875 ---- * @param n Node where the information about the Integer or the Set of * Integer is stored ! * @param ontType The ontology data type * n according to the ontology * @return Integer or Set of Integer */ ! private Object handleInt(Node n, OntologyDataType ontType) { ! if (ontType.hasMaxLength() || ontType.hasSubtype()) { //error (wrong syntax) logger.warn("handleInt: Error while processing an " ! + "ontology keyword. Check syntax of " + ontType.toString()); return null; } ! ! if (ontType.isSet()) { //Set of Integer HashSet set = new HashSet(); *************** *** 881,885 **** while (child != null) { ! Object temp = extractFromXMLNode(child, keyWordName); if (temp != null) { --- 877,881 ---- while (child != null) { ! Object temp = extractFromXMLNode(child, ontType); if (temp != null) { *************** *** 895,904 **** return null; } ! } else { //error (wrong syntax) logger.warn("handleInt: Error while processing an " ! + "ontology keyword. Check syntax of " + ontKeyWord); return null; ! } } else { //int (->Integer) --- 891,900 ---- return null; } ! } else if(ontType.isList()) { //error (wrong syntax) logger.warn("handleInt: Error while processing an " ! + "ontology keyword. Check syntax of " + ontType.toString()); return null; ! } else { //int (->Integer) *************** *** 946,1004 **** * the handleString-method, to handle Integer it calls the method handleInt. * @param n The org.w3c.dom.Node that should be extracted ! * @param ontKeyWord String that specifies the datatype for org.w3c.dom.Node n ! * according to the ontology * @return The Object of type List of String, Set of String, Set of Integer, * Set of User, Set of Item, Set of Category, String, Integer, Boolean, User * , Category, Item, Date, Datetime if possible; otherwise null */ ! private Object extractFromXMLNode(Node n, String ontKeyWord) { if (n instanceof Element) { - // I. Splitting the keyword into separate pieces: Name, content - // of brackets and content of paranthesis - HashMap ontologyType; - - try { - ontologyType = ItemAttrs.tokenizeOntologyKeyWord(ontKeyWord); - } catch (java.lang.StringIndexOutOfBoundsException e) { - logger.warn( - "Error while parsing an ontology Keyword. Check Syntax of " - + ontKeyWord); - - return null; - } try { ! boolean hasBrackets = ! ((Boolean) ontologyType.get("hasBrackets")).booleanValue(); ! boolean hasParanthesis = ! ((Boolean) ontologyType.get("hasParanthesis")).booleanValue(); ! String keyWordName = (String) ontologyType.get("keyWordName"); ! String inBrackets = (String) ontologyType.get("inBrackets"); ! String inParanthesis = ! (String) ontologyType.get("inParanthesis"); ! ! if (keyWordName.equals("string")) { ! return handleString(n, ontologyType, ontKeyWord); ! } else if (keyWordName.equals("int")) { ! return handleInt(n, ontologyType, ontKeyWord); ! } else if ((keyWordName.equals("user")) ! || (keyWordName.equals("item")) ! || (keyWordName.equals("category"))) { ! if (hasBrackets) { ! if (inBrackets.equals("")) { //Set of user, HashSet set = new HashSet(); Node child = n.getFirstChild(); ! String argument = keyWordName; ! ! if (hasParanthesis) { //Set of user(userclassname), ! ! //item(itemclassname) or category(categoryclassname) ! argument += ("(" + inParanthesis + ")"); ! } ! while (child != null) { Object temp = ! extractFromXMLNode(child, argument); if (temp != null) { --- 942,971 ---- * the handleString-method, to handle Integer it calls the method handleInt. * @param n The org.w3c.dom.Node that should be extracted ! * @param ontType The ontology data type for org.w3c.dom.Node n * @return The Object of type List of String, Set of String, Set of Integer, * Set of User, Set of Item, Set of Category, String, Integer, Boolean, User * , Category, Item, Date, Datetime if possible; otherwise null */ ! private Object extractFromXMLNode(Node n, OntologyDataType ontType) { if (n instanceof Element) { try { ! String typeName = ontType.getTypeName(); ! if (typeName.equals("string")) { ! return handleString(n, ontType); ! } else if (typeName.equals("int")) { ! return handleInt(n, ontType); ! } else if ((typeName.equals("user")) ! || (typeName.equals("item")) ! || (typeName.equals("category"))) { ! ! if (ontType.isSet()) { //Set of user, item or category HashSet set = new HashSet(); Node child = n.getFirstChild(); ! while (child != null) { Object temp = ! extractFromXMLNode(child, ontType.getCollectionElementType()); if (temp != null) { *************** *** 1014,1025 **** return null; } ! } else { //error (wrong syntax) logger.warn( "extractFromXMLNode: Error while processing an " + "ontology keyword. Check syntax of " ! + ontKeyWord); return null; ! } } else { //user,user(userclassname),item,item(itemclassname), --- 981,992 ---- return null; } ! } else if(ontType.isList()) { //error (wrong syntax) logger.warn( "extractFromXMLNode: Error while processing an " + "ontology keyword. Check syntax of " ! + ontType.toString()); return null; ! } else { //user,user(userclassname),item,item(itemclassname), *************** *** 1028,1084 **** Integer.parseInt(((Element) n).getAttribute("id")); ! return instantiate(ontologyType, id); } ! } else if (keyWordName.equals("date")) { ! if (hasBrackets || hasParanthesis) { //error (wrong syntax) ! logger.warn( ! "extractFromXMLNode: Error while processing an " ! + "ontology keyword. Check syntax of " + ontKeyWord); return null; ! } else { //date DateFormat dateFormat = DateFormat.getDateInstance(); return dateFormat.parse(n.getFirstChild().getNodeValue()); ! } ! } else if (keyWordName.equals("datetime")) { ! if (hasBrackets || hasParanthesis) { //error (wrong syntax) ! logger.warn( ! "extractFromXMLNode: Error while processing an " ! + "ontology keyword. Check syntax of " + ontKeyWord); ! ! return null; ! } else { //datetime (->Timestamp) return Timestamp.valueOf(n.getFirstChild().getNodeValue()); ! } ! } else if ((keyWordName.equals("uri")) ! || (keyWordName.equals("text"))) { ! if (hasBrackets || hasParanthesis) { //error (wrong syntax) ! logger.warn( ! "extractFromXMLNode: Error while processing an " ! + "ontology keyword. Check syntax of " + ontKeyWord); ! ! return null; ! } else { //uri or text (->String) return (n.getFirstChild().getNodeValue()); ! } ! } else if (keyWordName.equals("boolean")) { ! if (hasBrackets || hasParanthesis) { //error (wrong syntax) ! logger.warn( ! "extractFromXMLNode: Error while processing an " ! + "ontology keyword. Check syntax of " + ontKeyWord); ! ! return null; ! } else { //boolean return Boolean.valueOf(n.getFirstChild().getNodeValue()); ! } } else { // not supported datatype logger.warn("extractFromXMLNode: Missing or not supported " ! + "datatype: " + keyWordName); return null; --- 995,1031 ---- Integer.parseInt(((Element) n).getAttribute("id")); ! return instantiate(ontType, id); } ! } else if (ontType.isCollection() || ontType.hasMaxLength() ! || ontType.hasSubtype()) { //error (wrong syntax) ! logger.warn( ! "extractFromXMLNode: Error while processing an " ! + "ontology keyword. Check syntax of " + ontType.toString()); return null; ! ! } else if (typeName.equals("date")) { //date DateFormat dateFormat = DateFormat.getDateInstance(); return dateFormat.parse(n.getFirstChild().getNodeValue()); ! ! } else if (typeName.equals("datetime")) { //datetime (->Timestamp) return Timestamp.valueOf(n.getFirstChild().getNodeValue()); ! ! } else if ((typeName.equals("uri")) ! || (typeName.equals("text"))) { //uri or text (->String) return (n.getFirstChild().getNodeValue()); ! ! } else if (typeName.equals("boolean")) { //boolean return Boolean.valueOf(n.getFirstChild().getNodeValue()); ! } else { // not supported datatype logger.warn("extractFromXMLNode: Missing or not supported " ! + "datatype: " + ontType.toString()); return null; *************** *** 1191,1195 **** // Additional attribute or attribute that // wasn't defined in the itemontology ! value = extractFromXMLNode(child, "string"); logger.info("extractFromXMLDocument: No " + "corresponding datatype found in " --- 1138,1142 ---- // Additional attribute or attribute that // wasn't defined in the itemontology ! value = extractFromXMLNode(child, new OntologyDataType("string")); logger.info("extractFromXMLDocument: No " + "corresponding datatype found in " *************** *** 1199,1205 **** } else { // Attribute was defined in the itemontology ! String datatype = ontattr.getType(); ! ! if (datatype.equals("xml")) { // Attribute is of type XML value = extractFromXMLString(xml, tag); --- 1146,1152 ---- } else { // Attribute was defined in the itemontology ! OntologyDataType datatype = ontattr.getOntologyDataType(); ! String type = datatype.getTypeName(); ! if (type.equals("xml")) { // Attribute is of type XML value = extractFromXMLString(xml, tag); *************** *** 1226,1230 **** child = child.getNextSibling(); ! } catch (NumberFormatException e) { logger.warn(LogUtil.exception( "extractFromXMLDocument: " --- 1173,1177 ---- child = child.getNextSibling(); ! } catch (java.lang.StringIndexOutOfBoundsException e) { logger.warn(LogUtil.exception( "extractFromXMLDocument: " *************** *** 1367,1369 **** --- 1314,1325 ---- permission); } + /** + * This method returns the xml encoding for all items and for all item + * attributes + * @return Encoding type according to the xml standards. + */ + public final String getXMLEncoding() { + return this.xmlEncoding; + } + } |
|
From: <j_m...@us...> - 2004-02-29 12:21:46
|
Update of /cvsroot/cobricks/cobricks2/src/org/cobricks/item In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11169/src/org/cobricks/item Modified Files: ItemManagerDB.java Log Message: Index: ItemManagerDB.java =================================================================== RCS file: /cvsroot/cobricks/cobricks2/src/org/cobricks/item/ItemManagerDB.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** ItemManagerDB.java 21 Feb 2004 18:49:12 -0000 1.4 --- ItemManagerDB.java 29 Feb 2004 12:03:42 -0000 1.5 *************** *** 6,10 **** import org.cobricks.core.OntologyClass; import org.cobricks.core.OntologyClassAttr; ! /** * @author Johannes Mathes ma...@in... --- 6,11 ---- import org.cobricks.core.OntologyClass; import org.cobricks.core.OntologyClassAttr; ! import org.cobricks.core.OntologyDataType; ! import org.cobricks.core.DataObject; /** * @author Johannes Mathes ma...@in... *************** *** 20,24 **** import java.util.Map; import java.util.Set; ! /** --- 21,25 ---- import java.util.Map; import java.util.Set; ! import org.xmldb.api.base.XMLDBException; /** *************** *** 73,114 **** * @param attribute The attribute to store. * @param name The name of the attribute. ! * @param itemclasses The itemclasses which correspond to the current * item ! * @param itemid The itemid of item from which the attribute is part of */ protected final void storeAttribute(Object attribute, String name, ! OntologyClass[] itemclasses, int itemid) { //Default values ! String ontKeyWord = ""; // The whole keyword - that means e.g. string[] ! String ontKeyName = "string"; // The name - e.g. string ! boolean hasBrackets = false; String contextClass = null; //Lookup all ontology-related stuff ! if (ItemAttrs.getOCAttr(itemclasses, name) != null) { ! OntologyClassAttr oca = ItemAttrs.getOCAttr(itemclasses, name); ! ontKeyWord = oca.getType(); ! ! Map tokenized = ItemAttrs.tokenizeOntologyKeyWord(ontKeyWord); ! ontKeyName = (String) tokenized.get("keyWordName"); ! hasBrackets = ! ((Boolean) tokenized.get("hasBrackets")).booleanValue(); contextClass = oca.getContextClassName(); } ! //See if it is a special attribute, this lookup is done with the ont // key name ! boolean isSpecial = ItemAttrs.attributeIsSpecialType(ontKeyName); ! ! if (hasBrackets) { // At this time, only sets of special attributes are stored // set entry for set entry ! this.storeCollections(attribute, name, ontKeyName, contextClass, ! itemid, isSpecial); } else { //All single attributes and all Sets of non-special attributes // are stored as a single attribute ! this.storeSingleAttribute(attribute, name, ontKeyName, ! contextClass, itemid, isSpecial); } } --- 74,106 ---- * @param attribute The attribute to store. * @param name The name of the attribute. ! * @param itemclass The item class which correspond to the current * item ! * @param itemid The item id of item from which the attribute is part of */ protected final void storeAttribute(Object attribute, String name, ! OntologyClass itemclass, int itemid) { //Default values ! OntologyDataType ontType = new OntologyDataType("string"); String contextClass = null; //Lookup all ontology-related stuff ! if (itemclass.getAttribute(name) != null) { ! OntologyClassAttr oca = itemclass.getAttribute(name); ! ontType = oca.getOntologyDataType(); contextClass = oca.getContextClassName(); } ! //See if it is a special attribute, this lookup is done with the ontology // key name ! if (ontType.isCollection()) { // At this time, only sets of special attributes are stored // set entry for set entry ! this.storeCollections(attribute, name, ontType, contextClass, ! itemid); } else { //All single attributes and all Sets of non-special attributes // are stored as a single attribute ! this.storeSingleAttribute(attribute, name, ontType, ! contextClass, itemid); } } *************** *** 121,156 **** * @param oldAttribute Maybe it is necessary to compare with the old attribute * @param name The name of the attribute ! * @param itemclasses The ontology information is needed to get the type ! * of attribute and perhaps contextclass information. * @param itemid The id of the item this attribute belongs to */ protected final void updateAttribute(Object attribute, Object oldAttribute, ! String name, OntologyClass[] itemclasses, int itemid) { ! //The type of the attribute, according to the itemclass ! String ontKeyWord = ""; ! String ontKeyName = "string"; ! boolean hasBrackets = false; String contextClass = null; ! if (ItemAttrs.getOCAttr(itemclasses, name) != null) { ! OntologyClassAttr oca = ItemAttrs.getOCAttr(itemclasses, name); ! ontKeyWord = oca.getType(); ! ! Map tokenized = ItemAttrs.tokenizeOntologyKeyWord(ontKeyWord); ! ontKeyName = (String) tokenized.get("keyWordName"); ! hasBrackets = ! ((Boolean) tokenized.get("hasBrackets")).booleanValue(); contextClass = oca.getContextClassName(); } ! ! boolean isSpecial = ItemAttrs.attributeIsSpecialType(ontKeyName); ! ! if (hasBrackets) { this.updateCollections((Collection) attribute, ! (Collection) oldAttribute, name, ontKeyName, contextClass, ! itemid, isSpecial); } else { ! this.updateSingleAttribute(attribute, name, ontKeyName, ! contextClass, itemid, isSpecial); } } --- 113,138 ---- * @param oldAttribute Maybe it is necessary to compare with the old attribute * @param name The name of the attribute ! * @param itemclass The ontology information is needed to get the type ! * of attribute and perhaps context class information. * @param itemid The id of the item this attribute belongs to */ protected final void updateAttribute(Object attribute, Object oldAttribute, ! String name, OntologyClass itemclass, int itemid) { ! //The type of the attribute, according to the item class ! OntologyDataType ontType = new OntologyDataType("string"); String contextClass = null; ! if (itemclass.getAttribute(name) != null) { ! OntologyClassAttr oca = itemclass.getAttribute(name); ! ontType = oca.getOntologyDataType(); contextClass = oca.getContextClassName(); } ! if (ontType.isCollection()) { this.updateCollections((Collection) attribute, ! (Collection) oldAttribute, name, ontType, ! contextClass, itemid); } else { ! this.updateSingleAttribute(attribute, name, ontType, ! contextClass, itemid); } } *************** *** 163,171 **** * @param oldItem The old item (the one which is in the database) * @param newItem The new item (the one which has changed) ! * @param itemclasses The itemclasses which correspond to this item */ protected final void updateAttributeXMLDB(String name, Item oldItem, ! Item newItem, OntologyClass[] itemclasses) { String xpath = "/item[globalid='" + newItem.getGlobalId() + "']"; --- 145,153 ---- * @param oldItem The old item (the one which is in the database) * @param newItem The new item (the one which has changed) ! * @param itemclass The itemclass which correspond to this item */ protected final void updateAttributeXMLDB(String name, Item oldItem, ! Item newItem, OntologyClass itemclass) throws XMLDBException { String xpath = "/item[globalid='" + newItem.getGlobalId() + "']"; *************** *** 173,195 **** logger.debug("Try to update attribute: " + name + "itemid :" + String.valueOf(oldItem.getLocalId())); ! ! String itemclass = newItem.getItemClass(); ! ! if (itemclass == null) { ! itemclass = "item"; ! } ! ! OntologyClassAttr oca = ItemAttrs.getOCAttr(itemclasses, name); ! String attributeType = null; ! ! if (oca == null) { ! attributeType = "custom"; ! } else { ! attributeType = oca.getType(); ! } String oldXML = oldItem.getItemAttributeAsXML(name, false); String newXML = newItem.getItemAttributeAsXML(name, false); xmlDBAccess.update(oldXML, newXML, xpath); } --- 155,164 ---- logger.debug("Try to update attribute: " + name + "itemid :" + String.valueOf(oldItem.getLocalId())); ! OntologyClassAttr oca = itemclass.getAttribute(name); String oldXML = oldItem.getItemAttributeAsXML(name, false); String newXML = newItem.getItemAttributeAsXML(name, false); xmlDBAccess.update(oldXML, newXML, xpath); + } *************** *** 212,247 **** * This method deletes a single attribute-value pair in the rel. db * @param name The name of the attribute ! * @param itemclasses The itemclasses (all parent item classes and the custom ! * item class) of the item the attribute is from * @param itemid The itemid of the item the attribute is from */ protected final void removeAttribute(String name, ! OntologyClass[] itemclasses, int itemid) { //The type of the attribute, according to the itemclass ! String ontKeyWord = ""; ! String ontKeyName = "string"; ! boolean hasBrackets = false; String contextClass = null; ! if (ItemAttrs.getOCAttr(itemclasses, name) != null) { ! OntologyClassAttr oca = ItemAttrs.getOCAttr(itemclasses, name); ! ontKeyWord = oca.getType(); ! ! Map tokenized = ItemAttrs.tokenizeOntologyKeyWord(ontKeyWord); ! ontKeyName = (String) tokenized.get("keyWordName"); ! hasBrackets = ! ((Boolean) tokenized.get("hasBrackets")).booleanValue(); contextClass = oca.getContextClassName(); } //Don't uses prepareRecordSet because attribute value is not submitted //(and not necessary) ! boolean isSpecial = ItemAttrs.attributeIsSpecialType(ontKeyWord); Map toDelete = new HashMap(); toDelete.put("itemid", new Integer(itemid)); ! if (isSpecial) { toDelete.put("aname", name); ! this.dbAccess.sqlDelete("item_attrs" + ontKeyName, toDelete); } else if (name.matches("(content|title)_..") || name.matches("(content|title)")) { --- 181,209 ---- * This method deletes a single attribute-value pair in the rel. db * @param name The name of the attribute ! * @param itemclass The itemclass of the item the attribute is from * @param itemid The itemid of the item the attribute is from */ protected final void removeAttribute(String name, ! OntologyClass itemclass, int itemid) { //The type of the attribute, according to the itemclass ! OntologyDataType ontType = new OntologyDataType("string"); String contextClass = null; ! if (itemclass.getAttribute(name) != null) { ! OntologyClassAttr oca = itemclass.getAttribute(name); ! ontType = oca.getOntologyDataType(); contextClass = oca.getContextClassName(); } //Don't uses prepareRecordSet because attribute value is not submitted //(and not necessary) ! //boolean isSpecial = ItemAttrs.attributeIsSpecialType(ontType); Map toDelete = new HashMap(); toDelete.put("itemid", new Integer(itemid)); ! if (ontType.isCobricksType()) { toDelete.put("aname", name); ! this.dbAccess.sqlDelete("item_attrs" + ontType.getTypeName(), ! toDelete); } else if (name.matches("(content|title)_..") || name.matches("(content|title)")) { *************** *** 322,325 **** --- 284,297 ---- return new Item(xml, itemManager); } + /** + * This method performs an update by removing the whole old item and inserting + * the new one. Use only in emergency. + * @param item The new item to update. + */ + protected final void performSafeUpdate(Item item) { + logger.info("Performing safe update for item: " + item.getLocalId()); + this.xmlDBAccess.updateWholeDocument(item.getItemAsXML(false, false), + String.valueOf(item.getLocalId())); + } /** *************** *** 328,343 **** * @param attribute The attribute to store * @param name The name of the attribute ! * @param ontKeyName The ontology key name (NOT the whole key word) ! * @param contextClass The contextclass of this attribute (only * in case it is special attribute) ! * @param itemid The itemid this attribute belongs to ! * @param isSpecial Is it a special attribute? */ private void storeSingleAttribute(Object attribute, String name, ! String ontKeyName, String contextClass, int itemid, boolean isSpecial) { Map recordset = ! this.prepareRecordSet(attribute, name, ontKeyName, contextClass, ! itemid, isSpecial); ! String tablename = this.findTableName(name, ontKeyName, isSpecial); this.dbAccess.sqlInsert(tablename, recordset); --- 300,314 ---- * @param attribute The attribute to store * @param name The name of the attribute ! * @param ontDataType The ontology data type of this attribute ! * @param contextClass The context class of this attribute (only * in case it is special attribute) ! * @param itemid The item id this attribute belongs to */ private void storeSingleAttribute(Object attribute, String name, ! OntologyDataType ontDataType, String contextClass, int itemid) { Map recordset = ! this.prepareRecordSet(attribute, name, ontDataType, contextClass, ! itemid); ! String tablename = this.findTableName(name, ontDataType); this.dbAccess.sqlInsert(tablename, recordset); *************** *** 375,394 **** * @param attribute The attribute to store * @param name The attribute name. ! * @param ontKeyName The ontology key name (not the whole keyword). * @param contextClass The ontology contextclass (in case there is one, * otherwise null) * @param itemid The local id of the corresponding item - * @param isSpecial Is it a special attribute? (Avoids another isSpecial - * test). */ private void updateSingleAttribute(Object attribute, String name, ! String ontKeyName, String contextClass, int itemid, boolean isSpecial) { Map recordset = ! this.prepareRecordSet(attribute, name, ontKeyName, contextClass, ! itemid, isSpecial); String whereCondition = "itemid=" + String.valueOf(itemid); recordset.remove("itemid"); ! if (isSpecial) { whereCondition = whereCondition + " and aname LIKE " + "\"" + name + "\""; --- 346,363 ---- * @param attribute The attribute to store * @param name The attribute name. ! * @param ontType The ontology data type of this attribute * @param contextClass The ontology contextclass (in case there is one, * otherwise null) * @param itemid The local id of the corresponding item */ private void updateSingleAttribute(Object attribute, String name, ! OntologyDataType ontType, String contextClass, int itemid) { Map recordset = ! this.prepareRecordSet(attribute, name, ontType, contextClass, ! itemid); String whereCondition = "itemid=" + String.valueOf(itemid); recordset.remove("itemid"); ! if (ontType.isCobricksType()) { whereCondition = whereCondition + " and aname LIKE " + "\"" + name + "\""; *************** *** 402,406 **** } ! String tablename = this.findTableName(name, ontKeyName, isSpecial); this.dbAccess.sqlUpdate(tablename, recordset, whereCondition); } --- 371,375 ---- } ! String tablename = this.findTableName(name, ontType); this.dbAccess.sqlUpdate(tablename, recordset, whereCondition); } *************** *** 412,430 **** * @param attribute The collection of attributes to store * @param name The attribute name. ! * @param ontKeyName The ontlogy name of the type of attribute to store. * @param contextClass The contextclass (in case there is one, otherwise * null). * @param itemid The local id of the corresponding item - * @param isSpecial Is it a special attribute? Used to avoid another - * isSpecial query. */ private void storeCollections(Object attribute, String name, ! String ontKeyName, String contextClass, int itemid, boolean isSpecial) { //if (isSpecial) { Iterator it = ((Collection) attribute).iterator(); while (it.hasNext()) { ! this.storeSingleAttribute(it.next(), name, ontKeyName, ! contextClass, itemid, isSpecial); } --- 381,398 ---- * @param attribute The collection of attributes to store * @param name The attribute name. ! * @param ontType The ontlogy name of the type of attribute to store. * @param contextClass The contextclass (in case there is one, otherwise * null). * @param itemid The local id of the corresponding item */ + private void storeCollections(Object attribute, String name, ! OntologyDataType ontType, String contextClass, int itemid) { //if (isSpecial) { Iterator it = ((Collection) attribute).iterator(); while (it.hasNext()) { ! this.storeSingleAttribute(it.next(), name, ontType, ! contextClass, itemid); } *************** *** 446,462 **** * of course the content should be the same type as the new attributes * @param name The attribute name ! * @param ontKeyName The ontology key name (not the whole keyword) ! * @param contextClass The contextclass in case it is a special attribute, * null otherwise * @param itemid The local id of the item - * @param isSpecial In order to avoid another isSpecial test, it has to be - * specified whether a normal or a special attribute is submitted. */ private void updateCollections(java.util.Collection attribute, ! java.util.Collection oldAttribute, String name, String ontKeyName, ! String contextClass, int itemid, boolean isSpecial) { ! if (isSpecial) { ! Map oldO = ItemAttrs.createIDMap((Set) oldAttribute, ontKeyName); ! Map newO = ItemAttrs.createIDMap((Set) attribute, ontKeyName); Map diff = ItemAttrs.compareCols(oldO.keySet(), newO.keySet()); Set added = (Set) diff.get("added"); //contains the anames of added --- 414,430 ---- * of course the content should be the same type as the new attributes * @param name The attribute name ! * @param ontType The ontology data type of this attribute. ! * @param contextClass The context class in case it is a special attribute, * null otherwise * @param itemid The local id of the item */ private void updateCollections(java.util.Collection attribute, ! java.util.Collection oldAttribute, String name, OntologyDataType ontType, ! String contextClass, int itemid) { ! if (ontType.isCobricksType()) { ! Map oldO = ItemAttrs.createIDMap((Set) oldAttribute, ! ontType.getTypeName()); ! Map newO = ItemAttrs.createIDMap((Set) attribute, ! ontType.getTypeName()); Map diff = ItemAttrs.compareCols(oldO.keySet(), newO.keySet()); Set added = (Set) diff.get("added"); //contains the anames of added *************** *** 467,471 **** while (it.hasNext()) { this.storeSingleAttribute(newO.get(it.next()), name, ! ontKeyName, contextClass, itemid, isSpecial); } --- 435,439 ---- while (it.hasNext()) { this.storeSingleAttribute(newO.get(it.next()), name, ! ontType, contextClass, itemid); } *************** *** 474,478 **** while (it.hasNext()) { this.removeSingleAttribute(oldO.get(it.next()), name, ! ontKeyName, itemid, true); } } else { --- 442,446 ---- while (it.hasNext()) { this.removeSingleAttribute(oldO.get(it.next()), name, ! ontType, itemid); } } else { *************** *** 486,491 **** while (it.hasNext()) { ! this.storeSingleAttribute(it.next(), name, ontKeyName, ! contextClass, itemid, false); } --- 454,459 ---- while (it.hasNext()) { ! this.storeSingleAttribute(it.next(), name, ! ontType.getCollectionElementType(), contextClass, itemid); } *************** *** 493,498 **** while (it.hasNext()) { ! this.removeSingleAttribute(it.next(), name, ontKeyName, itemid, ! false); } } --- 461,466 ---- while (it.hasNext()) { ! this.removeSingleAttribute(it.next(), name, ! ontType.getCollectionElementType(), itemid); } } *************** *** 502,514 **** * This method finds out the correct table name for a specific attribute * @param aname The name of the attribute to store in the RDB ! * @param ontKeyName The ontology name of the attribute type ! * @param isSpecial Is it a special attribute? Avoids additional isSpecial ! * test * @return The name of the table where to store */ ! private String findTableName(String aname, String ontKeyName, ! boolean isSpecial) { ! if (isSpecial) { ! return ("item_attrs" + ontKeyName); } else if (aname.matches("(content|title)_..") || aname.matches("(content|title)")) { --- 470,479 ---- * This method finds out the correct table name for a specific attribute * @param aname The name of the attribute to store in the RDB ! * @param ontType The ontology data type of this attribute. * @return The name of the table where to store */ ! private String findTableName(String aname, OntologyDataType ontType) { ! if (ontType.isCobricksType()) { ! return ("item_attrs" + ontType.getTypeName()); } else if (aname.matches("(content|title)_..") || aname.matches("(content|title)")) { *************** *** 530,543 **** /** * This method prepares the map containing all necessary information for a ! * sql command (e.g. insert or update). The only other thing to take care of * is to find the correct table. * @param attribute The attribute value. * @param name The attribute name. ! * @param ontKeyName The ontology key name - NOT the whole keyword. * @param contextClass The context class (in case there is one, otherwise * null) ! * @param itemid The itemid. ! * @param isSpecial Additional information for avoiding additional isSpecial ! * test * @return Map containing all necessary information to make an insert state- * ment, depends on type: itemid, aname, contextclass (special), --- 495,506 ---- /** * This method prepares the map containing all necessary information for a ! * SQL command (e.g. insert or update). The only other thing to take care of * is to find the correct table. * @param attribute The attribute value. * @param name The attribute name. ! * @param ontType The ontology data type. * @param contextClass The context class (in case there is one, otherwise * null) ! * @param itemid The item id. * @return Map containing all necessary information to make an insert state- * ment, depends on type: itemid, aname, contextclass (special), *************** *** 546,550 **** */ private Map prepareRecordSet(Object attribute, String name, ! String ontKeyName, String contextClass, int itemid, boolean isSpecial) { Map recordset = new HashMap(); String whereCondition = "itemid=" + String.valueOf(itemid); --- 509,513 ---- */ private Map prepareRecordSet(Object attribute, String name, ! OntologyDataType ontType, String contextClass, int itemid) { Map recordset = new HashMap(); String whereCondition = "itemid=" + String.valueOf(itemid); *************** *** 554,563 **** Integer id; ! if (isSpecial) { recordset.put("aname", name); recordset.put("contextclass", contextClass); ! id = new Integer(ItemAttrs.getId(attribute, ontKeyName)); ! recordset.put("a" + ontKeyName + "id", id); /*if (!isUpdate) { --- 517,526 ---- Integer id; ! if (ontType.isCobricksType()) { recordset.put("aname", name); recordset.put("contextclass", contextClass); ! id = new Integer(((DataObject) attribute).getId()); ! recordset.put("a" + ontType.getTypeName() + "id", id); /*if (!isUpdate) { *************** *** 612,629 **** * attributes with same aname and itemid (list) * @param aname The aname of the attribute to delete ! * @param ontKeyName The name (NOT the whole keyword). Needed to match * to the correct table. * @param itemid The item as key needed. - * @param isSpecial Giving this parameter speeds up the determing if it is - * a special parameter or not. */ private void removeSingleAttribute(Object attribute, String aname, ! String ontKeyName, int itemid, boolean isSpecial) { Map toDelete = ! this.prepareRecordSet(attribute, aname, ontKeyName, null, itemid, ! isSpecial); toDelete.remove("contextclass"); ! String tablename = this.findTableName(aname, ontKeyName, isSpecial); this.dbAccess.sqlDelete(tablename, toDelete); } --- 575,589 ---- * attributes with same aname and itemid (list) * @param aname The aname of the attribute to delete ! * @param ontType The ontology data type. Needed to match * to the correct table. * @param itemid The item as key needed. */ private void removeSingleAttribute(Object attribute, String aname, ! OntologyDataType ontType, int itemid) { Map toDelete = ! this.prepareRecordSet(attribute, aname, ontType, null, itemid); toDelete.remove("contextclass"); ! String tablename = this.findTableName(aname, ontType); this.dbAccess.sqlDelete(tablename, toDelete); } |
|
From: <j_m...@us...> - 2004-02-29 12:21:30
|
Update of /cvsroot/cobricks/cobricks2/src/org/cobricks/item In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11114/src/org/cobricks/item Modified Files: ItemManager.java Log Message: Index: ItemManager.java =================================================================== RCS file: /cvsroot/cobricks/cobricks2/src/org/cobricks/item/ItemManager.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ItemManager.java 11 Feb 2004 14:31:52 -0000 1.1 --- ItemManager.java 29 Feb 2004 12:03:26 -0000 1.2 *************** *** 13,16 **** --- 13,17 ---- import org.cobricks.core.ComponentManagerInterface; import org.cobricks.core.util.LogUtil; + import org.cobricks.core.Ontology; *************** *** 52,56 **** // get HashMap of Objects from xml-input public HashMap extractFromXML(String xml); ! } --- 53,64 ---- // get HashMap of Objects from xml-input public HashMap extractFromXML(String xml); ! public Ontology getOntology(); ! ! /** ! * This method returns the encoding attribute of the xml declaration of all ! * items and all item attributes ! * @return xml encoding type. Default value is UTF-8 ! */ ! String getXMLEncoding(); } |
|
From: <j_m...@us...> - 2004-02-29 12:21:18
|
Update of /cvsroot/cobricks/cobricks2/src/org/cobricks/item In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11046/src/org/cobricks/item Modified Files: ItemAttrs.java Log Message: Index: ItemAttrs.java =================================================================== RCS file: /cvsroot/cobricks/cobricks2/src/org/cobricks/item/ItemAttrs.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** ItemAttrs.java 21 Feb 2004 18:49:00 -0000 1.4 --- ItemAttrs.java 29 Feb 2004 12:03:15 -0000 1.5 *************** *** 9,15 **** --- 9,17 ---- import org.cobricks.core.ComponentManagerAdaptor; import org.cobricks.core.CoreManager; + import org.cobricks.core.DataObject; import org.cobricks.core.Ontology; import org.cobricks.core.OntologyClass; import org.cobricks.core.OntologyClassAttr; + import org.cobricks.core.OntologyDataType; import org.cobricks.core.db.DBAccess; import org.cobricks.core.util.LogUtil; [...1315 lines suppressed...] + * It goes through the submitted array and returns the first match with the + * submitted aname. + * @param classes The ontology classes to go through + * @param aname Name of the ontology class attribute + * @return The first result found in the ontology array + + protected static OntologyClassAttr getOCAttr(OntologyClass[] classes, + String aname) { + int i = 0; + OntologyClassAttr oca = null; + + while ((i < classes.length) && (oca == null)) { + oca = classes[i].getAttribute(aname); + i++; + } + + return oca; + } + */ } |
|
From: <j_m...@us...> - 2004-02-29 12:21:04
|
Update of /cvsroot/cobricks/cobricks2/src/org/cobricks/item In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10990/src/org/cobricks/item Modified Files: Item.java Log Message: Index: Item.java =================================================================== RCS file: /cvsroot/cobricks/cobricks2/src/org/cobricks/item/Item.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** Item.java 23 Feb 2004 08:20:59 -0000 1.4 --- Item.java 29 Feb 2004 12:03:00 -0000 1.5 *************** *** 26,30 **** implements java.io.Serializable { private static int OBJECT_TYPE = -1; ! private static final String XML_ENCODING = "UTF-8"; static Logger logger = Logger.getLogger(Item.class); --- 26,30 ---- implements java.io.Serializable { private static int OBJECT_TYPE = -1; ! static Logger logger = Logger.getLogger(Item.class); *************** *** 34,38 **** protected String itemclass; protected String defaultLanguage = "en"; ! // item attributes cache Map annotations; --- 34,41 ---- protected String itemclass; protected String defaultLanguage = "en"; ! /** ! * Used for all xml encoding declarations ! */ ! private String xmlEncoding = "UTF-8"; // item attributes cache Map annotations; *************** *** 54,58 **** logger.debug("Item(String, ItemManager)"); this.defaultLanguage = itemManager.getDefaultLanguage(); ! HashMap attrs = itemManager.extractFromXML(xml); --- 57,61 ---- logger.debug("Item(String, ItemManager)"); this.defaultLanguage = itemManager.getDefaultLanguage(); ! this.xmlEncoding = itemManager.getXMLEncoding(); HashMap attrs = itemManager.extractFromXML(xml); *************** *** 106,109 **** --- 109,113 ---- super(); this.defaultLanguage = itemManager.getDefaultLanguage(); + this.xmlEncoding = itemManager.getXMLEncoding(); } *************** *** 113,116 **** --- 117,121 ---- this.defaultLanguage = itemManager.getDefaultLanguage(); this.itemid = itemid; + this.xmlEncoding = itemManager.getXMLEncoding(); /* *************** *** 134,137 **** --- 139,143 ---- this.itemid = itemid; this.itemclass = itemclass; + this.xmlEncoding = itemManager.getXMLEncoding(); /* *************** *** 149,162 **** return null; // tbd } ! public String getGlobalId() { return this.globalid; } - public int getId() - { - return this.itemid; - } - public int getLocalId() { return this.itemid; --- 155,165 ---- return null; // tbd } ! public int getId(){ ! return this.itemid; ! } public String getGlobalId() { return this.globalid; } public int getLocalId() { return this.itemid; *************** *** 303,307 **** //String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<item>\n" + ! String xml = "<?xml version=\"1.0\" encoding=\"" + Item.XML_ENCODING + "?>\n<item>\n" + " <itemid>" + new Integer(this.itemid).toString() + "</itemid>\n" + " <globalid>" + this.globalid + "</globalid>\n " + "<itemclass>" + --- 306,310 ---- //String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<item>\n" + ! String xml = "<?xml version=\"1.0\" encoding=\"" + this.xmlEncoding + "\"?>\n<item>\n" + " <itemid>" + new Integer(this.itemid).toString() + "</itemid>\n" + " <globalid>" + this.globalid + "</globalid>\n " + "<itemclass>" + *************** *** 359,363 **** if (withXMLDeclaration) { ! xml = "<?xml version=\"1.0\" encoding=\"" + Item.XML_ENCODING + "\"?>\n"; } --- 362,366 ---- if (withXMLDeclaration) { ! xml = "<?xml version=\"1.0\" encoding=\"" + this.xmlEncoding + "\"?>\n"; } |
|
From: <j_m...@us...> - 2004-02-29 12:20:50
|
Update of /cvsroot/cobricks/cobricks2/src/org/cobricks/item In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10950/src/org/cobricks/item Added Files: InputError.java Log Message: --- NEW FILE: InputError.java --- package org.cobricks.item; /** * @author Johannes Mathes ma...@in... * * */ public class InputError { private String errorCode; private String environment; public InputError(String submCode){ this.setErrorCode(submCode); } /** * @return */ public String getErrorCode() { return errorCode; } /** * @param string */ public void setErrorCode(String string) { errorCode = string; } /** * @return */ public String getEnvironment() { return environment; } /** * @param string */ public void setEnvironment(String string) { environment = string; } public String toString(){ return "Error: "+ this.getErrorCode() + " .Env: " + this.getEnvironment(); } } |