This is an automated email from the ASF dual-hosted git repository. jamesbognar pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/juneau.git
The following commit(s) were added to refs/heads/master by this push: new 3bf3433 Remove old Cognos DTOs. 3bf3433 is described below commit 3bf3433ba107775d2f83389691d04d5dee4651fc Author: JamesBognar <james.bog...@salesforce.com> AuthorDate: Sat Jan 30 12:11:48 2021 -0500 Remove old Cognos DTOs. --- .../apache/juneau/dto/cognos/CognosXmlTest.java | 113 ----------- .../dto/{cognos/package-info.java => Temp.java} | 99 ++++++++-- .../java/org/apache/juneau/dto/cognos/Column.java | 161 ---------------- .../java/org/apache/juneau/dto/cognos/DataSet.java | 207 --------------------- .../java/org/apache/juneau/dto/cognos/package.html | 58 ------ 5 files changed, 79 insertions(+), 559 deletions(-) diff --git a/juneau-core/juneau-core-utest/src/test/java/org/apache/juneau/dto/cognos/CognosXmlTest.java b/juneau-core/juneau-core-utest/src/test/java/org/apache/juneau/dto/cognos/CognosXmlTest.java deleted file mode 100644 index 878b614..0000000 --- a/juneau-core/juneau-core-utest/src/test/java/org/apache/juneau/dto/cognos/CognosXmlTest.java +++ /dev/null @@ -1,113 +0,0 @@ -// *************************************************************************************************************************** -// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file * -// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file * -// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance * -// * with the License. You may obtain a copy of the License at * -// * * -// * http://www.apache.org/licenses/LICENSE-2.0 * -// * * -// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an * -// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * -// * specific language governing permissions and limitations under the License. * -// *************************************************************************************************************************** -package org.apache.juneau.dto.cognos; - -import static org.apache.juneau.assertions.Assertions.*; -import static org.junit.Assert.*; -import static org.junit.runners.MethodSorters.*; - -import java.util.*; - -import org.apache.juneau.*; -import org.apache.juneau.collections.*; -import org.apache.juneau.xml.*; -import org.junit.*; - -@FixMethodOrder(NAME_ASCENDING) -public class CognosXmlTest { - - //==================================================================================================== - // test - //==================================================================================================== - @Test - public void test() throws Exception { - String expected = "" - + "<dataset xmlns='http://developer.cognos.com/schemas/xmldata/1/'>\n" - + " <metadata>\n" - + " <item name='asOfDate' type='xs:string' length='12'/>\n" - + " <item name='rateOfReturn' type='xs:double'/>\n" - + " <item name='famAcctIndex' type='xs:string' length='3'/>\n" - + " <item name='rowID' type='xs:string' length='1'/>\n" - + " <item name='brM' type='xs:string' length='1'/>\n" - + " <item name='productLineCode' type='xs:int'/>\n" - + " </metadata>\n" - + " <data>\n" - + " <row>\n" - + " <value>Apr 26, 2002</value>\n" - + " <value>0.21006642</value>\n" - + " <value>JA1</value>\n" - + " <value>F</value>\n" - + " <value>B</value>\n" - + " <value>1</value>\n" - + " </row>\n" - + " <row>\n" - + " <value>Apr 27, 2002</value>\n" - + " <value>0.1111111</value>\n" - + " <value>BBB</value>\n" - + " <value>G</value>\n" - + " <value>B</value>\n" - + " <value>2</value>\n" - + " </row>\n" - + " </data>\n" - + "</dataset>\n"; - - List<Object> rows = new LinkedList<>(); - rows.add(OMap.ofJson("{asOfDate:'Apr 26, 2002',rateOfReturn:0.21006642,famAcctIndex:'JA1',rowID:'F',brM:'B',productLineCode:1}")); - rows.add(new Item("Apr 27, 2002", 0.1111111, "BBB", "G", "B", 2)); - - Column[] c = { - new Column("asOfDate", "xs:string", 12), - new Column("rateOfReturn", "xs:double"), - new Column("famAcctIndex", "xs:string", 3), - new Column("rowID", "xs:string", 1), - new Column("brM", "xs:string", 1), - new Column("productLineCode", "xs:int") - }; - - XmlSerializer s = XmlSerializer.create() - .ws() - .sq() - .defaultNamespace("cognos") - .ns() - .addNamespaceUrisToRoot() - .build(); - - DataSet ds = new DataSet(c, rows, BeanContext.DEFAULT.createSession()); - - String out = s.serialize(ds); - - assertEquals(expected, out); - - // Make sure we can parse it back into a POJO. - DataSet ds2 = XmlParser.DEFAULT.parse(out, DataSet.class); - assertObject(ds).sameAs(ds2); - } - - public static class Item { - public String asOfDate; - public double rateOfReturn; - public String famAcctIndex; - public String rowID; - public String brM; - public int productLineCode; - - public Item(String asOfDate, double rateOfReturn, String famAcctIndex, String rowID, String brM, int productLineCode) { - this.asOfDate = asOfDate; - this.rateOfReturn = rateOfReturn; - this.famAcctIndex = famAcctIndex; - this.rowID = rowID; - this.brM = brM; - this.productLineCode = productLineCode; - } - } -} \ No newline at end of file diff --git a/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/cognos/package-info.java b/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/Temp.java similarity index 51% rename from juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/cognos/package-info.java rename to juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/Temp.java index 4c61930..c2fbac4 100644 --- a/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/cognos/package-info.java +++ b/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/Temp.java @@ -1,20 +1,79 @@ -// *************************************************************************************************************************** -// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file * -// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file * -// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance * -// * with the License. You may obtain a copy of the License at * -// * * -// * http://www.apache.org/licenses/LICENSE-2.0 * -// * * -// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an * -// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * -// * specific language governing permissions and limitations under the License. * -// *************************************************************************************************************************** -// XML namespaces used in this package -@XmlSchema(prefix="cognos", namespace="http://developer.cognos.com/schemas/xmldata/1/") -/** - * Cognos Data Transfer Objects - */ -package org.apache.juneau.dto.cognos; -import org.apache.juneau.xml.annotation.*; - +// *************************************************************************************************************************** +// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file * +// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file * +// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance * +// * with the License. You may obtain a copy of the License at * +// * * +// * http://www.apache.org/licenses/LICENSE-2.0 * +// * * +// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an * +// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * +// * specific language governing permissions and limitations under the License. * +// *************************************************************************************************************************** +package org.apache.juneau.dto; + +/** + * TODO + * + */ +public class Temp { + +// //----------------------------------------------------------------------------------------------------------------- +// // xxx +// //----------------------------------------------------------------------------------------------------------------- +// +// /** +// * Bean property getter: <property>XXX</property>. +// * +// * <p> +// * XXX +// * +// * @return The property value, or <jk>null</jk> if it is not set. +// */ +// public String getxxx() { +// return xxx; +// } +// +// /** +// * Bean property setter: <property>XXX</property>. +// * +// * <p> +// * XXX +// * +// * @param value +// * The new value for this property. +// * <br>Can be <jk>null</jk> to unset the property. +// */ +// public void setxxx(xxx value) { +// this.xxx = value; +// } +// +// /** +// * Bean property fluent getter: <property>XXX</property>. +// * +// * <p> +// * XXX +// * +// * @return The property value as an {@link Optional}. Never <jk>null</jk>. +// */ +// public Optional<String> xxx() { +// return Optional.ofNullable(xxx); +// } +// +// /** +// * Bean property fluent setter: <property>XXX</property>. +// * +// * <p> +// * XXX +// * +// * @param value +// * The new value for this property. +// * <br>Can be <jk>null</jk> to unset the property. +// * @return This object (for method chaining). +// */ +// public XXX xxx(xxx value) { +// setxxx(value); +// return this; +// } + +} diff --git a/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/cognos/Column.java b/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/cognos/Column.java deleted file mode 100644 index 760fded..0000000 --- a/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/cognos/Column.java +++ /dev/null @@ -1,161 +0,0 @@ -// *************************************************************************************************************************** -// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file * -// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file * -// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance * -// * with the License. You may obtain a copy of the License at * -// * * -// * http://www.apache.org/licenses/LICENSE-2.0 * -// * * -// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an * -// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * -// * specific language governing permissions and limitations under the License. * -// *************************************************************************************************************************** -package org.apache.juneau.dto.cognos; - -import org.apache.juneau.annotation.*; -import org.apache.juneau.transform.*; -import org.apache.juneau.xml.annotation.*; - -/** - * Represents a meta-data column in a Cognos dataset. - * - * <p> - * When serialized to XML, creates the following construct: - * <p class='bcode w800'> - * <xt><item</xt> <xa>name</xa>=<xs>'name'</xs> <xa>type</xa>=<xs>'xs:String'</xs> <xa>length</xa>=<xs>'255'</xs>/> - * </p> - */ -@SuppressWarnings({"rawtypes"}) -@Bean(typeName="item", p="name,type,length") -public class Column { - - private String name, type; - private Integer length; - PojoSwap pojoSwap; - - /** Bean constructor. */ - public Column() {} - - /** - * Constructor. - * - * @param name The column name. - * @param type The column type (e.g. <js>"xs:String"</js>). - */ - public Column(String name, String type) { - this(name, type, null); - } - - /** - * Constructor. - * - * @param name The column name. - * @param type The column type (e.g. <js>"xs:String"</js>). - * @param length The column length (e.g. <c>255</c>). - */ - public Column(String name, String type, Integer length) { - this.name = name; - this.type = type; - this.length = length; - } - - /** - * Associates a POJO swap with this column. - * - * <p> - * Typically used to define columns that don't exist on the underlying beans being serialized. - * - * <p> - * For example, the <c>AddressBookResource</c> sample defined the following POJO swap to define an additional - * <js>"numAddresses"</js> column even though no such property exists on the serialized beans. - * <p class='bcode w800'> - * Column c = <jk>new</jk> Column(<js>"numAddresses"</js>, <js>"xs:int"</js>) - * .addPojoSwaps( - * <jk>new</jk> PojoSwap<Person,Integer>() { - * <ja>@Override</ja> - * <jk>public</jk> Integer swap(Person p) { - * <jk>return</jk> p.<jf>addresses</jf>.size(); - * } - * } - * ); - * </p> - * - * @param pojoSwap The POJO swap to associate with the column. - * @return This object (for method chaining). - */ - public Column addPojoSwap(PojoSwap pojoSwap) { - this.pojoSwap = pojoSwap; - return this; - } - - - //----------------------------------------------------------------------------------------------------------------- - // Bean properties - //----------------------------------------------------------------------------------------------------------------- - - /** - * Bean property getter: <property>name</property>. - * - * @return The value of the <property>name</property> property on this bean, or <jk>null</jk> if it is not set. - */ - @Xml(format=XmlFormat.ATTR) - public String getName() { - return name; - } - - /** - * Bean property setter: <property>name</property>. - * - * @param name The new value for the <property>name</property> property on this bean. - * @return This object (for method chaining). - */ - public Column setName(String name) { - this.name = name; - return this; - } - - /** - * Bean property getter: <property>type</property>. - * - * @return The value of the <property>type</property> property on this bean, or <jk>null</jk> if it is not set. - */ - @Xml(format=XmlFormat.ATTR) - public String getType() { - return type; - } - - /** - * Bean property setter: <property>type</property>. - * - * @param type The new value for the <property>type</property> property on this bean. - * @return This object (for method chaining). - */ - public Column setType(String type) { - this.type = type; - return this; - } - - /** - * Bean property getter: <property>length</property>. - * - * @return The value of the <property>length</property> property on this bean, or <jk>null</jk> if length is not - * applicable for the specified type. - */ - @Xml(format=XmlFormat.ATTR) - public Integer getLength() { - return length; - } - - /** - * Bean property setter: <property>length</property>. - * - * @param length The new value for the <property>length</property> property on this bean. - * Can be <jk>null</jk> if length is not applicable for the specified type. - * @return This object (for method chaining). - */ - public Column setLength(Integer length) { - this.length = length; - return this; - } -} - diff --git a/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/cognos/DataSet.java b/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/cognos/DataSet.java deleted file mode 100644 index 28b1693..0000000 --- a/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/cognos/DataSet.java +++ /dev/null @@ -1,207 +0,0 @@ -// *************************************************************************************************************************** -// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file * -// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file * -// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance * -// * with the License. You may obtain a copy of the License at * -// * * -// * http://www.apache.org/licenses/LICENSE-2.0 * -// * * -// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an * -// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * -// * specific language governing permissions and limitations under the License. * -// *************************************************************************************************************************** -package org.apache.juneau.dto.cognos; - -import java.util.*; - -import org.apache.juneau.*; -import org.apache.juneau.annotation.*; -import org.apache.juneau.xml.annotation.*; - -/** - * Represents a Cognos dataset. - * - * <p> - * When serialized to XML, creates the following construct (example pulled from <c>AddressBookResource</c>): - * <p class='bcode w800'> - * <xt><?xml</xt> <xa>version</xa>=<xs>'1.0'</xs> <xa>encoding</xa>=<xs>'UTF-8'</xs><xt>?></xt> - * <xt><c:dataset <xa>xmlns:c</xa>=<xs>'http://developer.cognos.com/schemas/xmldata/1/'</xs>></xt> - * <xt><c:metadata></xt> - * <xt><c:item</xt> <xa>name</xa>=<xs>'name'</xs> <xa>type</xa>=<xs>'xs:String'</xs> - * <xa>length</xa>=<xs>'255'</xs><xt>/></xt> - * <xt><c:item</xt> <xa>name</xa>=<xs>'age'</xs> <xa>type</xa>=<xs>'xs:int'</xs><xt>/></xt> - * <xt><c:item</xt> <xa>name</xa>=<xs>'numAddresses'</xs> <xa>type</xa>=<xs>'xs:int'</xs><xt>/></xt> - * <xt></c:metadata></xt> - * <xt><c:data></xt> - * <xt><c:row></xt> - * <xt><c:value></xt>Barack Obama<xt></c:value></xt> - * <xt><c:value></xt>52<xt></c:value></xt> - * <xt><c:value></xt>2<xt></c:value></xt> - * <xt></c:row></xt> - * <xt><c:row></xt> - * <xt><c:value></xt>George Walker Bush<xt></c:value></xt> - * <xt><c:value></xt>67<xt></c:value></xt> - * <xt><c:value></xt>2<xt></c:value></xt> - * <xt></c:row></xt> - * <xt></c:data></xt> - * <xt></c:dataset></xt> - * </p> - * - * <p> - * Only 2-dimensional POJOs (arrays or collections of maps or beans) can be serialized to Cognos. - * - * <h5 class='section'>Example:</h5> - * - * The construct shown above is a serialized <c>AddressBook</c> object which is a subclass of - * <c>LinkedList<Person></c>. - * The code for generating the XML is as follows... - * <p class='bcode w800'> - * Column[] items = { - * <jk>new</jk> Column(<js>"name"</js>, <js>"xs:String"</js>, 255), - * <jk>new</jk> Column(<js>"age"</js>, <js>"xs:int"</js>), - * <jk>new</jk> Column(<js>"numAddresses"</js>, <js>"xs:int"</js>) - * .addPojoSwap( - * <jk>new</jk> PojoSwap<Person,Integer>() { - * <ja>@Override</ja> - * <jk>public</jk> Integer swap(Person p) { - * <jk>return</jk> p.<jf>addresses</jf>.size(); - * } - * } - * ) - * }; - * - * DataSet ds = <jk>new</jk> DataSet(items, <jsf>addressBook</jsf>, BeanContext.<jsf>DEFAULT</jsf>); - * - * String xml = XmlSerializer.<jsf>DEFAULT_SQ</jsf>.serialize(ds); - * </p> - */ -@SuppressWarnings("unchecked") -@Bean(typeName="dataset", properties="metadata,data") -public class DataSet { - - private Column[] metaData; - private List<Row> data; - - /** Bean constructor. */ - public DataSet() {} - - /** - * Constructor. - * - * @param columns The meta-data that represents the columns in the dataset. - * @param o - * The POJO being serialized to Cognos. - * Must be an array/collection of beans/maps. - * @param session The bean session used to convert POJOs to strings. - * @throws Exception An error occurred trying to serialize the POJO. - */ - public DataSet(Column[] columns, Object o, BeanSession session) throws Exception { - metaData = columns; - data = new LinkedList<>(); - if (o != null) { - if (o.getClass().isArray()) - o = Arrays.asList((Object[])o); - if (o instanceof Collection) { - Collection<?> c = (Collection<?>)o; - for (Object o2 : c) { - Row r = new Row(); - Map<?,?> m = null; - if (o2 instanceof Map) - m = (Map<?,?>)o2; - else - m = session.toBeanMap(o2); - for (Column col : columns) { - Object v; - if (col.pojoSwap != null) - v = col.pojoSwap.swap(session, o2); - else - v = m.get(col.getName()); - r.add(v == null ? null : v.toString()); - } - data.add(r); - } - } - } - } - - /** - * Represents a row of data. - * - * <p> - * When serialized to XML, creates the following construct (example pulled from <c>AddressBookResource</c>): - * <p class='bcode w800'> - * <xt><row></xt> - * <xt><value></xt>Barack Obama<xt></value></xt> - * <xt><value></xt>52<xt></value></xt> - * <xt><value></xt>2<xt></value></xt> - * <xt></row></xt> - * </p> - */ - @Bean(typeName="row") - public static final class Row { - private List<String> values = new LinkedList<>(); - - void add(String value) { - values.add(value); - } - - /** - * Returns the values in this row. - * - * @return The values in this row. - */ - @Xml(format=XmlFormat.COLLAPSED, childName="value") - public List<String> getValues() { - return values; - } - } - - - //----------------------------------------------------------------------------------------------------------------- - // Bean properties - //----------------------------------------------------------------------------------------------------------------- - - /** - * Bean property getter: <property>metadata</property>. - * - * @return The value of the <property>metadata</property> property on this bean, or <jk>null</jk> if it is not set. - */ - @Beanp("metadata") - public Column[] getMetaData() { - return metaData; - } - - /** - * Bean property setter: <property>metadata</property>. - * - * @param metaData The new value for the <property>metadata</property> property on this bean. - * @return This object (for method chaining). - */ - @Beanp("metadata") - public DataSet setMetaData(Column[] metaData) { - this.metaData = metaData; - return this; - } - - /** - * Bean property getter: <property>data</property>. - * - * @return The value of the <property>data</property> property on this bean, or <jk>null</jk> if it is not set. - */ - @Beanp("data") - public List<Row> getData() { - return data; - } - - /** - * Bean property setter: <property>data</property>. - * - * @param data The new value for the <property>data</property> property on this bean. - * @return This object (for method chaining). - */ - @Beanp("data") - public DataSet setData(List<Row> data) { - this.data = data; - return this; - } -} diff --git a/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/cognos/package.html b/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/cognos/package.html deleted file mode 100644 index 8c55743..0000000 --- a/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/cognos/package.html +++ /dev/null @@ -1,58 +0,0 @@ -<!DOCTYPE HTML> -<!-- -/*************************************************************************************************************************** - * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - * - ***************************************************************************************************************************/ - --> -<html> -<head> - <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> - <style type="text/css"> - /* For viewing in Page Designer */ - @IMPORT url("../../../../../../../javadoc.css"); - - /* For viewing in REST interface */ - @IMPORT url("../htdocs/javadoc.css"); - body { - margin: 20px; - } - </style> - <script> - /* Replace all @code and @link tags. */ - window.onload = function() { - document.body.innerHTML = document.body.innerHTML.replace(/\{\@code ([^\}]+)\}/g, '<code>$1</code>'); - document.body.innerHTML = document.body.innerHTML.replace(/\{\@link (([^\}]+)\.)?([^\.\}]+)\}/g, '<code>$3</code>'); - } - </script> -</head> -<body> -<p>Cognos Data Transfer Objects</p> -<script> - function toggle(x) { - var div = x.nextSibling; - while (div != null && div.nodeType != 1) - div = div.nextSibling; - if (div != null) { - var d = div.style.display; - if (d == 'block' || d == '') { - div.style.display = 'none'; - x.className += " closed"; - } else { - div.style.display = 'block'; - x.className = x.className.replace(/(?:^|\s)closed(?!\S)/g , '' ); - } - } - } -</script> -</body> -</html> \ No newline at end of file