Topic
4 replies Latest Post - ‏2013-10-09T12:32:02Z by diegmer
SystemAdmin
SystemAdmin
1672 Posts
ACCEPTED ANSWER

Pinned topic Bind XML Data to Resource Chart

‏2009-05-26T20:18:27Z |

[krishnamrajgoud said:]

<TRAININGROSTERDETAILS>

<Groups id="10004" name="PILOT">

<Equipment id="10003" name="A331">
<Customer id="10000" name="Kingfisher Airline" startTime="05/26/2009 16:42" endTime="05/27/2009 16:42" status="" />
<Customer id="10003" name="Deccan" startTime="05/27/2009 16:42" endTime="05/28/2009 16:42" status="" />
</Equipment>

<Equipment id="10005" name="A320">
<Customer id="10000" name="Kingfisher Airline" startTime="05/26/2009 16:42" endTime="05/27/2009 16:42" status="" />
<Customer id="10003" name="Deccan" startTime="05/28/2009 16:42" endTime="05/30/2009 16:42" status="" />
</Equipment>

</Groups>

</TRAININGROSTERDETAILS>

hi, here is my xml data, i want it to bind to resource chart, in which i am unsuccessfull.

left data grid in the resource chart (ResourceDataProvider)shud display groups>equipments>customers as tree. And Right side(TaskDataProvider) should display customers as tasks with differant dates using differant colors in the corresponding row.

how do i achieve this. it has been informed that it is possible, thanks for that, but can u plz guide me through this. TIA
Updated on 2009-05-27T01:21:33Z at 2009-05-27T01:21:33Z by SystemAdmin
  • SystemAdmin
    SystemAdmin
    1672 Posts
    ACCEPTED ANSWER

    Re: Bind XML Data to Resource Chart

    ‏2009-05-27T01:21:33Z  in response to SystemAdmin

    [Frederic said:]

    Hi,

    This is different from what I understood from your earlier question (http://forums.ilog.com/elixir/index.php?topic=1594.0).

    You need to separate the tasks from the resources. As described in the developer's manual (http://www.ilog.com/documentation/elixir200/docs/en-US/Content/Visualization/Documentation/Elixir/_pubskel/ps_elixir97.html):
    * the taskDataProvider is a flat list of tasks
    * the resourceDataProvider is either a flat or a hierarchical collection of resources
    * the relationship between resources and tasks is built using identifiers: resources must have a attribute with its identifier (specified by the resourceIdField -- defaults to 'id'); the task must have an attribute with the identifier of the resource it is associated to (specified by the taskResourceIdField -- defaults to 'resourceId').

    One possible approach with your data consists in reorganizing the XML into:

    <TRAININGROSTERDETAILS>
      <[b]Groups[/b]>
          <[b]Group [/b]id="10004" name="PILOT">
            <Equipment id="10003" name="A331" />
            <Equipment id="10005" name="A320" />
          <[b]Group[/b]>
      </[b]Groups[/b]>
      <[b]Assignments[/b]>
          <[b]Assignement [/b]id="10000" [b]equipmentId="10003"[/b] name="Kingfisher Airline" startTime="05/26/2009 16:42" endTime="05/27/2009 16:42" status="" />
          <[b]Assignement [/b]id="10001" [b]equipmentId="10003"[/b] name="Deccan" startTime="05/27/2009 16:42" endTime="05/28/2009 16:42" status="" />
          <[b]Assignement [/b]id="10002" [b]equipmentId="10005"[/b] name="Kingfisher Airline" startTime="05/26/2009 16:42" endTime="05/27/2009 16:42" status="" />
          <[b]Assignement [/b]id="10003" [b]equipmentId="10005"[/b] name="Deccan" startTime="05/28/2009 16:42" endTime="05/30/2009 16:42" status="" />
      </[b]Assignments[/b]>
    </TRAININGROSTERDETAILS>

    Declare the resource chart with:
    <ilog:ResourceChart id="resourceChart" [b]taskResourceIdField="equipmentId"[/b] .../>

    Once the XML is loaded, you can assign the data providers with:
    var XML:data = ...
    resourceChart.resourceDataProvider = data.Groups;
    resourceChart.taskDataProvider = data.Assignments;

    You can have a look at the source of the human resource demo for more help. The source is found in <ILOG Elixir installation dir>/samples/humanresources/src. In humanresource.mxml look for loadDataModel() and xmlLoaded().

    Hope this helps,
    Frédéric
    • diegmer
      diegmer
      5 Posts
      ACCEPTED ANSWER

      Re: Bind XML Data to Resource Chart

      ‏2013-10-08T08:23:09Z  in response to SystemAdmin

      Hello, I have the same problem

      in my xml

      <?xml version="1.0" encoding="utf-8"?>
      <model>    
              <recurso id="319_ECKKS" tipo="AVION" acSubtypeIata="319" acSubtypeIata_carrierCode="319 IB" operador="IB" flotaGrupo="null" aircraftReg="ECKKS" subRowCount="1" fechaOrden="null" agruparPor="319"/>
              <actividad resourceId="319_ECKKS" startTime="02/10/2013 05:54" endTime="05/10/2013 08:17" tipo="VUELO" reason="VUELO_EN_CURSO" subRowCount="1"/>    
              <actividad resourceId="319_ECKKS" startTime="02/10/2013 09:40" endTime="12/10/2013 11:05" tipo="VUELO" reason="VUELO_EN_CURSO" subRowCount="1"/>    
              <actividad resourceId="319_ECKKS" startTime="02/10/2013 12:10" endTime="22/10/2013 13:43" tipo="VUELO" reason="VUELO_EN_CURSO" subRowCount="1"/>    
              <actividad resourceId="319_ECKKS" startTime="02/10/2013 15:20" endTime="09/10/2013 17:30" tipo="VUELO" reason="VUELO_EN_CURSO" subRowCount="1"/>
      </model>

      load the data with the funcion of humanresource.mxml -> loadDataModel() and xmlLoaded()

      Once the XML is loaded, I assign the data providers with:
      var XML:data = ...
      resourceChart.resourceDataProvider = data.Groups;
      resourceChart.taskDataProvider = data.actividad;

      Load data matriculas in datagrid; this run ok

      resourceChart.resourceDataProvider = null;

                   resourceChart.resourceDataProvider = General.getInstance().groupData(data.recurso, "@agruparPor");
                   var resourceCollection:ICollectionView = ICollectionView(resourceChart.resourceDataProvider);
                   var sort:Sort = new Sort();
                   sort.fields = [new SortField("@fechaOrden", true), new SortField("@aircraftReg", true)];      
                   resourceCollection.sort = sort;
                   resourceCollection.refresh();
                   resourceChart.resourceDataProvider = resourceCollection;

       

      but when load the activities in resourceChart.taskDataProvider, no charge anything

      the code is the next:

       var data:XML = event.result as XML;

      resourceChart.taskDataProvider = data.actividades;

      my ResourceChart is

      <gantt:ResourceChart id="resourceChart" width="100%" height="100%"
                                       left="3" right="3"
                                       taskResourceIdField="resourceId"
                                       resourceIdField="id"
                                       taskEndTimeFunction="readEndTime"
                                       taskStartTimeFunction="readStartTime"
                                       >

      I´m working with api ilog Elixir Enterprise 3.5

      if i change the xml with the next structure:

      <?xml version="1.0" encoding="utf-8"?>
      <model>    
              <recurso>            
                  <id>319_ECKKS</id>
                  <tipo>AVION</tipo>
                  <acSubtypeIata>319</acSubtypeIata>
                  <acSubtypeIata_carrierCode>319 IB</acSubtypeIata_carrierCode>
                  <operador>IB</operador>
                  <flota_grupo>null</flota_grupo>
                  <aircraftReg>ECKKS</aircraftReg>
                  <subRowCount>1</subRowCount>
                  <agruparPor>319</agruparPor>
                  <fechaorden>null</fechaorden>
              </recurso>
              <actividad>
                  <resourceId>319_ECKKS</resourceId>
                  <reason>Vacation</reason>
                  <tipo>VUELO_EN_CURSO</tipo>
                  <startTime>2013/10/07</startTime>
                  <endTime>2013/10/10</endTime>
              </actividad>
              <actividad>
                  <resourceId>319_ECKKS</resourceId>
                  <reason>VUELO_EN_CURSO</reason>
                  <tipo>VUELO</tipo>
                  <startTime>2013/10/12</startTime>
                  <endTime>2013/10/15</endTime>
              </actividad>
      </model>

       

      and change the code :

      resourceChart.resourceDataProvider = General.getInstance().groupData(data.recurso, "agruparPor");
                   var resourceCollection:ICollectionView = ICollectionView(resourceChart.resourceDataProvider);
                   var sort:Sort = new Sort();
                   sort.fields = [new SortField("@fechaOrden", true), new SortField("aircraftReg", true)];      
                   resourceCollection.sort = sort;
                   resourceCollection.refresh();
                   resourceChart.resourceDataProvider = resourceCollection;

      delete the @ for xml attributes

      the GanttSheet load the data without any problems

      Thanks

      Diego Merino

      • FrédéricLeroy
        FrédéricLeroy
        16 Posts
        ACCEPTED ANSWER

        Re: Bind XML Data to Resource Chart

        ‏2013-10-08T15:42:21Z  in response to diegmer

        Hi Diego,

        The discussion you are referring to applies to an earlier version of Elixir.

        Since version 3.0 (IIRC) the fields used by Elixir components must specify the '@' prefix when referring to attributes of XML tags.

        So in your case:

        <gantt:ResourceChart id="resourceChart" width="100%" height="100%"
                                         left="3" right="3"
                                         taskResourceIdField="@resourceId"
                                         resourceIdField="@id"
                                         taskEndTimeFunction="readEndTime"
                                         taskStartTimeFunction="readStartTime"
                                         >

        You should also check all other field attributes of the ResourceChart.

        Hope this helps,

        Frédéric

        • diegmer
          diegmer
          5 Posts
          ACCEPTED ANSWER

          Re: Bind XML Data to Resource Chart

          ‏2013-10-09T12:32:02Z  in response to FrédéricLeroy

          Ok Frédéric, now it works

          Thank you very much

          Diego Merino