On Wed, Aug 7, 2013 at 10:45 AM, Senaka Fernando <[email protected]> wrote:
> Hi Nuwan, > > I'm most certain that these are stored as multiple child elements under a > single parent, > If that is so, its perfectly alright. @Chan can you confirm please. > and there is no difference compared to storing them side-by-side vs in a > single group, especially if you use something like AXIOM to parse the XML. > Given the amount of migration involved in changing what we have, I'm not > convinced that there is any significant benefit of changing that. > Yes I also agree that there is no huge benifit in squeezing this change in to the release. However @Chan please test how its getting saved > > Thanks, > Senaka. > > > On Wed, Aug 7, 2013 at 10:17 AM, Nuwan Bandara <[email protected]> wrote: > >> Hi Senaka, >> >> The issue is when we pass an array of attributes (artifact.setAttributes) >> it saves as multiple root elements (same name) in the XML which is wrong. >> IFAIK that's the only issue, have its as CSV gives more meaning like >> <screenshots>foo,bar,mar</screenshots>. I think this need to be handled >> at the generic artifact manager. WDYT ? >> >> Regards, >> /Nuwan >> >> >> On Wed, Aug 7, 2013 at 10:11 AM, Senaka Fernando <[email protected]> wrote: >> >>> Hi Dulitha, >>> >>> Apart from the way things are stored in XML, is there any other concerns >>> WRT this? I didn't understand the benefit of having CSVs. >>> >>> Thanks, >>> Senaka. >>> >>> >>> On Wed, Aug 7, 2013 at 9:22 AM, Dulitha Wijewantha <[email protected]>wrote: >>> >>>> Hi guys, >>>> I am using the artifact.js module provided by jaggery core to insert >>>> JSON based javascript objects to the registry. Internally it converts them >>>> to xml before using the GenericArtifactManager to insert them to Greg. >>>> We are passing all the attributes to a method that converts them to xml >>>> - >>>> Below is the array - >>>> >>>> >>>> var screenshot1 = files['screenshot1File']; >>>> >>>> >>>> >>>> >>>> >>>> >>>> >>>> screenshot1 = saveFile(screenshot1); >>>> >>>> var screenshot2 = files['screenshot2File']; >>>> >>>> >>>> >>>> >>>> >>>> >>>> >>>> screenshot2 = saveFile(screenshot2); >>>> >>>> var screenshot3 = files['screenshot3File']; >>>> >>>> >>>> >>>> >>>> >>>> >>>> >>>> screenshot3 = saveFile(screenshot3); >>>> >>>> var screenshots = [screenshot1, screenshot2, screenshot3]; >>>> >>>> >>>> >>>> >>>> >>>> >>>> >>>> Link <https://gist.github.com/dulichan/6171023#file-gistfile2-js> >>>> >>>> >>>> Below is the method that creates the artifact (from json to xml in >>>> artifact.js) >>>> >>>> var createArtifact = function (manager, options) { >>>> >>>> >>>> >>>> >>>> >>>> >>>> >>>> var name, attribute, i, length, lc, >>>> >>>> >>>> >>>> >>>> >>>> >>>> >>>> artifact = manager.newGovernanceArtifact(new >>>> QName(options.name)), >>>> >>>> >>>> >>>> >>>> >>>> >>>> >>>> attributes = options.attributes; >>>> for (name in attributes) { >>>> if (attributes.hasOwnProperty(name)) { >>>> attribute = attributes[name]; >>>> if (attribute instanceof Array) { >>>> >>>> >>>> >>>> >>>> >>>> >>>> >>>> /*length = attribute.length; >>>> for (i = 0; i < length; i++) { >>>> >>>> >>>> >>>> >>>> >>>> >>>> >>>> artifact.addAttribute(name, attribute[i]); >>>> }*/ >>>> artifact.setAttributes(name, attribute); >>>> >>>> >>>> >>>> >>>> >>>> >>>> >>>> } else { >>>> artifact.setAttribute(name, attribute); >>>> >>>> >>>> >>>> >>>> >>>> >>>> >>>> } >>>> } >>>> } >>>> if (options.id) { >>>> artifact.id = options.id; >>>> } >>>> if (options.content) { >>>> if (options.content instanceof Stream) { >>>> >>>> >>>> >>>> >>>> >>>> >>>> >>>> >>>> artifact.setContent(IOUtils.toByteArray(options.content.getStream())); >>>> >>>> >>>> >>>> >>>> >>>> >>>> >>>> } else { >>>> artifact.setContent(new >>>> java.lang.String(options.content).getBytes()); >>>> >>>> >>>> >>>> >>>> >>>> >>>> >>>> } >>>> } >>>> >>>> lc = options.lifecycles; >>>> >>>> if (lc) { >>>> length = lc.length; >>>> >>>> >>>> >>>> >>>> >>>> >>>> >>>> for (i = 0; i < length; i++) { >>>> >>>> >>>> >>>> >>>> >>>> >>>> >>>> artifact.attachLifecycle(lc[i]); >>>> } >>>> } >>>> return artifact; >>>> }; >>>> Link <https://gist.github.com/dulichan/6171023#file-gistfile1-js> >>>> >>>> >>>> The culprit method here is the setAttributes - it saves the xml as >>>> >>>> <screenshots>one</screenshots> >>>> <screenshots>two</screenshots> >>>> >>>> >>>> >>>> >>>> >>>> >>>> >>>> <screenshots>three</screenshots> >>>> Link <https://gist.github.com/dulichan/6171023#file-gistfile3-xml> >>>> >>>> >>>> Temporarily I concatenated the array with commas - >>>> var screenshots = screenshot1+","+screenshot2+","+screenshot3; >>>> >>>> And convert them to an array with a utility method from my side. This >>>> should ideally be handled in the artifact.js module. WTDY? >>>> >>>> Thanks. >>>> -- >>>> Chan (Dulitha Wijewantha) >>>> Software Engineer - Mobile Development >>>> WSO2Mobile >>>> Lean.Enterprise.Mobileware >>>> * ~Email [email protected] <[email protected]>* >>>> * ~Mobile +94712112165* >>>> * ~Website dulithawijewantha.com >>>> * >>>> * ~Blog >>>> blog.dulithawijewantha.com<http://dulichan.github.io/chan/> >>>> * >>>> * ~Twitter @dulitharw <https://twitter.com/dulitharw>* >>>> >>> >>> >>> >>> -- >>> * <http://us13.wso2con.com/> >>> * >>> * >>> * >>> *Senaka Fernando* >>> Senior Technical Lead; WSO2 Inc.; http://wso2.com* >>> Member; Apache Software Foundation; http://apache.org >>> >>> E-mail: senaka AT wso2.com >>> **P: +1 408 754 7388; ext: 51736*; *M: +94 77 322 1818 >>> Linked-In: http://linkedin.com/in/senakafernando >>> >>> *Lean . Enterprise . Middleware >>> >> >> >> >> -- >> *Thanks & Regards, >> >> Nuwan Bandara >> Technical Lead; **WSO2 Inc. * >> *lean . enterprise . middleware | http://wso2.com * >> *blog : http://nuwanbando.com; email: [email protected]; phone: +94 11 763 >> 9629 >> * >> <http://www.nuwanbando.com/> >> > > > > -- > * <http://us13.wso2con.com/> > * > * > * > *Senaka Fernando* > Senior Technical Lead; WSO2 Inc.; http://wso2.com* > Member; Apache Software Foundation; http://apache.org > > E-mail: senaka AT wso2.com > **P: +1 408 754 7388; ext: 51736*; *M: +94 77 322 1818 > Linked-In: http://linkedin.com/in/senakafernando > > *Lean . Enterprise . Middleware > -- *Thanks & Regards, Nuwan Bandara Technical Lead; **WSO2 Inc. * *lean . enterprise . middleware | http://wso2.com * *blog : http://nuwanbando.com; email: [email protected]; phone: +94 11 763 9629 * <http://www.nuwanbando.com/>
_______________________________________________ Dev mailing list [email protected] http://wso2.org/cgi-bin/mailman/listinfo/dev
