No announcement yet.
  • Filter
  • Time
Clear All
new posts

  • More complex XML data sources examples

    I have seen the online employee examples of describing the datasource with respect to a simple container that holds multiple employees. How about XML that has attributes and contains deeper nesting? For example... how would you define the datasource for this xml?

    <service address="" port="7400"/>
    <host address="node00" port="7400" serviceInterface="">
    <graspcontroller address="tc2A1" port="915" hostInterface="">
    <OTA otaAddress="0" position="0" row="0" column="0" />
    <OTA otaAddress="1" position="1" row="1" column="0" />
    <graspcontroller address="tc2A2" port="915" hostInterface="" >
    <OTA otaAddress="256" position="0" row="0" column="1" />
    <OTA otaAddress="257" position="1" row="1" column="1" />
    <host address="node01" port="7400" serviceInterface="">
    <graspcontroller address="tc2A3" port="915" hostInterface="">
    <OTA otaAddress="2" position="0" row="2" column="0" />
    <OTA otaAddress="3" position="1" row="3" column="0" />
    <graspcontroller address="tc2A4" port="915" hostInterface="" >
    <OTA otaAddress="258" position="0" row="2" column="1" />
    <OTA otaAddress="259" position="1" row="3" column="1" />

    We have hosts holding controllers holding OTAs. Do you make a seperate ds describing otas, then make one of controllers that hold otas, then make one of hosts that hold controllers, and finally the hostmap that holds hosts and a service? How do you specify the attributes? How do you link the seperate ds's together?

  • #2
    How do you want the data to appear? As a tree similar to the XML structure, or as a grid where each row is a controller and the hosts and services are just attributes?


    • #3
      Data appearance

      I guess I was thinking tree, but grid is fine as well...

      Do you have examples of how I would do it either way?

      I was thinking of this:

      Browsing through the tree structure, you could add hosts, add controllers, add OTAs, as appropriate to your level of the tree. Beside the tree would be an editor that would change to edit each data type as you clicked on it... I need to be able to support CRUD operations on each item in the HostMap, Service, Host(s), Controller(s), OTA(s)...

      How painful is this? So I need to add appropriate views and listeners to the tree structure, and I need to reflect these changes in the underlying XML document.


      • #4
        With a grid, set a recordXPath that selects the OTAs (//OTA) and use valueXPaths in each field to acquire values from parent elements. eg a field might be hostAddress with valueXPath "ancestor:host@address" (haven't checked that that XPath is correct).

        You could display this as a grid with one row per OTA, or use groupByFields() to switch to a tree view.


        • #5
          More questions

          So, I have defined my data source as follows:
          DataSourceTextField serviceAddressField = new DataSourceTextField(
          "ancestor::service@address", "serviceAddress", 128);
          DataSourceTextField servicePortField = new DataSourceTextField(
          "ancestor::service@port", "servicePort", 128);
          DataSourceTextField hostAddressField = new DataSourceTextField(
          "ancestor::host@address", "hostAddress", 128);
          DataSourceTextField hostPortField = new DataSourceTextField(
          "ancestor::host@port", "hostPort", 128);
          DataSourceTextField hostServiceInterfaceField = new DataSourceTextField(
          "ancestor::host@serviceInterface", "hostServiceInterface",
          DataSourceTextField graspControllerAddressField = new DataSourceTextField(
          "graspControllerAddress", 128);
          DataSourceTextField graspControllerPortField = new DataSourceTextField(
          "ancestor::graspcontroller@port", "graspControllerPort", 128);
          DataSourceTextField graspControllerHostInterfaceField = new DataSourceTextField(
          "graspControllerHostInterface", 128);
          // Now add the OTA level fields
          DataSourceTextField otaAddressField = new DataSourceTextField(
          "self::attribute::otaAddress", "otaAddress", 128);
          DataSourceTextField positionField = new DataSourceTextField(
          "self::@position", "position", 128);
          DataSourceTextField rowField = new DataSourceTextField("self::@row",
          "row", 128);
          DataSourceTextField columnField = new DataSourceTextField(
          "self::@column", "Column", 128);

          I have defined a ListGrid as follows:

          ListGridField serviceAddressField = new ListGridField("serviceAddress", "Service Address");
          ListGridField servicePortField = new ListGridField("servicePort", "Service Port");
          ListGridField hostAddressField = new ListGridField("hostAddress", "Host Address");
          ListGridField hostPortField = new ListGridField("hostPort", "Host Port");
          ListGridField hostServiceInterfaceField = new ListGridField("hostserviceInterface", "Host Service Interface");
          ListGridField graspControllerAddressField = new ListGridField("graspControllerAddress", "Grasp Controller Address");
          ListGridField graspControllerPortField = new ListGridField("graspControllerPort", "Grasp Controller Port");
          ListGridField graspControllerHostInterfaceField = new ListGridField("ancestor::graspcontroller@hostInterface", "Grasp Controller Host Interface");
          ListGridField otaAddressField = new ListGridField("otaAddress", "OTA Address");
          ListGridField positionField = new ListGridField("position", "OTA Position");
          ListGridField rowField = new ListGridField("row", "OTA Row");
          ListGridField columnField = new ListGridField("column", "OTA Column");

          hostMapGrid.setFields(serviceAddressField, servicePortField, hostAddressField,
          hostPortField, hostServiceInterfaceField,
          graspControllerAddressField, graspControllerPortField,
          graspControllerHostInterfaceField, otaAddressField,
          positionField, rowField, columnField);

          This show correct entries for all of the OTA fields... otaAddress, position, row, column.... but blank fields for all of the ancestor fields. How do I map the ancestor fields into the list grid? What is the naming convention?


          • #6
            I am beginning to wonder if this is going to work

            Originally posted by Isomorphic
            With a grid, set a recordXPath that selects the OTAs (//OTA) and use valueXPaths in each field to acquire values from parent elements. eg a field might be hostAddress with valueXPath "ancestor:host@address" (haven't checked that that XPath is correct).

            You could display this as a grid with one row per OTA, or use groupByFields() to switch to a tree view.
            Okay, I figured this out... now on to the GroupBy problem...


            • #7

              Okay, I can see things the way I want to... but I can't edit anything, despite the fact that the interface allows me to pretend to edit, when I actually change something the change is not propagated.

              I guess I need to add some kind of listener?


              • #8
                Group By

                Also, group by is tricky... I want to group a set of fields at one level... not just one field at that level, for example all of the host stuff should be editable at the host level, then controller stuff at the controller level, etc.... and changing the host port should change the host port for every Ota that is owned by that host...


                • #9
                  The grid will attempt to save changes to the DataSource. Whatever type of DataSource you're using, it seems like it hasn't been set up to save.

                  You could use handlers like the EditCompleteHandler to propagate changes to other rows that should change.


                  • #10
                    FYI, I am having some of the same issues, mainly on how to map ancestors in a way that would work with Datasources, and it would have been a great help if you actually had posted the answers to your questions.