Changeset 13418 in main


Ignore:
Timestamp:
03/23/17 14:24:18 (3 years ago)
Author:
Garth Braithwaite
Message:

admin, view - finished initiatives xml, dataset and view dimension xml structs. Before moving datasets into IP xml. View added default attribution for maps.

Location:
trunk
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/db/src/main/scripts/mysql/tab_c-indicator.sql

    r12462 r13418  
    163163Not sure if this is needed other than flexibility???
    164164
     165if implmenting then need intersection table.
     166probably should be more generic - if a view then the IV table has the surrogate
     167URL.  If dataset query then should be generic?
    165168create table INDICATOR_VIEW_SAVED_QUERY(
    166169  INDICATOR_VIEW_NAME             varchar  (100)  not null,
    167170  TITLE                           varchar  (100)  not null,
    168   SAVED_QUERY_URL                 varchar (1024)  not null,             /* Did have this as a SAVE_QUERY_NAME - but for now simply do a direct URL */
     171  URL                             varchar (1024)  not null,
    169172  /* */
    170173  SORT_ORDER                      int             default null,
  • trunk/ibisph-admin/src/main/webapp/WEB-INF/config/spring/publish-direct.xml

    r6920 r13418  
    158158        </bean>
    159159
    160         <bean id="publishCategorizedIndexController"
    161                 parent="publishDataBeanCollectionToXMLFileProperties"
    162                 class="org.ibisph.databean.springmvc.PublishCollectionToXMLFileController"
    163         >
    164                 <property name="filePathAndName"    value="#{publishCategorizedIndexXMLFilePathAndName.string}"/>
    165                 <property name="dataBeanClassName"  value="org.ibisph.indicatorprofile.databean.CategorizedIndex"/>
    166                 <property name="rootXMLElementName" value="CATEGORIZED_INDEXES"/>
    167         </bean>
    168 
    169160        <bean id="publishOrgUnitsController"
    170161                parent="publishDataBeanCollectionToXMLFileProperties"
     
    180171                <property name="dataBeanDAOService"            ref="commonDataBeanDAOService"/>
    181172                <property name="indicatorDataBeanToXMLService" ref="indicatorDataBeanToXMLService"/>
     173                <property name="indicatorDatasetDataBeanToXMLService" ref="indicatorDatasetDataBeanToXMLService"/>
    182174                <property name="indicatorViewDataBeanToXMLService" ref="indicatorViewDataBeanToXMLService"/>
    183175                <property name="publishedIndicatorsXMLService" ref="publishPublishedIndicatorsXMLService"/>
  • trunk/ibisph-admin/src/main/webapp/css/_layout.css

    r13360 r13418  
    131131#navigationMenu #navigationMenuList
    132132{
     133        position: absolute;
     134
    133135        -moz-box-shadow:        2px 2px 5px 2px #777;
    134136    -webkit-box-shadow: 2px 2px 5px 2px #777;
  • trunk/ibisph-view/src/main/webapp/WEB-INF/config/leaflet_maps.xml

    r11347 r13418  
    153153                        center: [34.25, -107]
    154154                        ,maxBounds: [[30.25, -101], [38.25, -111]]              // southwest corner, northeast corner
     155                        ,attributionControl: true
    155156                }
    156157
     
    256257                                        {
    257258                                                title: ""               // if no title then no group title...
    258                                                 ,type: "base"  // isBaseMap: true
     259                                                ,type: "base"   // isBaseMap: true
    259260                                                ,layers:
    260261                                                {
     
    265266                                                                ,url: "http://{s}.tile.opencyclemap.org/cycle/{z}/{x}/{y}.png"
    266267                                                                ,show: true
    267                                                                 ,options: null
     268                                                                ,options:
     269                                                                {
     270                                                                        attribution: '&amp;copy; <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
     271                                                                }
    268272                                                        }
    269273                                                        ,"none":
  • trunk/ibisph-view/src/main/webapp/css/Graphic.css

    r8095 r13418  
    8080        padding-left:           10px;
    8181}
     82.Graphic.Map .leaflet-control-attribution
     83{
     84        clear:                          both;
     85        margin-top:             3px;
     86        /* if wanting attribution to appear to left of scale then only this line:
     87        margin-top:             28px;
     88        */
     89}
     90.Graphic.Map .leaflet-control-attribution a:hover
     91{
     92        background-color:       transparent;
     93}
    8294
    8395.Graphic.Map .leaflet-container
     
    88100        border:                         1px outset #aaa;
    89101}
     102
    90103.DialogContent .Graphic.Map .leaflet-container
    91104{
  • trunk/ibisph/src/main/java/org/ibisph/indicatorprofile/service/IndicatorDataBeanToXML.java

    r13360 r13418  
    5151    addDataBeanToNode(document, indicator);
    5252
     53    XMLLib.addNode(document, getTopicsElement(indicator));
    5354    XMLLib.addNode(document, getInitiativesElement(indicator));
    54     XMLLib.addNode(document, getTopicsElement(indicator));
    5555    XMLLib.addNode(document, getRelationsElement(indicator));
     56    XMLLib.addNode(document, getDatasetsElement(indicator));
    5657    XMLLib.addNode(document, getIndicatorViewsElement(indicator));
    5758    return(document);
     
    6061
    6162  /**
    62    * Creates healthy people objective container and child elements based on
    63    * the supplied indicator.
     63   * Creates initiatives container and child topic and topic objective elements.
     64   * The supplied indicator only links to topic objectives so need to work from
     65   * the lowest level back to the top. 
     66   * Struct: INITIATIVES/INITIATIVE/
     67   *           INITIATIVE_TOPICS/INITIATIVE_TOPIC/
     68   *             INITIATIVE_TOPIC_OBJECTIVES/INITIATIVE_TOPIC_OBJECTIVE
    6469   * @param indicator DataBean to be converted to XML
    65    * @return XML HEALTHY_PEOPLE_OBJECTIVE element for the supplied indicator
    66    *   DataBean.
     70   * @return XML INITIATIVES element for the supplied indicator dataBean.
    6771   */
    6872  public Node getInitiativesElement(Indicator indicator) throws Exception {
    69     Node initiativesElement = XMLLib.newNode("INITIATIVES");
    70  // TODO: Need to finish
    71     /*
    72 
    73     InitiativeTopicObjectiveToIndicator
    74     ArrayList<DataBean> initativeCollection = new ArrayList<DataBean>();
    75     Initiative initiative = new Initiative();
    76     initiative.setFieldValue("INDICATOR_NAME", indicator.getName());
    77     this.dataBeanDAOService.load(initativeCollection, initiative);
    78     for(int i=0; i<initativeCollection.size(); i++) {
    79       initiative = (IndicatorToTopic)initativeCollection.get(i);
    80       Topic topic = new Topic();
    81       topic.setFieldValue("NAME",        initiative.getTopicName());
    82       topic.setFieldValue("ACTIVE_FLAG", this.dataBeanActiveFlagValue);
    83       if(this.dataBeanDAOService.load(topic) > 0) {
    84         Node dataSourceElement = XMLLib.newNode("TOPIC");
    85         XMLLib.addAttribute(dataSourceElement, "name", topic.getName() );
    86         XMLLib.addNode(dataSourceElement, XMLLib.newNode("NAME",  topic.getName() ) );
    87         XMLLib.addNode(dataSourceElement, XMLLib.newNode("TITLE", topic.getTitle() ) );
    88         XMLLib.addNode(dataSourceElement, XMLLib.newNode("URL",   topic.getURL() ) );
    89         XMLLib.addNode(dataSourceElement, XMLLib.newNode("SORT_ORDER", initiative.getSortOrder() ));
    90         XMLLib.addNode(initiativesElement, dataSourceElement);
     73    Node initiativesElement = null;
     74
     75    // start by seeing if any topic objectives exist for this IP.
     76    ArrayList<DataBean> initiativeTopicObjectiveToIndicatorCollection = new ArrayList<DataBean>();
     77    InitiativeTopicObjectiveToIndicator initiativeTopicObjectiveToIndicator = new InitiativeTopicObjectiveToIndicator();
     78    initiativeTopicObjectiveToIndicator.setFieldValue("INDICATOR_NAME", indicator.getName());
     79    this.dataBeanDAOService.load(
     80      initiativeTopicObjectiveToIndicatorCollection,
     81      initiativeTopicObjectiveToIndicator,
     82      new String[] {"INITIATIVE_TOPIC_NAME", "SORT_ORDER"}
     83    );
     84
     85    // If any exist then process.  Loop for all the IP's topic objective records.
     86    // The processing starts with the lowest level (topic objective) and works
     87    // it way back up to the top INITIATIVES container adding containers and
     88    // elements as needed e.g. If containers not found then create them as you go.
     89    if(0 < initiativeTopicObjectiveToIndicatorCollection.size()) {
     90      initiativesElement = XMLLib.newNode("INITIATIVES");
     91      for(int i=0; i<initiativeTopicObjectiveToIndicatorCollection.size(); i++) {
     92        initiativeTopicObjectiveToIndicator = (InitiativeTopicObjectiveToIndicator)initiativeTopicObjectiveToIndicatorCollection.get(i);
     93        addInitiativeTopicObjectiveElement(initiativesElement, initiativeTopicObjectiveToIndicator.getInitiativeTopicObjectiveName());
    9194      }
    9295    }
    9396    return(initiativesElement);
    94 
    95     Initiative initiative = new Initiative();
    96     initiative.setFieldValue("NAME",        indicator.getHealthyPeopleObjectiveName());
    97     initiative.setFieldValue("ACTIVE_FLAG", this.dataBeanActiveFlagValue);
    98     int recordLoadedCount = this.dataBeanDAOService.load(initiative);
    99     if(0 == recordLoadedCount) {
    100       logger.debug(".getHealthyPeopleObjectiveElement - HPO data bean not loaded.  HPO name: {} for indicator profile name: {}",
    101         indicator.getHealthyPeopleObjectiveName(),
    102         indicator.getName()
    103       );
    104     }
    105 */
    106     return(initiativesElement);
     97  } //-------------------------- End of Method ------------------------------
     98
     99  // get the topic objective bean, convert to XML, get/create the container
     100  // elements and add the objective element to it.
     101  protected void addInitiativeTopicObjectiveElement(
     102    Node initiativesElement,
     103    String initiativeTopicObjectiveName
     104  ) throws Exception {
     105
     106    // get the databean and convert to XML.
     107    InitiativeTopicObjective initiativeTopicObjective = new InitiativeTopicObjective();
     108    initiativeTopicObjective.setFieldValue("NAME", initiativeTopicObjectiveName);
     109    initiativeTopicObjective.setFieldValue("ACTIVE_FLAG", this.dataBeanFlagValue);
     110    if(0 < this.dataBeanDAOService.load(initiativeTopicObjective) ) {
     111      Node initiativeTopicObjectiveElement = this.newNode("INITIATIVE_TOPIC_OBJECTIVE", initiativeTopicObjective);
     112 
     113      // now get the parent topic element to add this to.  This code gets/creates
     114      // new parent elements as needed.
     115      Node initiativeTopicObjectivesElement = getInitiativeTopicObjectivesElement(initiativesElement, initiativeTopicObjective);
     116      XMLLib.addNode(initiativeTopicObjectivesElement, initiativeTopicObjectiveElement);
     117    }
     118  } //-------------------------- End of Method ------------------------------
     119
     120  // Gets the topic objectives container element.  If exists then simply return. 
     121  // If does not exist then get the associated topic, create the assoc XML and
     122  // create a objectives element of which to return so that the objective can
     123  // be added.  Also, if creating need to attach the new topic element to the
     124  // associated initiative.
     125  protected Node getInitiativeTopicObjectivesElement(
     126    Node initiativesElement,
     127    InitiativeTopicObjective initiativeTopicObjective
     128  ) throws Exception {
     129    String initiativeTopicName = initiativeTopicObjective.getInitiativeTopicName();
     130    Node initiativeTopicObjectivesElement = XMLLib.getNode(initiativesElement, "//INITIATIVE_TOPIC[NAME='" + initiativeTopicName + "']/INITIATIVE_TOPIC_OBJECTIVES");
     131    if(null == initiativeTopicObjectivesElement) {
     132      InitiativeTopic initiativeTopic = new InitiativeTopic();
     133      initiativeTopic.setFieldValue("NAME", initiativeTopicName);
     134      initiativeTopic.setFieldValue("ACTIVE_FLAG", this.dataBeanFlagValue);
     135      if(0 < this.dataBeanDAOService.load(initiativeTopic)) {
     136        Node initiativeTopicElement = this.newNode("INITIATIVE_TOPIC", initiativeTopic);
     137        initiativeTopicObjectivesElement = XMLLib.newNode("INITIATIVE_TOPIC_OBJECTIVES");
     138        XMLLib.addNode(initiativeTopicElement, initiativeTopicObjectivesElement);
     139
     140        // next need to get/create the initiative topics element to add the topic element to.
     141        Node initiativeTopicsElement = getInitiativeTopicsElement(initiativesElement, initiativeTopic);
     142        XMLLib.addNode(initiativeTopicsElement, initiativeTopicElement);
     143      }
     144    }
     145    return(initiativeTopicObjectivesElement);
     146  } //-------------------------- End of Method ------------------------------
     147
     148  // Gets the topics container element.  If exists then simply return. If does
     149  // not exist then get the associated initiative, create the assoc XML and
     150  // create a topics container element of which to return so that the topic can
     151  // be added. 
     152  protected Node getInitiativeTopicsElement(
     153    Node initiativesElement,
     154    InitiativeTopic initiativeTopic
     155  ) throws Exception {
     156    String initiativeName = initiativeTopic.getInitiativeName();
     157    Node initiativeTopicsElement = XMLLib.getNode(initiativesElement, "//INITIATIVE[NAME='" + initiativeName + "']/INITIATIVE_TOPICS");
     158    if(null == initiativeTopicsElement) {
     159      Initiative initiative = new Initiative();
     160      initiative.setFieldValue("NAME", initiativeName);
     161      initiative.setFieldValue("ACTIVE_FLAG", this.dataBeanFlagValue);
     162      if(0 < this.dataBeanDAOService.load(initiative)) {
     163        Node initiativeElement = this.newNode("INITIATIVE", initiative);
     164        XMLLib.addNode(initiativesElement, initiativeElement);
     165        initiativeTopicsElement = XMLLib.newNode("INITIATIVE_TOPICS");
     166        XMLLib.addNode(initiativeElement, initiativeTopicsElement);
     167      }
     168    }
     169    return(initiativeTopicsElement);
    107170  } //-------------------------- End of Method ------------------------------
    108171
     
    206269
    207270  /**
     271   * Creates the DATASETS container and child DATASET elements with their NAME
     272   * and TITLEs based on the supplied indicator.  The TITLEs are grabbed here
     273   * so that the XSLT code doesn't have to open the assoc dataset documents to
     274   * get their title info.
     275   * @param indicator DataBean used to get the assoc datasets.
     276   * @return XML DATASETS element for the supplied indicator DataBean.
     277   */
     278  public Node getDatasetsElement(Indicator indicator) throws Exception {
     279    Node datasetsElement = XMLLib.newNode("DATASETS");
     280
     281    // Since no intersection table for I to DS need to query the DSs based
     282    // on the IP NAME FK.  Need to sort by DS.SORT_ORDER and filter out all
     283    // inactives. 
     284    ArrayList<DataBean> datasetCollection = new ArrayList<DataBean>();
     285    Dataset dataset = new Dataset();
     286    dataset.setFieldValue("INDICATOR_NAME", indicator.getName());
     287    dataset.setFieldValue("ACTIVE_FLAG",    this.dataBeanFlagValue);
     288    this.dataBeanDAOService.load(datasetCollection, dataset, new String[] {"SORT_ORDER", "TITLE"});
     289
     290    Node datasetElement;
     291    for(int i=0; i<datasetCollection.size(); i++) {
     292      dataset = (Dataset)datasetCollection.get(i);
     293      datasetElement = XMLLib.newNode("DATASET");
     294      XMLLib.addNode(datasetElement, XMLLib.newNode("NAME",  dataset.getName()) );
     295      XMLLib.addNode(datasetElement, XMLLib.newNode("TITLE", dataset.getTitle()) );
     296      XMLLib.addNode(datasetsElement, datasetElement);
     297    }
     298    return(datasetsElement);
     299  } //-------------------------- End of Method ------------------------------
     300
     301
     302  /**
    208303   * Creates the INDICATOR_VIEWS container and child INDICATOR_VIEW elements
    209304   * with their NAME and TITLEs based on the supplied indicator.  The TITLEs
  • trunk/ibisph/src/main/java/org/ibisph/indicatorprofile/service/IndicatorDatasetDataBeanToXML.java

    r13360 r13418  
    4141    addDataBeanToNode(document, dataset);
    4242
     43    ArrayList<DataBean> recordsCollection = new ArrayList<DataBean>();
     44    DatasetRecord datasetRecord = new DatasetRecord();
     45    datasetRecord.setFieldValue("DATASET_NAME", dataset.getName());
     46    datasetRecord.setFieldValue("ACTIVE_FLAG",  this.dataBeanFlagValue);
     47    this.dataBeanDAOService.load(recordsCollection, datasetRecord);
     48
    4349    XMLLib.addNode(document, getMeasureElement(dataset));
    4450    XMLLib.addNode(document, getDataSourcesElement(dataset));
    45     XMLLib.addNode(document, getDatasetDimensionsElement(dataset));
    46     XMLLib.addNode(document, getRecordsElement(dataset));
     51    XMLLib.addNode(document, getDatasetDimensionsElement(dataset, recordsCollection));
     52    XMLLib.addNode(document, getRecordsElement(dataset, recordsCollection));
    4753    XMLLib.addNode(document, getSavedQueriesElement(dataset));
    4854   
     
    8591   * @return XML DIMENSIONS element for the supplied dataset Databean.
    8692   */
    87   public Node getDatasetDimensionsElement(Dataset dataset) throws Exception {
     93  public Node getDatasetDimensionsElement(
     94    Dataset dataset,
     95    ArrayList<DataBean> recordsCollection
     96  ) throws Exception {
    8897    Node containerNode = XMLLib.newNode("DIMENSIONS");
    8998
     
    109118      // loop for all dimension values.  Add the element if it is used.
    110119      for(int j=0; j<dimensionValueCollection.size(); j++) {
    111         dimensionValue = (DimensionValue)dimensionValueCollection.get(i);
     120        dimensionValue = (DimensionValue)dimensionValueCollection.get(j);
    112121// TODO: check if the dim value is actually used.  If so then add it...
    113122        this.addDataBeanToNode(dimensionValuesNode, dimensionValue);
     
    145154   * @return XML INDICATOR_VIEW_VALUES element for the supplied indicator view DataBean.
    146155   */
    147   public Node getRecordsElement(Dataset dataset) throws Exception {
    148     ArrayList<DataBean> valuesCollection  = new ArrayList<DataBean>();
    149     DatasetRecord datasetValue = new DatasetRecord();
    150     datasetValue.setFieldValue("DATASET_NAME",   dataset.getName());
    151 //    datasetValue.setFieldValue("SERIES_DIMENSION_NAME",   dataset.getSeriesDimensionName());
    152 //    datasetValue.setFieldValue("CATEGORY_DIMENSION_NAME", dataset.getCategoryDimensionName());
    153     datasetValue.setFieldValue("ACTIVE_FLAG",             this.dataBeanFlagValue);
    154     this.dataBeanDAOService.load(valuesCollection, datasetValue);
    155     Node valuesContainerElement = newNode("RECORDS", valuesCollection);
    156 
    157     return(valuesContainerElement);
     156  public Node getRecordsElement(
     157    Dataset dataset,
     158    ArrayList<DataBean> recordsCollection 
     159  ) throws Exception {
     160    Node recordsContainerElement = newNode("RECORDS", recordsCollection);
     161    return(recordsContainerElement);
    158162  } //-------------------------- End of Method ------------------------------
    159163
  • trunk/ibisph/src/main/java/org/ibisph/indicatorprofile/service/IndicatorViewDataBeanToXML.java

    r13360 r13418  
    4242
    4343    // add the period, series, category dimensions and values.
    44     XMLLib.addNode(document, getPeriodDimensionElement(indicatorView));
    45     XMLLib.addNode(document, getSeriesDimensionElement(indicatorView));
    46     XMLLib.addNode(document, getCategoryDimensionElement(indicatorView));
     44    XMLLib.addNode(document, getMeasureElement(indicatorView));
    4745    XMLLib.addNode(document, getChartElement(indicatorView));
    4846    XMLLib.addNode(document, getMapElement(indicatorView));
    49     XMLLib.addNode(document, getSavedQueriesElement(indicatorView));
     47    XMLLib.addNode(document, getDatasetNamesElement(indicatorView));
     48
     49    Node dimensionsElement = XMLLib.newNode("DIMENSIONS");
     50    XMLLib.addNode(dimensionsElement, getDimensionElement(indicatorView, "SERIES",   DimensionToIndicatorView.SERIES_USAGE));
     51    XMLLib.addNode(dimensionsElement, getDimensionElement(indicatorView, "CATEGORY", DimensionToIndicatorView.CATEGORY_USAGE));
     52    XMLLib.addNode(dimensionsElement, getDimensionElement(indicatorView, "PERIOD",   DimensionToIndicatorView.PERIOD_USAGE));
     53    XMLLib.addNode(document, dimensionsElement);
     54
     55// TODO: this needs to be determined if even needed/used and how...
     56    // XMLLib.addNode(document, getSavedQueriesElement(indicatorView));
    5057   
    5158    return(document);
     
    5966   * @return XML DATA_SOURCES element for the supplied indicator view DataBean.
    6067   */
    61   public Node getPeriodDimensionElement(IndicatorView indicatorView) throws Exception {
    62     Node dataSourcesNode = XMLLib.newNode("DATA_SOURCES");
     68  public Node getDimensionElement(
     69    IndicatorView indicatorView,
     70    String containerElementName,
     71    String dimensionUsage
     72  ) throws Exception {
     73    Node containerElement = XMLLib.newNode(containerElementName);
    6374
    64     ArrayList<DataBean> indicatorViewDataSourceCollection = new ArrayList<DataBean>();
    65     DataSourceToDataset indicatorViewDataSource = new DataSourceToDataset();
    66     indicatorViewDataSource.setFieldValue("INDICATOR_VIEW_NAME", indicatorView.getName());
    67     this.dataBeanDAOService.load(indicatorViewDataSourceCollection, indicatorViewDataSource);
     75    ArrayList<DataBean> dimensionToIndicatorViewCollection = new ArrayList<DataBean>();
     76    DimensionToIndicatorView dimensionToIndicatorView = new DimensionToIndicatorView();
     77    dimensionToIndicatorView.setFieldValue("INDICATOR_VIEW_NAME", indicatorView.getName());
     78    dimensionToIndicatorView.setFieldValue("DIMENSION_USAGE",     dimensionUsage);
     79    this.dataBeanDAOService.load(dimensionToIndicatorViewCollection, dimensionToIndicatorView);
    6880
    69     for(int i=0; i<indicatorViewDataSourceCollection.size(); i++) {
    70       indicatorViewDataSource = (DataSourceToDataset)indicatorViewDataSourceCollection.get(i);
    71       DataSource dataSource = new DataSource();
    72       dataSource.setFieldValue("NAME",        indicatorViewDataSource.getDataSourceName());
    73       dataSource.setFieldValue("ACTIVE_FLAG", this.dataBeanFlagValue);
    74       if(this.dataBeanDAOService.load(dataSource) > 0) {
    75         Node dataSourceElement = XMLLib.newNode("DATA_SOURCE");
    76         XMLLib.addAttribute(dataSourceElement, "name", dataSource.getName() );
    77         XMLLib.addNode(dataSourceElement, XMLLib.newNode("NAME", dataSource.getName() ) );
    78         XMLLib.addNode(dataSourceElement, XMLLib.newNode("TEXT", dataSource.getText() ) );
    79         XMLLib.addNode(dataSourceElement, XMLLib.newNode("SORT_ORDER", indicatorViewDataSource.getSortOrder() ));
    80         XMLLib.addNode(dataSourcesNode, dataSourceElement);
     81    for(int i=0; i<dimensionToIndicatorViewCollection.size(); i++) {
     82      dimensionToIndicatorView  = (DimensionToIndicatorView)dimensionToIndicatorViewCollection.get(i);
     83      Dimension dimension = new Dimension();
     84      dimension.setFieldValue("NAME", dimensionToIndicatorView.getDimensionName());
     85      this.dataBeanDAOService.load(dimension);
     86      Node dimensionElement = this.newNode("DIMENSION", dimension);
     87      Node dimensionValuesElement = XMLLib.newNode("DIMENSION_VALUES");
     88      XMLLib.addNode(dimensionElement, dimensionValuesElement);
     89
     90      ArrayList<DataBean> dimensionValueToIndicatorViewCollection = new ArrayList<DataBean>();
     91      DimensionValueToIndicatorView dimensionValueToIndicatorView = new DimensionValueToIndicatorView();
     92      dimensionValueToIndicatorView.setFieldValue("INDICATOR_VIEW_NAME", indicatorView.getName());
     93      dimensionValueToIndicatorView.setFieldValue("DIMENSION_NAME",      dimension.getName());
     94      this.dataBeanDAOService.load(dimensionValueToIndicatorViewCollection, dimensionValueToIndicatorView);
     95      for(int j=0; i<dimensionValueToIndicatorViewCollection.size(); j++) {
     96        dimensionValueToIndicatorView  = (DimensionValueToIndicatorView)dimensionValueToIndicatorViewCollection.get(j);
     97        DimensionValue dimensionValue = new DimensionValue();
     98        dimensionValue.setFieldValue("DIMENSION_NAME",  dimensionValueToIndicatorView.getDimensionName());
     99        dimensionValue.setFieldValue("DIMENSION_VALUE", dimensionValueToIndicatorView.getDimensionValue());
     100        this.dataBeanDAOService.load(dimensionValue);
     101
     102        XMLLib.addNode(dimensionValuesElement, this.newNode("DIMENSION_VALUE", dimensionValue));
    81103      }
    82104    }
    83     return(dataSourcesNode);
    84   } //-------------------------- End of Method ------------------------------
    85105
    86 
    87  
    88   /**
    89    * Creates SERIES_DIMENSION container and child elements based on the supplied
    90    * indicator view.
    91    * @param indicatorView DataBean to be converted to XML
    92    * @return XML DATASET_SERIES element for the supplied indicator view DataBean.
    93    */
    94   public Node getSeriesDimensionElement(org.ibisph.indicatorprofile.databean.IndicatorView indicatorView) throws Exception {
    95     Node containerNode = XMLLib.newNode("SERIES_DIMENSION");
    96 
    97     Measure datasetSeries = new Measure();
    98 //    this.dataDataBeanDAOService.load(datasetSeries, "NAME", indicatorView.getSeriesDimensionName());
    99     addDataBeanToNode(containerNode, datasetSeries);
    100 
    101     ArrayList<DataBean> valuesCollection = new ArrayList<DataBean>();
    102     MeasureValue datasetSeriesValue = new MeasureValue();
    103     datasetSeriesValue.setFieldValue("SERIES_DIMENSION_NAME", datasetSeries.getName());
    104     datasetSeriesValue.setFieldValue("ACTIVE_FLAG",           this.dataBeanFlagValue);
    105     this.dataBeanDAOService.load(valuesCollection, datasetSeriesValue);
    106     Node valuesContainerNode = newNode("DIMENSION_VALUES", valuesCollection);
    107     XMLLib.addNode(containerNode, valuesContainerNode);
    108 
    109     return(containerNode);
     106    return(containerElement);
    110107  } //-------------------------- End of Method ------------------------------
    111108
    112109
    113110  /**
    114    * Creates CATEGORY DIMENSION container and child elements based on the supplied
    115    * indicator view.
    116    * @param indicatorView DataBean to be converted to XML
    117    * @return XML CATEGORY_DIMENSION element for the supplied indicator view DataBean.
     111   * Creates the DATASETS container and child DATASET elements with their NAME
     112   * and TITLEs based on the supplied indicator view.  The TITLEs are grabbed 
     113   * here so that the XSLT code doesn't have to open the assoc dataset documents 
     114   * to get their title info.
     115   * @param indicatorView DataBean used to specify the assoc datasets.
     116   * @return XML DATASETS element for the supplied indicator DataBean.
    118117   */
    119   public Node getCategoryDimensionElement(IndicatorView indicatorView) throws Exception {
    120     Node containerNode = XMLLib.newNode("CATEGORY_DIMENSION");
     118  public Node getDatasetNamesElement(IndicatorView indicatorView) throws Exception {
     119    // Since no intersection table for I to ID need to query the views based
     120    // on the FK.  Need to sort by IV.SORT_ORDER and filter out all inactives. 
     121    ArrayList<DataBean> datasetToIndicatorViewCollection = new ArrayList<DataBean>();
     122    DatasetToIndicatorView datasetToIndicatorView = new DatasetToIndicatorView();
     123    datasetToIndicatorView.setFieldValue("INDICATOR_VIEW_NAME", indicatorView.getName());
     124    this.dataBeanDAOService.load(datasetToIndicatorViewCollection, datasetToIndicatorView);
    121125
    122     Dimension categoryDimension = new Dimension();
    123 //    categoryDimension.setFieldValue("NAME", indicatorView.getCategoryDimensionName());
    124     this.dataBeanDAOService.load(categoryDimension);
    125     this.addDataBeanToNode(containerNode, categoryDimension);
    126 
    127     ArrayList<DataBean> valuesCollection = new ArrayList<DataBean>();
    128     DimensionValue datasetCategoryValue = new DimensionValue();
    129     datasetCategoryValue.setFieldValue("CATEGORY_DIMENSION_NAME", categoryDimension.getName());
    130     datasetCategoryValue.setFieldValue("ACTIVE_FLAG",             this.dataBeanFlagValue);
    131     this.dataBeanDAOService.load(valuesCollection, datasetCategoryValue);
    132     XMLLib.addNode(containerNode, newNode("DIMENSION_VALUES", valuesCollection));
    133 
    134     return(containerNode);
     126    Node datasetToIndicatorViewElement = this.newNode("DATASET_NAMES", "DATASET_NAME", datasetToIndicatorViewCollection);
     127    return(datasetToIndicatorViewElement);
    135128  } //-------------------------- End of Method ------------------------------
    136129
     130
     131  /**
     132   * Creates MEASURE element based on the supplied indicator view.
     133   * @param indicatorView DataBean to be converted to XML
     134   * @return XML MEASURE element for the supplied indicator view
     135   *   DataBean.
     136   */
     137  public Node getMeasureElement(IndicatorView indicatorView) throws Exception {
     138    Measure measure = new Measure();
     139    this.dataBeanDAOService.load(measure, "NAME", indicatorView.getMeasureName());
     140    return(newNode("MEASURE", measure));
     141  } //-------------------------- End of Method ------------------------------
    137142
    138143  /**
     
    171176   */
    172177  public Node getSavedQueriesElement(IndicatorView indicatorView) throws Exception {
    173     Node savedQueriesNode = XMLLib.newNode("SAVED_QUERIES");
    174 
    175178    ArrayList<DataBean> indicatorViewSavedQueryCollection = new ArrayList<DataBean>();
    176179    IndicatorViewSavedQuery indicatorViewSavedQuery = new IndicatorViewSavedQuery();
     
    178181    this.dataBeanDAOService.load(indicatorViewSavedQueryCollection, indicatorViewSavedQuery);
    179182
    180     for(int i=0; i<indicatorViewSavedQueryCollection.size(); i++) {
    181       indicatorViewSavedQuery = (IndicatorViewSavedQuery)indicatorViewSavedQueryCollection.get(i);
    182       Node savedQueryElement = XMLLib.newNode("SAVED_QUERY");
    183       XMLLib.addNode(savedQueryElement, XMLLib.newNode("TITLE", indicatorViewSavedQuery.getTitle()) );
    184       XMLLib.addNode(savedQueryElement, XMLLib.newNode("URL",   indicatorViewSavedQuery.getURL() ));
    185       XMLLib.addNode(savedQueryElement, XMLLib.newNode("SORT_ORDER", indicatorViewSavedQuery.getSortOrder() ));
    186       XMLLib.addNode(savedQueriesNode, savedQueryElement);
    187     }
     183    Node savedQueriesNode = this.newNode("SAVED_QUERIES", "SAVED_QUERY", indicatorViewSavedQueryCollection);
    188184    return(savedQueriesNode);
    189185  } //-------------------------- End of Method ------------------------------
  • trunk/ibisph/src/main/java/org/ibisph/indicatorprofile/springmvc/databean/PublishIndicatorToXMLFileController.java

    r8638 r13418  
    22
    33import java.io.FileNotFoundException;
     4import java.util.Date;
    45import java.util.List;
    56
     
    1415import org.ibisph.indicatorprofile.databean.Indicator;
    1516import org.ibisph.indicatorprofile.service.IndicatorDataBeanToXML;
     17import org.ibisph.indicatorprofile.service.IndicatorDatasetDataBeanToXML;
    1618import org.ibisph.indicatorprofile.service.IndicatorViewDataBeanToXML;
    1719import org.ibisph.indicatorprofile.service.PublishedIndicatorsXML;
     
    3234  protected DataBeanDAOService         dataBeanDAOService                = null;
    3335  protected IndicatorDataBeanToXML     indicatorDataBeanToXMLService     = null;
     36  protected IndicatorDatasetDataBeanToXML indicatorDatasetDataBeanToXMLService = null;
    3437  protected IndicatorViewDataBeanToXML indicatorViewDataBeanToXMLService = null;
    3538  protected PublishedIndicatorsXML     publishedIndicatorsXMLService     = null;
     
    4447  public void setDataBeanDAOService(DataBeanDAOService dataBeanDAOService) {
    4548    this.dataBeanDAOService = dataBeanDAOService;
     49  } //-------------------------- End of Method ------------------------------
     50
     51  /**
     52   * Sets the indicator dataset DataBeanToXML service that is used to convert a
     53   * IP Dataset DataBean to an XML document.
     54   * @param indicatorDatasetDataBeanToXMLService service used to do the conversion.
     55   */
     56  public void setIndicatorDatasetDataBeanToXMLService(IndicatorDatasetDataBeanToXML indicatorDatasetDataBeanToXMLService) {
     57    this.indicatorDatasetDataBeanToXMLService = indicatorDatasetDataBeanToXMLService;
    4658  } //-------------------------- End of Method ------------------------------
    4759
     
    172184    // published date to now.  Else it's a republishing - leave published
    173185    // date as is but set return message to include it is being republished.
    174     java.util.Date publishedDate = indicatorDataBean.getPublishedDate();
    175     java.util.Date statusDate    = indicatorDataBean.getStatusDate();
     186    Date publishedDate = indicatorDataBean.getPublishedDate();
     187    Date statusDate    = indicatorDataBean.getStatusDate();
    176188    isNewPublishedDate = ((publishedDate == null) || statusDate.after(publishedDate));
    177189    if(!indicatorDataBean.isActive()) {
     
    214226    }
    215227
     228    // loop and save for all datasets.  If error don't abort as the ind file is
     229    // already saved.  Best that can do is report the error and have the user
     230    // correct.
     231    try {
     232      List<Node> nodes = indicatorDocument.selectNodes("/INDICATOR/DATASETS/DATASET/NAME");
     233      String datasetName;
     234      for(Node node:nodes) {
     235        datasetName = node.getText();
     236
     237        if(indicatorDataBean.isActive()) {
     238          Node element = this.indicatorDatasetDataBeanToXMLService.getDocument(datasetName);
     239          String saveMessage = save(element, datasetName);
     240          returnMessage.append(saveMessage);
     241        }
     242        else {
     243          String filePathAndName = IOPath.concat(this.filePath, datasetName + ".xml", "/");
     244          this.documentDAOService.delete(filePathAndName);
     245          returnMessage
     246            .append("Indicator profile NOT active - dataset file (")
     247            .append(filePathAndName)
     248            .append(") DELETED!. ");
     249        }
     250      }
     251    }
     252    catch(Exception e) {
     253      returnMessage.append(e.getMessage());
     254    }
     255
    216256    // loop and save for all views.  If error don't abort as the ind file is
    217257    // already saved.  Best that can do is report the error and have the user
     
    224264
    225265        if(indicatorDataBean.isActive()) {
    226           returnMessage.append(
    227             save(
    228               this.indicatorViewDataBeanToXMLService.getDocument(indicatorViewName),
    229               indicatorViewName
    230             )
    231           );
     266          Node element = this.indicatorViewDataBeanToXMLService.getDocument(indicatorViewName);
     267          String saveMessage = save(element, indicatorViewName);
     268          returnMessage.append(saveMessage);
    232269        }
    233270        else {
Note: See TracChangeset for help on using the changeset viewer.