Hi Simon, Thanks for the feedback. I see where you are coming from. Jackrabbit certainly gives you freedom of choice :)
Ben 2009/12/10 Simon Kent <[email protected]>: > > I can't see any problem with this, but in reality there isn't really a > 'wrong' way anyway, it's all a matter of preference. > > As a comment, I'd say have you thought about breaking the referenced nodes > away from having the enumerated values to unique nodes. In the current > design, there are references to the nodes size and waist providing (as I > understand it) the options, but there is no integrity here to support that > structure. > > How about... > > Node optionsRoot = session.getRootNode().addNode("/product/options/size"); > for (String value : new String[] { "250ml", "500ml", "1000ml" }) { > Node option = optionsRoot.addNode(value); > option.addMixin("mix:referenceable"); > } > > Node productRoot = > session.getRootNode().addNode("/products/washing_up_liquid"); > productRoot.setProperty("name", "Washing up Liquid"); > > Node productRoot250 = productRoot.addNode("250ml"); > productRoot250.addProperty("size", > optionsRoot.getNode(productRoot250.getName()); > productRoot250.setProperty("cost", new BigDecimal("1.99")); > productRoot250.setProperty("stock", 1); > productRoot250.setProperty("weight", 250); > > Node productRoot500 = productRoot.addNode("500ml"); > productRoot500.addProperty("size", > optionsRoot.getNode(productRoot500.getName()); > productRoot500.setProperty("cost", new BigDecimal("2.99")); > productRoot500.setProperty("stock", 1); > productRoot500.setProperty("weight", 500); > > .. and so on. > > This provides a link to the actual size and you could attach common size > properties to the size node (such as 'weight' for example) > > Then... > > Node washingUpLiquid = session.getRootNode("/products/washing_up_liquid"); > NodeIterator sizeIterator = washingUpLiquid.getNodes(); > while (sizeIterator.hasNext()) { > System.out.println(washingUpLiquid.getName() + ": Option -> " + > sizeIterator.nextNode().getName()); > } > > or something like that... > > Nothing wrong with your way, but just another take on it. > > Simon. > > > Ben Short wrote: >> >> Could anyone provide any comments or see any problems that might occur >> with the following repository structure? >> >> Node option = session.getRootNode().addNode("/product/options/size"); >> option.addMixin("mix:referenceable"); >> option.setProperty("name", "size"); >> option.setProperty("values", new String[]{"250ml", "500ml", >> "1000ml"}); >> >> Node product = >> session.getRootNode().addNode("/products/washing_up_liquid"); >> product.setProperty("name", "Washing up Liquid"); >> >> Node productOptions = product.addNode("options"); >> productOptions.setProperty("size", option); // REFERENCE >> >> Node variation250ml = product.addNode("variation/250ml"); >> variation250ml.setProperty("cost", new BigDecimal("1.99")); >> variation250ml.setProperty("stock", 1); >> variation250ml.setProperty("weight", 250); >> >> Node variation250mlOptions = >> variation250ml.addNode("options/size"); >> variation250mlOptions.setProperty("value", "250ml"); >> >> Node variation500ml = product.addNode("variation/500ml"); >> variation500ml.setProperty("cost", new BigDecimal("2.99")); >> variation500ml.setProperty("stock", 1); >> variation500ml.setProperty("weight", 500); >> >> Node variation500mlOptions = >> variation500ml.addNode("options/size"); >> variation500mlOptions.setProperty("value", "500ml"); >> >> >> Node waist = session.getRootNode().addNode("/product/options/waist"); >> waist.addMixin("mix:referenceable"); >> waist.setProperty("name", "waist"); >> waist.setProperty("values", new String[]{"28", "30", "32"}); >> >> Node leg = >> session.getRootNode().addNode("/product/options/leg"); >> leg.addMixin("mix:referenceable"); >> leg.setProperty("name", "leg"); >> leg.setProperty("values", new String[]{"28", "30", "32"}); >> >> Node product = >> session.getRootNode().addNode("/products/jeans"); >> product.setProperty("name", "Jeans"); >> >> Node productOptions = product.addNode("options"); >> productOptions.setProperty("waist", waist); // REFERENCE >> productOptions.setProperty("leg", leg); // REFERENCE >> >> Node variation28waist28leg = >> product.addNode("variation/28waist28leg"); >> variation28waist28leg.setProperty("cost", new >> BigDecimal("49.99")); >> variation28waist28leg.setProperty("stock", 1); >> variation28waist28leg.setProperty("weight", 3000); >> >> Node option1 = variation28waist28leg.addNode("options/waist"); >> option1.setProperty("value", "28"); >> >> Node option2 = variation28waist28leg.addNode("options/leg"); >> option2.setProperty("value", "28"); >> >> > > -- > View this message in context: > http://n4.nabble.com/Critique-and-Comments-tp956034p957002.html > Sent from the Jackrabbit - Users mailing list archive at Nabble.com. >
