Changeset 17685 in main
- Timestamp:
- 12/30/18 18:35:40 (4 years ago)
- Location:
- trunk
- Files:
-
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/db/src/main/scripts/mysql/data-value_attribute.sql
r15262 r17685 6 6 7 7 insert into VALUE_ATTRIBUTE (NAME, TITLE, CODE, DESCRIPTION, DEFINITION, SORT_ORDER, ACTIVE_FLAG, MODIFIED_DATE) values( 8 'Sup ressed', 'Supressed', '**',8 'Suppressed', 'Suppressed', '**', 9 9 'Value suppressed due to small numbers.', 10 10 'The estimate has been suppressed because 1) The relative standard error is greater than 50% or when the relative standard error can not be determined. Consider aggregating years to decrease the relative standard error and improve the reliability of the estimate. 2) the observed number of events is very small and not appropriate for publication, or 3) it could be used to calculate the number in a cell that has been suppressed.', … … 12 12 ); 13 13 insert into VALUE_ATTRIBUTE (NAME, TITLE, CODE, DESCRIPTION, DEFINITION, SORT_ORDER, ACTIVE_FLAG, MODIFIED_DATE) values( 14 'SurveySup ressed', 'Survey Supressed', '**',14 'SurveySuppressed', 'Survey Suppressed', '**', 15 15 ' Value suppressed due to small sample size (<50).', 16 16 'The estimate has been suppressed because number of responses was less than 50.', -
trunk/db/src/main/scripts/mysql/tab_c-misc_update_v3.sql
r17632 r17685 37 37 VALUE_TYPE_NAME varchar (100), 38 38 XML_ELEMENT_NAME varchar (100), /* IF USED SHOULD BE REQUIRED */ 39 REQUIRED_FLAG varchar (1), 39 40 /* */ 40 41 SORT_ORDER int, -
trunk/ibisph-admin/src/main/webapp/WEB-INF/config/spring/indicator.xml
r17645 r17685 71 71 <property name="dateFormat" ref="commonDateFormat"/> 72 72 <property name="stringCleaner" ref="commonMSWordStringCleaner"/> 73 <property name="includeDependentXML" value="true"/> 73 74 </bean> 74 75 -
trunk/ibisph-view/src/main/webapp/css/_general.css
r17645 r17685 340 340 font-size: 0.85rem; 341 341 } 342 .Note h3 343 { 344 margin-top: 2px; 345 } 342 346 343 347 -
trunk/ibisph-view/src/main/webapp/xslt/html/publication/index/chronological/Page.xslt
r16335 r17685 35 35 </style> 36 36 37 <a id="top"/>38 37 This page contains a chronological index of the Office of Public Health Assessment publications. 39 38 The year links allow you to directly jump to that section of the index which lists those -
trunk/ibisph-view/src/main/webapp/xslt/html/publication/index/topical/Page.xslt
r16335 r17685 27 27 ibis:doc="Main page content template. Builds a table listing the pubs by topic." 28 28 > 29 <a id="top"></a>30 29 This page contains a topical index of the Office of Public Health Assessment publications. 31 30 The drop down list box will enable you to directly jump to that section of the index which -
trunk/ibisph-view/src/main/webapp/xslt/html/query/module/result/Page.xslt
r17632 r17685 92 92 <xsl:param name="configuration" select="$queryModule/CONFIGURATIONS/CONFIGURATION[NAME=/QUERY_MODULE/REQUEST/CONFIGURATION_NAME]"/> 93 93 94 <a id="top"></a>95 94 <xsl:call-template name="UserSelections.criteria"> 96 95 <xsl:with-param name="queryModule" select="$queryModule"/> … … 141 140 <br/><br/> 142 141 143 <a href="# top" class="Top">Top</a>142 <a href="#" class="Top">Top</a> 144 143 <br/><br/> 145 144 </xsl:template> -
trunk/ibisph-view/src/main/webapp/xslt/json/Kendo.xslt
r17632 r17685 132 132 ,"Label": { type: "string" } 133 133 ,"Note": { type: "string" } 134 ,"ValueAttribute ": { type: "string" }134 ,"ValueAttributeName": { type: "string" } 135 135 <xsl:for-each select="$recordAncillaryValueFields/RECORD_ANCILLARY_VALUE_FIELD"> 136 136 ,"<xsl:value-of select="NAME"/>": { type: "number" } … … 199 199 <xsl:param name="recordAncillaryValueFields" ibis:doc="ancillary values struct."/> 200 200 <xsl:param name="measure" ibis:doc="measure info - NOT the measure value."/> 201 <xsl:param name="footerValues" />202 203 <xsl:param name="showFooterRow" select="0 != count($footerValues)"/> 201 <xsl:param name="footerValues" ibis:doc="total values - typically from query result."/> 202 <xsl:param name="showFooterRow" select="(0 != count($footerValues)) and (0 != string-length($footerValues[0]))"/> 203 204 204 <xsl:param name="showNoteColumn" select="false()"/> 205 205 <xsl:param name="showLabelColumn" select="false()"/> … … 209 209 <xsl:param name="categoryDimensionField" select="$recordDimensionFields/RECORD_DIMENSION_FIELD[USAGE='category']"/> 210 210 <xsl:param name="constantDimensionField" select="$recordDimensionFields/RECORD_DIMENSION_FIELD[USAGE='constant']"/> 211 <!-- GARTH: TODO: 212 <xsl:param name="baseExportFilename" select="'ibisph-query-result-data'"/> 213 --> 214 211 215 212 <xsl:text>{</xsl:text> 216 213 dataSource: <xsl:value-of select="$kendoDataSourceJavascriptVariableName"/> … … 293 290 </xsl:for-each> 294 291 292 <xsl:if test="$showLabelColumn"> 293 ,{ 294 field: "Label" 295 ,title: "<xsl:value-of select="$Kendo.labelColumnTitle"/>" 296 ,attributes: {"class": "Notes"} 297 }<xsl:text/> 298 </xsl:if> 299 300 <xsl:if test="$showValueAttributeColumn"> 301 ,{ 302 field: "ValueAttributeName" 303 ,title: "<xsl:value-of select="$Kendo.valueAttributeColumnTitle"/>" 304 ,attributes: {"class": "Notes"} 305 }<xsl:text/> 306 </xsl:if> 307 295 308 <xsl:if test="$showNoteColumn"> 296 309 ,{ … … 301 314 </xsl:if> 302 315 303 <xsl:if test="$showLabelColumn">304 ,{305 field: "Label"306 ,title: "<xsl:value-of select="$Kendo.labelColumnTitle"/>"307 ,attributes: {"class": "Notes"}308 }<xsl:text/>309 </xsl:if>310 311 <xsl:if test="$showValueAttributeColumn">312 ,{313 field: "ValueAttribute"314 ,title: "<xsl:value-of select="$Kendo.valueAttributeColumnTitle"/>"315 ,attributes: {"class": "Notes"}316 }<xsl:text/>317 </xsl:if>318 319 316 <!-- hidden category sort order 320 317 ,{field: "<xsl:value-of select="$categoryDimensionField/NAME"/>", title: "Default Order", hidden: false, groupable: false} 321 318 --> 322 319 ] 323 <!-- GARTH: TODO:324 saveAsExcel applies only when using325 , excel: { fileName: "<xsl:value-of select="$baseExportFilename"/>.xlsx" }326 -->327 320 } 328 321 </xsl:template> … … 350 343 <xsl:param name="includeNumerator" select="false()"/> 351 344 <xsl:param name="includeDenominator" select="false()"/> 352 <!-- GARTH: TODO: 353 <xsl:param name="baseExportFilename" select="'ibisph-query-result-chart'"/> 354 --> 345 355 346 <!-- 356 347 Did have code to dynamically craft - too complex and error prone. -
trunk/ibisph-view/src/main/webapp/xslt/xml/Interactive.xslt
r17508 r17685 207 207 208 208 <xsl:variable name="dimensionUsagesCount" select="count(distinct-values($dimensionUsages/DIMENSION_USAGE/USAGE))"/> 209 209 210 210 <!-- might as well filter out records that don't have the same number of dims. --> 211 211 <xsl:for-each select="$datasetRecords/RECORD[count(DIMENSIONS/DIMENSION) = $dimensionUsagesCount]"> -
trunk/ibisph/src/main/java/org/ibisph/databean/DimensionsDataBeanToXMLService.java
r15716 r17685 22 22 23 23 /** 24 * 25 * GARTH TODO: Delete if using referenced XML and not embedded. 26 * 27 * 28 * 24 29 * Helper service that creates an INDICATOR DATASET XML document from an 25 30 * indicator dataset data bean (and associated data beans). -
trunk/ibisph/src/main/java/org/ibisph/indicatorprofile/service/DatasetDataBeanToXML.java
r17255 r17685 11 11 import org.ibisph.databean.DataBean; 12 12 import org.ibisph.databean.DataBeanToXMLService; 13 import org.ibisph.indicatorprofile.databean.AncillaryValue; 13 14 import org.ibisph.indicatorprofile.databean.AncillaryValueToDataset; 15 import org.ibisph.indicatorprofile.databean.DataSource; 14 16 import org.ibisph.indicatorprofile.databean.DataSourceToDataset; 15 17 import org.ibisph.indicatorprofile.databean.Dataset; 16 18 import org.ibisph.indicatorprofile.databean.DatasetRecord; 17 19 import org.ibisph.indicatorprofile.databean.DatasetRecordAncillaryValue; 20 import org.ibisph.indicatorprofile.databean.Dimension; 21 import org.ibisph.indicatorprofile.databean.DimensionToDataset; 22 import org.ibisph.indicatorprofile.databean.DimensionValue; 18 23 import org.ibisph.indicatorprofile.databean.Indicator; 24 import org.ibisph.indicatorprofile.databean.Measure; 25 import org.ibisph.indicatorprofile.databean.ValueAttribute; 26 import org.ibisph.indicatorprofile.databean.ValueType; 19 27 import org.ibisph.util.StrLib; 20 28 import org.ibisph.util.XMLLib; … … 29 37 protected String dimensionNameSeparator = "---"; 30 38 39 protected boolean includeDependentXML = false; 40 41 42 public void setIncludeDependentXML(boolean includeDependentXML) { 43 this.includeDependentXML = includeDependentXML; 44 } //-------------------------- End of Method ------------------------------ 45 31 46 public Node getDatasetsNode(String indicatorName) throws Exception { 32 47 ArrayList<DataBean> datasetCollection = getIndicatorDatasets(indicatorName); … … 100 115 XMLLib.addNode(document, getRecordsNode(dataset.getMeasureName(), recordsCollection, ancillaryValueToDatasetCollection)); 101 116 XMLLib.addNode(document, getSavedQueriesNode(datasetName)); 117 118 if(this.includeDependentXML) { 119 Measure measure = new Measure(); 120 this.dataBeanDAOService.load(measure, "NAME", dataset.getMeasureName()); 121 XMLLib.addNode(document, newNode("MEASURE", measure)); 122 XMLLib.addNode(document, getDatasetAncillaryValuesNode(ancillaryValueToDatasetCollection)); 123 XMLLib.addNode(document, getValueTypesNode(measure, ancillaryValueToDatasetCollection)); 124 XMLLib.addNode(document, getValueAttributesNode(recordsCollection)); 125 XMLLib.addNode(document, getDatasetDimensionsNode(datasetName, recordsCollection)); 126 XMLLib.addNode(document, getDataSourcesNode(datasetName)); 127 } 128 102 129 return(document); 103 130 } //-------------------------- End of Method ------------------------------ 104 105 131 106 132 … … 128 154 return(dataSourceNamesNode); 129 155 } //-------------------------- End of Method ------------------------------ 130 131 156 132 157 … … 377 402 } //-------------------------- End of Method ------------------------------ 378 403 404 /////////////////////////// 405 406 407 /** 408 * Creates DATA_SOURCES container and child elements based on the supplied 409 * dataset. 410 * @param dataset DataBean to be converted to XML 411 * @return XML DATA_SOURCES element for the supplied dataset DataBean. 412 */ 413 public Node getDataSourcesNode(String datasetName) throws Exception { 414 Node dataSourcesNode = XMLLib.newNode("DATA_SOURCES"); 415 HashSet<String> dataSourceNameHashSet = new HashSet<String>(); 416 417 ArrayList<DataBean> datasetDataSourceCollection = new ArrayList<DataBean>(); 418 DataSourceToDataset dataSourceToDataset = new DataSourceToDataset(); 419 dataSourceToDataset.setFieldValue("DATASET_NAME", datasetName); 420 this.dataBeanDAOService.load(datasetDataSourceCollection, dataSourceToDataset); 421 for(DataBean dataBean : datasetDataSourceCollection) { 422 dataSourceToDataset = (DataSourceToDataset)dataBean; 423 String dataSourceName = dataSourceToDataset.getDataSourceName(); 424 if(StrLib.isSomething(dataSourceName) && !dataSourceNameHashSet.contains(dataSourceName)) { 425 DataSource dataSource = new DataSource(); 426 this.dataBeanDAOService.load(dataSource, "NAME", dataSourceName); 427 XMLLib.addNode(dataSourcesNode, this.newNode("DATA_SOURCE", dataSource)); 428 dataSourceNameHashSet.add(dataSourceName); 429 } 430 } 431 return(dataSourcesNode); 432 } //-------------------------- End of Method ------------------------------ 433 434 435 /** 436 * Creates DATASET's DIMENSIONs child DIMENSION/VALUES based on actual usage. 437 * @param dataset DataBean to be used for getting dimension XML. 438 * @return XML DIMENSIONS element for the supplied dataset Databean. 439 */ 440 public Node getDatasetDimensionsNode( 441 String datasetName, 442 ArrayList<DataBean> recordsCollection 443 ) throws Exception { 444 Node containerNode = XMLLib.newNode("DIMENSIONS"); 445 446 ArrayList<DataBean> dimensionToDatasetCollection = new ArrayList<DataBean>(); 447 DimensionToDataset dimensionToDataset = new DimensionToDataset(); 448 dimensionToDataset.setFieldValue("DATASET_NAME", datasetName); 449 this.dataBeanDAOService.load(dimensionToDatasetCollection, dimensionToDataset); 450 451 for(int i=0; i<dimensionToDatasetCollection.size(); i++) { 452 dimensionToDataset = (DimensionToDataset)dimensionToDatasetCollection.get(i); 453 Dimension dimension = new Dimension(); 454 dimension.setFieldValue("NAME", dimensionToDataset.getDimensionName()); 455 if(0 < this.dataBeanDAOService.load(dimension)) { 456 457 Node dimensionNode = this.newNode("DIMENSION", dimension); 458 459 ArrayList<DataBean> dimensionValueCollection = new ArrayList<DataBean>(); 460 DimensionValue dimensionValue = new DimensionValue(); 461 dimensionValue.setFieldValue("DIMENSION_NAME", dimension.getName()); 462 this.dataBeanDAOService.load(dimensionValueCollection, dimensionValue); 463 Node dimensionValuesNode = XMLLib.newNode("VALUES"); 464 XMLLib.addNode(dimensionNode, dimensionValuesNode); 465 466 // loop for all dimension values. Add the element if it is used. 467 DatasetRecord datasetRecord; 468 for(int j=0; j<dimensionValueCollection.size(); j++) { 469 dimensionValue = (DimensionValue)dimensionValueCollection.get(j); 470 boolean dimensionValueUsed = false; 471 for(int k=0; k<recordsCollection.size(); k++) { 472 datasetRecord = (DatasetRecord)recordsCollection.get(k); 473 dimensionValueUsed = 474 (dimension.getName().equals(datasetRecord.getDimension1Name()) 475 && dimensionValue.getValue().equals(datasetRecord.getDimension1Value())) 476 || 477 (dimension.getName().equals(datasetRecord.getDimension2Name()) 478 && dimensionValue.getValue().equals(datasetRecord.getDimension2Value())) 479 || 480 (dimension.getName().equals(datasetRecord.getPeriodDimensionName()) 481 && dimensionValue.getValue().equals(datasetRecord.getPeriodDimensionValue())) 482 ; 483 if(dimensionValueUsed) break; 484 } 485 if(dimensionValueUsed) XMLLib.addNode(dimensionValuesNode, this.newNode("VALUE", dimensionValue)); 486 } 487 XMLLib.addNode(containerNode, dimensionNode); 488 } 489 } 490 491 return(containerNode); 492 } //-------------------------- End of Method ------------------------------ 493 494 495 /** 496 * Creates VALUE_TYPES container and child elements based on the measure and 497 * ancillary values. 498 * @return XML VALUE_TYPES element. 499 */ 500 public Node getValueTypesNode( 501 Measure measure, 502 ArrayList<DataBean> ancillaryValueToDatasetCollection 503 ) throws Exception { 504 Node valueTypesNode = XMLLib.newNode("VALUE_TYPES"); 505 HashSet<String> valueTypeNameHashSet = new HashSet<String>(); 506 507 ValueType valueType = getValueType(measure.getValueTypeName()); 508 XMLLib.addNode(valueTypesNode, newNode("VALUE_TYPE", valueType)); 509 valueTypeNameHashSet.add(valueType.getName()); 510 511 for(DataBean dataBean : ancillaryValueToDatasetCollection) { 512 AncillaryValueToDataset ancillaryValueToDataset = (AncillaryValueToDataset)dataBean; 513 AncillaryValue ancillaryValue = new AncillaryValue(); 514 ancillaryValue.setFieldValue("NAME", ancillaryValueToDataset.getAncillaryValueName()); 515 if(0 < this.dataBeanDAOService.load(ancillaryValue)) { 516 String valueTypeName = ancillaryValue.getValueTypeName(); 517 if(StrLib.isSomething(valueTypeName) && !valueTypeNameHashSet.contains(valueTypeName)) { 518 valueType = getValueType(valueTypeName); 519 XMLLib.addNode(valueTypesNode, newNode("VALUE_TYPE", valueType)); 520 valueTypeNameHashSet.add(valueType.getName()); 521 } 522 } 523 } 524 return(valueTypesNode); 525 } //-------------------------- End of Method ------------------------------ 526 527 public ValueType getValueType(String name) throws Exception { 528 ValueType valueType = new ValueType(); 529 valueType.setFieldValue("NAME", name); 530 this.dataBeanDAOService.load(valueType); 531 return(valueType); 532 } //-------------------------- End of Method ------------------------------ 533 534 535 /** 536 * Creates VALUE_ATTRIBUTES container and child elements. 537 * @return XML VALUE_ATTRIBUTES element. 538 */ 539 public Node getValueAttributesNode(ArrayList<DataBean> recordsCollection) throws Exception { 540 Node valueAttributesNode = XMLLib.newNode("VALUE_ATTRIBUTES"); 541 HashSet<String> processedValueAttributeSet = new HashSet<String>(); 542 for(DataBean recordDataBean : recordsCollection) { 543 DatasetRecord datasetRecord = (DatasetRecord)recordDataBean; 544 String valueAttributeName = datasetRecord.getValueAttributeName(); 545 if(StrLib.isSomething(valueAttributeName) && !processedValueAttributeSet.contains(valueAttributeName)) { 546 processedValueAttributeSet.add(valueAttributeName); 547 ValueAttribute valueAttribute = new ValueAttribute(); 548 valueAttribute.setFieldValue("NAME", valueAttributeName); 549 if(0 < this.dataBeanDAOService.load(valueAttribute)) { 550 XMLLib.addNode(valueAttributesNode, newNode("VALUE_ATTRIBUTE", valueAttribute)); 551 } 552 } 553 } 554 return(valueAttributesNode); 555 } //-------------------------- End of Method ------------------------------ 556 557 558 /** 559 * Creates ANCILLARY_VALUES container and child elements based on the supplied 560 * ancillary value collection. 561 * @param ancillaryValueToDatasetCollection to be converted to XML 562 * @return XML ANCILLARY_VALUES element for the supplied collection. 563 */ 564 public Node getDatasetAncillaryValuesNode( 565 ArrayList<DataBean> ancillaryValueToDatasetCollection 566 ) throws Exception { 567 Node ancillaryValuesNode = XMLLib.newNode("ANCILLARY_VALUES"); 568 for(DataBean dataBean : ancillaryValueToDatasetCollection) { 569 AncillaryValueToDataset ancillaryValueToDataset = (AncillaryValueToDataset)dataBean; 570 AncillaryValue ancillaryValue = new AncillaryValue(); 571 ancillaryValue.setFieldValue("NAME", ancillaryValueToDataset.getAncillaryValueName()); 572 if(0 < this.dataBeanDAOService.load(ancillaryValue)) { 573 Node ancillaryValueNode = newNode("ANCILLARY_VALUE", ancillaryValue); 574 XMLLib.addNode(ancillaryValuesNode, ancillaryValueNode); 575 } 576 } 577 return(ancillaryValuesNode); 578 } //-------------------------- End of Method ------------------------------ 579 379 580 } //============================ END OF CLASS ================================= -
trunk/ibisph/src/main/java/org/ibisph/indicatorprofile/service/IndicatorDataBeanToXML.java
r16389 r17685 3 3 import java.util.ArrayList; 4 4 import java.util.Collection; 5 import java.util.HashSet; 6 import java.util.List; 5 7 6 8 import org.dom4j.Node; … … 10 12 import org.ibisph.indicatorprofile.databean.*; 11 13 import org.ibisph.indicatorprofile.service.DatasetDataBeanToXML; 14 import org.ibisph.util.StrLib; 12 15 import org.ibisph.util.XMLLib; 13 16 … … 23 26 protected Collection<Relation> relationDataBeanCollection = null; 24 27 28 protected boolean includeDependentXML = false; 29 30 31 public void setIncludeDependentXML(boolean includeDependentXML) { 32 this.includeDependentXML = includeDependentXML; 33 } //-------------------------- End of Method ------------------------------ 25 34 26 35 /** … … 63 72 addDataBeanToNode(document, indicator); 64 73 65 XMLLib.addNode(document, this.datasetDataBeanToXMLService.getDatasetsNode(indicator)); 74 ArrayList<DataBean> datasetCollection = this.datasetDataBeanToXMLService.getIndicatorDatasets(indicator.getName()); 75 XMLLib.addNode(document, this.datasetDataBeanToXMLService.getDatasetsNode(datasetCollection)); 66 76 XMLLib.addNode(document, getTopicsNode(indicator)); 67 77 XMLLib.addNode(document, getInitiativesNode(indicator)); … … 69 79 XMLLib.addNode(document, getIndicatorViewsNode(indicator)); 70 80 XMLLib.addNode(document, getLinksNode(indicator)); 71 81 82 if(this.includeDependentXML) { 83 XMLLib.addNode(document, getMeasuresNode(document)); 84 XMLLib.addNode(document, getValueTypesNode(document)); 85 XMLLib.addNode(document, getValueAttributesNode(document)); 86 XMLLib.addNode(document, getDataSourcesNode(document)); 87 XMLLib.addNode(document, getDatasetDimensionsNode(document)); 88 XMLLib.addNode(document, getOrgUnitNode(indicator.getOrgUnitName())); 89 } 90 72 91 return(document); 92 } //-------------------------- End of Method ------------------------------ 93 94 95 /** 96 * Creates TOPICS container and child elements based on the supplied 97 * indicator. 98 * @param indicator DataBean to be converted to XML 99 * @return XML TOPICS element for the supplied indicator DataBean. 100 */ 101 public Node getTopicsNode(Indicator indicator) throws Exception { 102 Node topicsNode = XMLLib.newNode("TOPICS"); 103 104 ArrayList<DataBean> topicIndicatorCollection = new ArrayList<DataBean>(); 105 IndicatorToTopic topicIndicator = new IndicatorToTopic(); 106 topicIndicator.setFieldValue("INDICATOR_NAME", indicator.getName()); 107 this.dataBeanDAOService.load(topicIndicatorCollection, topicIndicator); 108 109 for(int i=0; i<topicIndicatorCollection.size(); i++) { 110 topicIndicator = (IndicatorToTopic)topicIndicatorCollection.get(i); 111 Topic topic = new Topic(); 112 topic.setFieldValue("NAME", topicIndicator.getTopicName()); 113 topic.setFieldValue("ACTIVE_FLAG", this.dataBeanFlagValue); 114 if(this.dataBeanDAOService.load(topic) > 0) { 115 Node topicNode = newNode("TOPIC", topic); 116 XMLLib.addNode(topicsNode, topicNode); 117 } 118 } 119 return(topicsNode); 73 120 } //-------------------------- End of Method ------------------------------ 74 121 … … 139 186 140 187 /** 141 * Creates TOPICS container and child elements based on the supplied142 * indicator.143 * @param indicator DataBean to be converted to XML144 * @return XML TOPICS element for the supplied indicator DataBean.145 */146 public Node getTopicsNode(Indicator indicator) throws Exception {147 Node topicsNode = XMLLib.newNode("TOPICS");148 149 ArrayList<DataBean> topicIndicatorCollection = new ArrayList<DataBean>();150 IndicatorToTopic topicIndicator = new IndicatorToTopic();151 topicIndicator.setFieldValue("INDICATOR_NAME", indicator.getName());152 this.dataBeanDAOService.load(topicIndicatorCollection, topicIndicator);153 154 for(int i=0; i<topicIndicatorCollection.size(); i++) {155 topicIndicator = (IndicatorToTopic)topicIndicatorCollection.get(i);156 Topic topic = new Topic();157 topic.setFieldValue("NAME", topicIndicator.getTopicName());158 topic.setFieldValue("ACTIVE_FLAG", this.dataBeanFlagValue);159 if(this.dataBeanDAOService.load(topic) > 0) {160 Node topicNode = newNode("TOPIC", topic);161 XMLLib.addNode(topicsNode, topicNode);162 }163 }164 return(topicsNode);165 } //-------------------------- End of Method ------------------------------166 167 168 /**169 188 * Creates RELATIONS container and child elements based on the supplied 170 189 * indicator. … … 291 310 } //-------------------------- End of Method ------------------------------ 292 311 312 313 314 315 ///////////////////////////////////////////////// 316 public Node getMeasuresNode(Node containerNode) throws Exception { 317 List<Node> measureNameNodes = XMLLib.getNodes(containerNode, "//MEASURE_NAME", "text()", true); 318 319 Node measuresNode = XMLLib.newNode("MEASURES"); 320 for(Node measureNameNode : measureNameNodes) { 321 Measure measure = new Measure(); 322 this.dataBeanDAOService.load(measure, "NAME", XMLLib.getText(measureNameNode)); 323 XMLLib.addNode(measuresNode, this.newNode("MEASURE", measure)); 324 } 325 return(measuresNode); 326 } //-------------------------- End of Method ------------------------------ 327 328 329 public Node getValueTypesNode(Node containerNode) throws Exception { 330 List<Node> valueTypeNamesNode = XMLLib.getNodes(containerNode, "//VALUE_TYPE_NAME", "text()", true); 331 332 Node valueTypesNode = XMLLib.newNode("VALUE_TYPES"); 333 for(Node valueTypeNameNode : valueTypeNamesNode) { 334 ValueType valueType = new ValueType(); 335 this.dataBeanDAOService.load(valueType, "NAME", XMLLib.getText(valueTypeNameNode)); 336 XMLLib.addNode(valueTypesNode, this.newNode("VALUE_TYPE", valueType)); 337 } 338 return(valueTypesNode); 339 } //-------------------------- End of Method ------------------------------ 340 341 342 public Node getValueAttributesNode(Node containerNode) throws Exception { 343 List<Node> valueAttributeNamesNode = XMLLib.getNodes(containerNode, "//VALUE_ATTRIBUTE_NAME", "text()", true); 344 345 Node valueAttributesNode = XMLLib.newNode("VALUE_ATTRIBUTES"); 346 for(Node valueAttributeNameNode : valueAttributeNamesNode) { 347 ValueAttribute valueAttribute = new ValueAttribute(); 348 this.dataBeanDAOService.load(valueAttribute, "NAME", XMLLib.getText(valueAttributeNameNode)); 349 XMLLib.addNode(valueAttributesNode, this.newNode("VALUE_ATTRIBUTE", valueAttribute)); 350 } 351 return(valueAttributesNode); 352 } //-------------------------- End of Method ------------------------------ 353 354 355 public Node getDataSourcesNode(Node containerNode) throws Exception { 356 List<Node> dataSourceNamesNode = XMLLib.getNodes(containerNode, "//DATA_SOURCE_USAGE/NAME", "text()", true); 357 358 Node dataSourcesNode = XMLLib.newNode("DATA_SOURCES"); 359 for(Node dataSourceNameNode : dataSourceNamesNode) { 360 DataSource dataSource = new DataSource(); 361 this.dataBeanDAOService.load(dataSource, "NAME", XMLLib.getText(dataSourceNameNode)); 362 XMLLib.addNode(dataSourcesNode, this.newNode("DATA_SOURCE", dataSource)); 363 } 364 return(dataSourcesNode); 365 } //-------------------------- End of Method ------------------------------ 366 367 368 /** 369 * Creates DATASET's DIMENSIONs child DIMENSION/VALUES based on actual usage. 370 * @param dataset DataBean to be used for getting dimension XML. 371 * @return XML DIMENSIONS element for the supplied dataset Databean. 372 */ 373 public Node getDatasetDimensionsNode(Node containerNode) throws Exception { 374 List<Node> dimensionNamesNode = XMLLib.getNodes(containerNode, "//DIMENSION/NAME", "text()", true); 375 376 Node dimensionsNode = XMLLib.newNode("DIMENSIONS"); 377 for(Node dimensionNameNode : dimensionNamesNode) { 378 Dimension dimension = new Dimension(); 379 this.dataBeanDAOService.load(dimension, "NAME", XMLLib.getText(dimensionNameNode)); 380 Node dimensionNode = this.newNode("DIMENSION", dimension); 381 382 ArrayList<DataBean> dimensionValueCollection = new ArrayList<DataBean>(); 383 DimensionValue dimensionValue = new DimensionValue(); 384 dimensionValue.setFieldValue("DIMENSION_NAME", dimension.getName()); 385 dimensionValue.setFieldValue("ACTIVE_FLAG", this.dataBeanFlagValue); 386 this.dataBeanDAOService.load(dimensionValueCollection, dimensionValue); 387 388 // loop for all dimension values. Add the element if it is used. 389 Node dimensionValuesNode = XMLLib.newNode("VALUES"); 390 for(int j=0; j<dimensionValueCollection.size(); j++) { 391 dimensionValue = (DimensionValue)dimensionValueCollection.get(j); 392 XMLLib.addNode(dimensionValuesNode, this.newNode("VALUE", dimensionValue)); 393 } 394 XMLLib.addNode(dimensionNode, dimensionValuesNode); 395 XMLLib.addNode(dimensionsNode, dimensionNode); 396 } 397 398 return(dimensionsNode); 399 } //-------------------------- End of Method ------------------------------ 400 401 402 public Node getOrgUnitNode(String orgUnitName) throws Exception { 403 OrgUnit orgUnit = new OrgUnit(); 404 this.dataBeanDAOService.load(orgUnit, "NAME", orgUnitName); 405 Node orgUnitNode = this.newNode("ORG_UNIT", orgUnit); 406 return(orgUnitNode); 407 } //-------------------------- End of Method ------------------------------ 408 409 410 411 412 //////////////// SAVED FOR NOW 413 414 public String[] getMeasureNames(ArrayList<DataBean> datasetCollection) throws Exception { 415 HashSet<String> measureNames = new HashSet<String>(); 416 for(DataBean dataBean : datasetCollection) { 417 Dataset dataset = (Dataset)dataBean; 418 measureNames.add(dataset.getMeasureName()); 419 } 420 return((String[])measureNames.toArray()); 421 } //-------------------------- End of Method ------------------------------ 422 423 public ArrayList<DataBean> getMeasures(String[] measureNames) throws Exception { 424 Measure measure = new Measure(); 425 ArrayList<DataBean> measureCollection = new ArrayList<DataBean>(); 426 for(String measureName : measureNames) { 427 this.dataBeanDAOService.load(measure, "NAME", measureName); 428 measureCollection.add(measure); 429 } 430 return(measureCollection); 431 } //-------------------------- End of Method ------------------------------ 432 433 public Node getMeasuresNode(ArrayList<DataBean> measureCollection) throws Exception { 434 Node measuresNode = XMLLib.newNode("MEASURES"); 435 for(DataBean dataBean : measureCollection) { 436 this.addDataBeanToNode(measuresNode, dataBean); 437 } 438 return(measuresNode); 439 } //-------------------------- End of Method ------------------------------ 440 441 442 443 public String[] getValueTypeNames(ArrayList<DataBean> measureCollection) throws Exception { 444 HashSet<String> valueTypeNames = new HashSet<String>(); 445 for(DataBean dataBean : measureCollection) { 446 Measure measure = (Measure)dataBean; 447 valueTypeNames.add(measure.getValueTypeName()); 448 } 449 return((String[])valueTypeNames.toArray()); 450 } //-------------------------- End of Method ------------------------------ 451 452 public Node getValueTypesNode(String[] valueTypeNames) throws Exception { 453 Node valueTypesNode = XMLLib.newNode("VALUE_TYPES"); 454 for(String valueTypeName : valueTypeNames) { 455 ValueType valueType = new ValueType(); 456 this.dataBeanDAOService.load(valueType, "NAME", valueTypeName); 457 this.addDataBeanToNode(valueTypesNode, valueType); 458 } 459 return(valueTypesNode); 460 } //-------------------------- End of Method ------------------------------ 461 462 463 464 /** 465 * Creates DATA_SOURCES container and child elements based on the supplied 466 * dataset. 467 * @param dataset DataBean to be converted to XML 468 * @return XML DATA_SOURCES element for the supplied dataset DataBean. 469 */ 470 public Node getDataSourcesNode(String datasetName) throws Exception { 471 Node dataSourcesNode = XMLLib.newNode("DATA_SOURCES"); 472 473 ArrayList<DataBean> datasetDataSourceCollection = new ArrayList<DataBean>(); 474 DataSourceToDataset datasetDataSource = new DataSourceToDataset(); 475 datasetDataSource.setFieldValue("DATASET_NAME", datasetName); 476 this.dataBeanDAOService.load(datasetDataSourceCollection, datasetDataSource); 477 for(DataBean dataBean : datasetDataSourceCollection) { 478 datasetDataSource = (DataSourceToDataset)dataBean; 479 480 Node dataSourceNode = XMLLib.newNode("DATA_SOURCE"); 481 XMLLib.addNode(dataSourceNode, XMLLib.newNode("NAME", datasetDataSource.getDataSourceName())); 482 XMLLib.addNode(dataSourceNode, XMLLib.newNode("USAGE", datasetDataSource.getDataSourceUsage())); 483 XMLLib.addNode(dataSourcesNode, dataSourceNode); 484 } 485 return(dataSourcesNode); 486 } //-------------------------- End of Method ------------------------------ 487 488 489 /** 490 * Creates DATASET's DIMENSIONs child DIMENSION/VALUES based on actual usage. 491 * @param dataset DataBean to be used for getting dimension XML. 492 * @return XML DIMENSIONS element for the supplied dataset Databean. 493 */ 494 public Node getDatasetDimensionsNode( 495 String datasetName, 496 ArrayList<DataBean> recordsCollection 497 ) throws Exception { 498 Node containerNode = XMLLib.newNode("DIMENSIONS"); 499 500 ArrayList<DataBean> dimensionToDatasetCollection = new ArrayList<DataBean>(); 501 DimensionToDataset dimensionToDataset = new DimensionToDataset(); 502 dimensionToDataset.setFieldValue("DATASET_NAME", datasetName); 503 this.dataBeanDAOService.load(dimensionToDatasetCollection, dimensionToDataset); 504 505 for(int i=0; i<dimensionToDatasetCollection.size(); i++) { 506 dimensionToDataset = (DimensionToDataset)dimensionToDatasetCollection.get(i); 507 Dimension dimension = new Dimension(); 508 dimension.setFieldValue("NAME", dimensionToDataset.getDimensionName()); 509 if(0 < this.dataBeanDAOService.load(dimension)) { 510 511 Node dimensionNode = this.newNode("DIMENSION", dimension); 512 513 ArrayList<DataBean> dimensionValueCollection = new ArrayList<DataBean>(); 514 DimensionValue dimensionValue = new DimensionValue(); 515 dimensionValue.setFieldValue("DIMENSION_NAME", dimension.getName()); 516 this.dataBeanDAOService.load(dimensionValueCollection, dimensionValue); 517 Node dimensionValuesNode = XMLLib.newNode("VALUES"); 518 XMLLib.addNode(dimensionNode, dimensionValuesNode); 519 520 // loop for all dimension values. Add the element if it is used. 521 DatasetRecord datasetRecord; 522 for(int j=0; j<dimensionValueCollection.size(); j++) { 523 dimensionValue = (DimensionValue)dimensionValueCollection.get(j); 524 boolean dimensionValueUsed = false; 525 for(int k=0; k<recordsCollection.size(); k++) { 526 datasetRecord = (DatasetRecord)recordsCollection.get(k); 527 dimensionValueUsed = 528 (dimension.getName().equals(datasetRecord.getDimension1Name()) 529 && dimensionValue.getValue().equals(datasetRecord.getDimension1Value())) 530 || 531 (dimension.getName().equals(datasetRecord.getDimension2Name()) 532 && dimensionValue.getValue().equals(datasetRecord.getDimension2Value())) 533 || 534 (dimension.getName().equals(datasetRecord.getPeriodDimensionName()) 535 && dimensionValue.getValue().equals(datasetRecord.getPeriodDimensionValue())) 536 ; 537 if(dimensionValueUsed) break; 538 } 539 if(dimensionValueUsed) XMLLib.addNode(dimensionValuesNode, this.newNode("VALUE", dimensionValue)); 540 } 541 XMLLib.addNode(containerNode, dimensionNode); 542 } 543 } 544 545 return(containerNode); 546 } //-------------------------- End of Method ------------------------------ 547 548 549 /** 550 * Creates VALUE_TYPES container and child elements based on the measure and 551 * ancillary values. 552 * @return XML VALUE_TYPES element. 553 */ 554 public Node getValueTypesNode( 555 Measure measure, 556 ArrayList<DataBean> ancillaryValueToDatasetCollection 557 ) throws Exception { 558 Node valueTypesNode = XMLLib.newNode("VALUE_TYPES"); 559 HashSet<String> valueTypeNameHashSet = new HashSet<String>(); 560 561 ValueType valueType = getValueType(measure.getValueTypeName()); 562 XMLLib.addNode(valueTypesNode, newNode("VALUE_TYPE", valueType)); 563 valueTypeNameHashSet.add(valueType.getName()); 564 565 for(DataBean dataBean : ancillaryValueToDatasetCollection) { 566 AncillaryValueToDataset ancillaryValueToDataset = (AncillaryValueToDataset)dataBean; 567 AncillaryValue ancillaryValue = new AncillaryValue(); 568 ancillaryValue.setFieldValue("NAME", ancillaryValueToDataset.getAncillaryValueName()); 569 if(0 < this.dataBeanDAOService.load(ancillaryValue)) { 570 String valueTypeName = ancillaryValue.getValueTypeName(); 571 if(StrLib.isSomething(valueTypeName) && !valueTypeNameHashSet.contains(valueTypeName)) { 572 valueType = getValueType(valueTypeName); 573 XMLLib.addNode(valueTypesNode, newNode("VALUE_TYPE", valueType)); 574 valueTypeNameHashSet.add(valueType.getName()); 575 } 576 } 577 } 578 return(valueTypesNode); 579 } //-------------------------- End of Method ------------------------------ 580 581 public ValueType getValueType(String name) throws Exception { 582 ValueType valueType = new ValueType(); 583 valueType.setFieldValue("NAME", name); 584 this.dataBeanDAOService.load(valueType); 585 return(valueType); 586 } //-------------------------- End of Method ------------------------------ 587 588 589 /** 590 * Creates VALUE_ATTRIBUTES container and child elements. 591 * @return XML VALUE_ATTRIBUTES element. 592 */ 593 public Node getValueAttributesNode() throws Exception { 594 ArrayList<DataBean> collection = new ArrayList<DataBean>(); 595 ValueAttribute valueAttribute = new ValueAttribute(); 596 valueAttribute.setFieldValue("ACTIVE_FLAG", this.dataBeanFlagValue); 597 this.dataBeanDAOService.load(collection, valueAttribute); 598 Node ancillaryValuesNode = this.newNode("VALUE_ATTRIBUTES", "VALUE_ATTRIBUTE", collection); 599 return(ancillaryValuesNode); 600 } //-------------------------- End of Method ------------------------------ 601 602 603 /** 604 * Creates ANCILLARY_VALUES container and child elements based on the supplied 605 * ancillary value collection. 606 * @param ancillaryValueToDatasetCollection to be converted to XML 607 * @return XML ANCILLARY_VALUES element for the supplied collection. 608 */ 609 public Node getDatasetAncillaryValuesNode() throws Exception { 610 ArrayList<DataBean> collection = new ArrayList<DataBean>(); 611 AncillaryValue ancillaryValue = new AncillaryValue(); 612 this.dataBeanDAOService.load(collection, ancillaryValue); 613 Node ancillaryValuesNode = this.newNode("ANCILLARY_VALUES", "ANCILLARY_VALUE", collection); 614 return(ancillaryValuesNode); 615 } //-------------------------- End of Method ------------------------------ 616 293 617 } //============================ END OF CLASS ================================= 294 618 -
trunk/ibisph/src/main/java/org/ibisph/util/XMLLib.java
r17155 r17685 21 21 import org.dom4j.io.DOMWriter; 22 22 import org.dom4j.io.DocumentSource; 23 23 import org.dom4j.XPath; 24 import org.dom4j.xpath.DefaultXPath; 24 25 25 26 /** … … 148 149 return(element); 149 150 } //------------------------------ End of Method --------------------------- 151 152 153 public static XPath newXPath(String xPathExpression) { 154 return( new DefaultXPath(xPathExpression) ); 155 } //-------------------------- End of Method ------------------------------ 150 156 151 157 … … 228 234 * @return List of nodes that matches the XPath expression. 229 235 */ 230 231 236 public static List<Node> getNodes(Node node, String xPathExpression) { 232 237 if(xPathExpression.startsWith("/") && !(node instanceof Document)) { … … 236 241 List<Node> nodes = node.selectNodes(xPathExpression); 237 242 if((nodes.size() < 1) && (node instanceof Document)) return(((Document)node).getRootElement().selectNodes(xPathExpression)); 243 return(nodes); 244 /* 245 Object xPathEvaluationObject = evaluateXPath(node, xPathExpression); 246 if(xPathEvaluationObject instanceof List) { 247 return((List<Node>)xPathEvaluationObject); 248 } 249 else if(xPathEvaluationObject instanceof Node) { 250 List<Node> nodes = new ArrayList<Node>(); 251 nodes.add((Node)xPathEvaluationObject); 252 return(nodes); 253 } 254 return(null); 255 */ 256 } //-------------------------- End of Method ------------------------------ 257 258 259 /** 260 * Simple helper that provides a localized way to get unique nodes via an X 261 * Path expression. 262 * 263 * @param node Document/element/node to retrieve nodes from. 264 * @param xPathExpression Text that contains an XPath expression to be used to 265 * select/specify the desired nodes. 266 * @return Unique list of nodes that matches the XPath expression. 267 */ 268 public static List<Node> getNodes(Node node, String xPathExpression, String sortOrderXPathExpression, boolean distinct) { 269 // XPath sortOrderXPath = XMLLib.newXPath(sortOrderXPathExpression); 270 List<Node> nodes = node.selectNodes(xPathExpression, sortOrderXPathExpression, distinct); 271 if((nodes.size() < 1) && (node instanceof Document)) return(((Document)node).getRootElement().selectNodes(xPathExpression, sortOrderXPathExpression, distinct)); 238 272 return(nodes); 239 273 /*
Note: See TracChangeset
for help on using the changeset viewer.