[Bprocessor-commit] model/src/net/sourceforge/bprocessor/model Classification.java, 1.3, 1.4 Space.
Status: Pre-Alpha
Brought to you by:
henryml
|
From: Nikolaj B. <nbr...@us...> - 2006-11-16 23:20:43
|
Update of /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv21757/src/net/sourceforge/bprocessor/model Modified Files: Classification.java Space.java Project.java Persistence.java Log Message: Name is now almost gone from spaces, both functional and construction are giving classification when created. And fixed and improved some things with the classification. Index: Persistence.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Persistence.java,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** Persistence.java 13 Nov 2006 12:20:52 -0000 1.21 --- Persistence.java 16 Nov 2006 23:20:39 -0000 1.22 *************** *** 166,170 **** space.setDescription(xml.getDescription()); if (!xml.getClassification().equalsIgnoreCase("unassigned")) { ! space.setClassification(Project.getInstance().getClassification(xml.getClassification())); } mapper.put(new Long(xml.getId()), space); --- 166,176 ---- space.setDescription(xml.getDescription()); if (!xml.getClassification().equalsIgnoreCase("unassigned")) { ! if (type == 0) { ! space.setClassification(Project.getInstance(). ! getClassification(xml.getClassification(), 0)); ! } else { ! space.setClassification(Project.getInstance(). ! getClassification(xml.getClassification(), 1)); ! } } mapper.put(new Long(xml.getId()), space); Index: Space.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Space.java,v retrieving revision 1.100 retrieving revision 1.101 diff -C2 -d -r1.100 -r1.101 *** Space.java 13 Nov 2006 12:25:33 -0000 1.100 --- Space.java 16 Nov 2006 23:20:39 -0000 1.101 *************** *** 224,227 **** --- 224,229 ---- } + + /** * Create a Construction Space *************** *** 246,249 **** --- 248,281 ---- } + + /** + * Create a Construction Space + * @param cl The classification + * @return The space + * @throws Exception If a part is being extended + */ + public Space createConstructionSpace(Classification cl) throws Exception { + Space cur; + if (this.level == PART_LEVEL) { + throw new Exception("Not leagal to make further levels of detail, max level is PART"); + } + if (this.level == ELEMENT_LEVEL) { + cur = new Space("", Space.CONSTRUCTION, PART_LEVEL, false); + cur.setClassification(cl); + return cur; + } + if (this.level == SPACE_LEVEL) { + cur = new Space("", Space.CONSTRUCTION, ELEMENT_LEVEL, false); + cur.setClassification(cl); + return cur; + } + if (this.level == PROJECT_LEVEL) { + cur = new Space("", Space.CONSTRUCTION, SPACE_LEVEL, false); + cur.setClassification(cl); + return cur; + } + return null; + } + /** * Create a Functional Space *************** *** 269,272 **** --- 301,333 ---- /** + * Create a Functional Space + * @param cl The classification + * @return The space + * @throws Exception If a part is being extended + */ + public Space createFunctionalSpace(Classification cl) throws Exception { + Space cur; + if (this.level == PART_LEVEL) { + throw new Exception("Not leagal to make further levels of detail, max level is PART"); + } + if (this.level == ELEMENT_LEVEL) { + cur = new Space("", Space.FUNCTIONAL , PART_LEVEL, false); + cur.setClassification(cl); + return cur; + } + if (this.level == SPACE_LEVEL) { + cur = new Space("", Space.FUNCTIONAL, ELEMENT_LEVEL, false); + cur.setClassification(cl); + return cur; + } + if (this.level == PROJECT_LEVEL) { + cur = new Space("", Space.FUNCTIONAL, SPACE_LEVEL, false); + cur.setClassification(cl); + return cur; + } + return null; + } + + /** * Get type * @return type *************** *** 353,357 **** */ public String getName() { ! return name; } --- 414,422 ---- */ public String getName() { ! if (getClassification() != null) { ! return getClassification().toString(); ! } else { ! return name; ! } } *************** *** 1429,1435 **** if (isConstructionSpace()) { res.add(new Attribute("Classification", ! Project.getInstance().getClassification(), getClassification(), 1)); } else { ! //res.add(new Attribute("Classification", functionalOptions, getClassification())); } } else { --- 1494,1501 ---- if (isConstructionSpace()) { res.add(new Attribute("Classification", ! Project.getInstance().getConstructionClas(), getClassification(), 1)); } else { ! res.add(new Attribute("Classification", ! Project.getInstance().getFunctionalClas(), getClassification(), 1)); } } else { *************** *** 1442,1449 **** } else { res.add(new Attribute("Classification", ! Project.getInstance().getClassification(), getClassification(), 2)); } } else { ! //res.add(new Attribute("Classification", elementFunctionalOptions, getClassification())); } } else if (getLevel() == Space.PART_LEVEL) { --- 1508,1521 ---- } else { res.add(new Attribute("Classification", ! Project.getInstance().getConstructionClas(), getClassification(), 2)); } } else { ! if (getOwner().getClassification() != null) { ! res.add(new Attribute("Classification", ! getOwner().getClassification(), getClassification(), 2)); ! } else { ! res.add(new Attribute("Classification", ! Project.getInstance().getFunctionalClas(), getClassification(), 2)); ! } } } else if (getLevel() == Space.PART_LEVEL) { *************** *** 1454,1461 **** } else { res.add(new Attribute("Classification", ! Project.getInstance().getClassification(), getClassification(), 3)); } } else { ! //res.add(new Attribute("Classification", partFunctionalOptions, getClassification())); } } --- 1526,1539 ---- } else { res.add(new Attribute("Classification", ! Project.getInstance().getConstructionClas(), getClassification(), 3)); } } else { ! if (getOwner().getClassification() != null) { ! res.add(new Attribute("Classification", ! getOwner().getClassification(), getClassification(), 3)); ! } else { ! res.add(new Attribute("Classification", ! Project.getInstance().getFunctionalClas(), getClassification(), 3)); ! } } } *************** *** 1546,1550 **** break; } ! return name + " - " + res + id; } --- 1624,1632 ---- break; } ! if (getClassification() != null) { ! return getClassification().toString() + " - " + res + id; ! } else { ! return name + " - " + res + id; ! } } Index: Classification.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Classification.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Classification.java 10 Nov 2006 13:48:44 -0000 1.3 --- Classification.java 16 Nov 2006 23:20:39 -0000 1.4 *************** *** 22,26 **** /** The id of the classification */ ! private Integer id; /** The children of this classification */ --- 22,26 ---- /** The id of the classification */ ! private String id; /** The children of this classification */ *************** *** 30,42 **** private Classification parent; /** * The constructor for a new classification * @param id the id * @param name the name * @param parent the parent */ ! public Classification(Integer id, String name, Classification parent) { setName(name); setId(id); setParent(parent); } --- 30,53 ---- private Classification parent; + /** Construction Type */ + public static final int CONSTRUCTION = 0; + + /** functional Type */ + public static final int FUNCTIONAL = 1; + + /** type */ + private int type; + /** * The constructor for a new classification * @param id the id * @param name the name + * @param type the type * @param parent the parent */ ! public Classification(String id, String name, Classification parent, int type) { setName(name); setId(id); + setType(type); setParent(parent); } *************** *** 45,60 **** * Constructor for a custom name element * @param name the name */ ! public Classification(String name) { setName(name); ! setId(new Integer(-1)); } /** * Constructor for base element */ ! public Classification() { setName("Classification"); ! setId(new Integer(0)); } --- 56,75 ---- * Constructor for a custom name element * @param name the name + * @param type the type */ ! public Classification(String name, int type) { setName(name); ! setType(type); ! setId(new String("-1")); } /** * Constructor for base element + * @param type the type */ ! public Classification(int type) { setName("Classification"); ! setId(new String("0")); ! setType(type); } *************** *** 87,91 **** * @return the id */ ! public Integer getId () { return id; } --- 102,106 ---- * @return the id */ ! public String getId () { return id; } *************** *** 95,99 **** * @param id the id to be set */ ! public void setId (Integer id) { this.id = id; } --- 110,114 ---- * @param id the id to be set */ ! public void setId (String id) { this.id = id; } *************** *** 131,137 **** String fullId = id.toString(); Classification par = parent; ! while (!par.getName().equalsIgnoreCase("Classification")) { ! fullId = par.getId() + "." + fullId; ! par = par.getParent(); } return fullId; --- 146,154 ---- String fullId = id.toString(); Classification par = parent; ! if (par != null) { ! while (!par.getName().equalsIgnoreCase("Classification")) { ! fullId = par.getId() + "." + fullId; ! par = par.getParent(); ! } } return fullId; *************** *** 146,149 **** --- 163,182 ---- } + /** + * Return the type of this classification + * @return type the type + */ + public int getType() { + return type; + } + + /** + * Set the type of this classification + * @param type the type + */ + public void setType(int type) { + this.type = type; + } + Index: Project.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Project.java,v retrieving revision 1.91 retrieving revision 1.92 diff -C2 -d -r1.91 -r1.92 *** Project.java 13 Nov 2006 12:20:52 -0000 1.91 --- Project.java 16 Nov 2006 23:20:39 -0000 1.92 *************** *** 47,51 **** /** The classification */ ! private Classification clas = new Classification(); /** The cameras */ --- 47,54 ---- /** The classification */ ! private Classification constructionClas = new Classification(0); ! ! /** The classification */ ! private Classification functionalClas = new Classification(1); /** The cameras */ *************** *** 130,134 **** Modellor.registerModellor(new LayerModellor()); try { ! loadClassification(); } catch (Exception e) { System.out.println("loading classification"); --- 133,138 ---- Modellor.registerModellor(new LayerModellor()); try { ! loadClassification(true); ! loadClassification(false); } catch (Exception e) { System.out.println("loading classification"); *************** *** 777,791 **** * This method loads the classification document from a file * @exception Exception Thrown if an exception occurs */ ! public void loadClassification() throws Exception { String current = ""; String token = ""; String curname = ""; ! Integer curid; ! Classification parent = new Classification(); ! Classification last = new Classification(); int depth = 0; int lastdepth = 0; ! BufferedReader bf = new BufferedReader(new FileReader("classification.csv")); current = bf.readLine(); while (!current.equalsIgnoreCase("--stop--")) { --- 781,808 ---- * This method loads the classification document from a file * @exception Exception Thrown if an exception occurs + * @param construction true if its construction space classification, false if functional */ ! public void loadClassification(boolean construction) throws Exception { ! Classification clas; String current = ""; String token = ""; String curname = ""; ! String curid; ! Classification parent; ! Classification last; int depth = 0; int lastdepth = 0; ! BufferedReader bf; ! if (construction) { ! bf = new BufferedReader(new FileReader("classification.csv")); ! clas = new Classification(0); ! parent = new Classification(0); ! last = new Classification(0); ! } else { ! bf = new BufferedReader(new FileReader("funcClassification.csv")); ! clas = new Classification(1); ! parent = new Classification(1); ! last = new Classification(1); ! } current = bf.readLine(); while (!current.equalsIgnoreCase("--stop--")) { *************** *** 794,801 **** token = st.nextToken(); if (depth == 0 && !token.equalsIgnoreCase(";")) { ! curid = new Integer(token); st.nextToken(); curname = st.nextToken(); ! Classification curclas = new Classification(curid, curname, clas); parent = curclas; clas.addChild(curclas); --- 811,823 ---- token = st.nextToken(); if (depth == 0 && !token.equalsIgnoreCase(";")) { ! curid = new String(token); st.nextToken(); curname = st.nextToken(); ! Classification curclas; ! if (construction) { ! curclas = new Classification(curid, curname, clas, 0); ! } else { ! curclas = new Classification(curid, curname, clas, 1); ! } parent = curclas; clas.addChild(curclas); *************** *** 805,809 **** depth++; } else if (depth != 0 && !token.equalsIgnoreCase(";")) { ! curid = new Integer(token); st.nextToken(); curname = st.nextToken(); --- 827,831 ---- depth++; } else if (depth != 0 && !token.equalsIgnoreCase(";")) { ! curid = new String(token); st.nextToken(); curname = st.nextToken(); *************** *** 814,818 **** parent = parent.getParent(); } ! Classification curclas = new Classification(curid, curname, parent); parent.addChild(curclas); last = curclas; --- 836,845 ---- parent = parent.getParent(); } ! Classification curclas; ! if (construction) { ! curclas = new Classification(curid, curname, parent, 0); ! } else { ! curclas = new Classification(curid, curname, parent, 1); ! } parent.addChild(curclas); last = curclas; *************** *** 823,834 **** current = bf.readLine(); } } /** ! * this method returns the classification ! * @return Classification the classification * */ ! public Classification getClassification () { ! return clas; } --- 850,878 ---- current = bf.readLine(); } + if (construction) { + constructionClas = clas; + constructionClas.addChild( + new Classification("-99", "Egne klassifikationer", constructionClas, 0)); + } else { + functionalClas = clas; + functionalClas.addChild( + new Classification("-99", "Egne klassifikationer", functionalClas, 1)); + } } /** ! * this method returns the construction space classification ! * @return Classification the construction space classification * */ ! public Classification getConstructionClas () { ! return constructionClas; ! } ! ! /** ! * this method returns the funcational space classification ! * @return Classification the funcational space classification ! * */ ! public Classification getFunctionalClas () { ! return functionalClas; } *************** *** 836,844 **** * this method returns the classification * @param id the id of the classification wanted * @return Classification the classification * */ ! public Classification getClassification(String id) { StringTokenizer st = new StringTokenizer(id, "."); ! Classification cl = clas; String curid; while (st.hasMoreTokens()) { --- 880,894 ---- * this method returns the classification * @param id the id of the classification wanted + * @param type 0 if its construction space classification, 1 if functional * @return Classification the classification * */ ! public Classification getClassification(String id, int type) { StringTokenizer st = new StringTokenizer(id, "."); ! Classification cl; ! if (type == 0) { ! cl = constructionClas; ! } else { ! cl = functionalClas; ! } String curid; while (st.hasMoreTokens()) { *************** *** 847,851 **** while (it.hasNext()) { Classification current = (Classification) it.next(); ! if (curid.equalsIgnoreCase(current.getId().toString())) { cl = current; } --- 897,901 ---- while (it.hasNext()) { Classification current = (Classification) it.next(); ! if (curid.equalsIgnoreCase(current.getId())) { cl = current; } |