/*
- * Copyright (C) 2001, 2002 The Mir-coders group
+ * Copyright (C) 2001, 2002 The Mir-coders group
*
* This file is part of Mir.
*
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* In addition, as a special exception, The Mir-coders gives permission to link
- * the code of this program with the com.oreilly.servlet library, any library
- * licensed under the Apache Software License, The Sun (tm) Java Advanced
- * Imaging library (JAI), The Sun JIMI library (or with modified versions of
- * the above that use the same license as the above), and distribute linked
- * combinations including the two. You must obey the GNU General Public
- * License in all respects for all of the code used other than the above
- * mentioned libraries. If you modify this file, you may extend this exception
- * to your version of the file, but you are not obligated to do so. If you do
- * not wish to do so, delete this exception statement from your version.
+ * the code of this program with any library licensed under the Apache Software License,
+ * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library
+ * (or with modified versions of the above that use the same license as the above),
+ * and distribute linked combinations including the two. You must obey the
+ * GNU General Public License in all respects for all of the code used other than
+ * the above mentioned libraries. If you modify this file, you may extend this
+ * exception to your version of the file, but you are not obligated to do so.
+ * If you do not wish to do so, delete this exception statement from your version.
*/
-
package mir.producer.reader;
-import java.util.Arrays;\r
-import java.util.HashMap;\r
-import java.util.HashSet;\r
-import java.util.Iterator;\r
-import java.util.Map;\r
-import java.util.Set;\r
-\r
-import mir.entity.adapter.EntityAdapterModel;\r
-import mir.generator.Generator;\r
-import mir.generator.WriterEngine;\r
-import mir.log.LoggerWrapper;\r
-import mir.producer.ConditionalProducerNode;\r
-import mir.producer.DirCopyingProducerNode;\r
-import mir.producer.EntityBatchingProducerNode;\r
-import mir.producer.EntityEnumeratingProducerNode;\r
-import mir.producer.EntityListProducerNode;\r
-import mir.producer.EvaluatedAssignmentProducerNode;\r
-import mir.producer.ExpandedAssignmentProducerNode;\r
-import mir.producer.FileDateSettingProducerNode;\r
-import mir.producer.FileDeletingProducerNode;\r
-import mir.producer.GeneratingProducerNode;\r
-import mir.producer.LoggingProducerNode;\r
-import mir.producer.LoopProducerNode;\r
-import mir.producer.ProducerNode;\r
-import mir.producer.RSSProducerNode;\r
-import mir.producer.ResourceBundleProducerNode;\r
-import mir.producer.ScriptCallingProducerNode;\r
-import mir.util.XMLReader;\r
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+
+import mir.entity.adapter.EntityAdapterModel;
+import mir.generator.Generator;
+import mir.generator.WriterEngine;
+import mir.log.LoggerWrapper;
+import mir.producer.ConditionalProducerNode;
+import mir.producer.DirCopyingProducerNode;
+import mir.producer.EntityBatchingProducerNode;
+import mir.producer.EntityEnumeratingProducerNode;
+import mir.producer.EntityListProducerNode;
+import mir.producer.EvaluatedAssignmentProducerNode;
+import mir.producer.ExpandedAssignmentProducerNode;
+import mir.producer.FileDateSettingProducerNode;
+import mir.producer.FileDeletingProducerNode;
+import mir.producer.GeneratingProducerNode;
+import mir.producer.LoggingProducerNode;
+import mir.producer.LoopProducerNode;
+import mir.producer.ProducerNode;
+import mir.producer.*;
+import mir.producer.ResourceBundleProducerNode;
+import mir.producer.ScriptCallingProducerNode;
+import mir.util.XMLReader;
import mir.util.XMLReaderTool;
public class DefaultProducerNodeBuilders {
aBuilderLibrary.registerBuilder("While", LoopProducerNodeBuilder.class);
aBuilderLibrary.registerBuilder("RSS", RSSProducerNodeBuilder.class);
+ aBuilderLibrary.registerBuilder("RDFAggregate", RDFAggregatorProducerNodeBuilder.class);
+
+ aBuilderLibrary.registerBuilder("FreeQuery", FreeQueryProducerNodeBuilder.class);
aBuilderLibrary.registerFactory("Enumerate", new EnumeratingProducerNodeBuilder.factory(aModel));
aBuilderLibrary.registerFactory("List", new ListProducerNodeBuilder.factory(aModel));
////////////////////////////////////////////////////////////////////////////////
+ public static class FreeQueryProducerNodeBuilder extends AbstractProducerNodeBuilder {
+ private final static String FREEQUERY_KEY_ATTRIBUTE = KEY_ATTRIBUTE;
+ private final static String FREEQUERY_LIMIT_ATTRIBUTE = LIMIT_ATTRIBUTE;
+ private final static String FREEQUERY_QUERY_ATTRIBUTE = "query";
+ private final static String FREEQUERY_TYPE_ATTRIBUTE = "type";
+ private final static String[] FREEQUERY_REQUIRED_ATTRIBUTES = { KEY_ATTRIBUTE, FREEQUERY_QUERY_ATTRIBUTE };
+ private final static String[] FREEQUERY_OPTIONAL_ATTRIBUTES = { LIMIT_ATTRIBUTE, FREEQUERY_TYPE_ATTRIBUTE };
+ private final static String[] FREEQUERY_SUBNODES = {};
+
+ private String key;
+ private String query;
+ private String limit;
+ private int type;
+
+ public FreeQueryProducerNodeBuilder() {
+ super(FREEQUERY_SUBNODES);
+ }
+
+ public void setAttributes(Map anAttributes) throws ProducerConfigExc, XMLReader.XMLReaderExc {
+ String typeString;
+
+ XMLReaderTool.checkAttributes(anAttributes, FREEQUERY_REQUIRED_ATTRIBUTES, FREEQUERY_OPTIONAL_ATTRIBUTES);
+
+ key = (String) anAttributes.get(FREEQUERY_KEY_ATTRIBUTE);
+ query = (String) anAttributes.get(FREEQUERY_QUERY_ATTRIBUTE);
+ limit = (String) anAttributes.get(FREEQUERY_LIMIT_ATTRIBUTE);
+
+ if (anAttributes.containsKey(FREEQUERY_TYPE_ATTRIBUTE)) {
+ typeString = ((String) anAttributes.get( FREEQUERY_TYPE_ATTRIBUTE ));
+
+ if (typeString.toLowerCase().equals("set"))
+ type = FreeQueryProducerNode.QUERY_TYPE_SET;
+ else if (typeString.toLowerCase().equals("row"))
+ type = FreeQueryProducerNode.QUERY_TYPE_ROW;
+ else if (typeString.toLowerCase().equals("value"))
+ type = FreeQueryProducerNode.QUERY_TYPE_VALUE;
+ else
+ throw new ProducerConfigExc("unknown query type: " + typeString + " (allowed are set, row and value)");
+ }
+ else
+ type = FreeQueryProducerNode.QUERY_TYPE_SET;
+ };
+
+ public ProducerNode constructNode() {
+ return new FreeQueryProducerNode(key, query, limit, type);
+ };
+ }
+
+////////////////////////////////////////////////////////////////////////////////
+
public static class ResourceBundleProducerNodeBuilder extends AbstractProducerNodeBuilder {
private final static String RESOURCEBUNDLE_KEY_ATTRIBUTE = KEY_ATTRIBUTE;
private final static String RESOURCEBUNDLE_BUNDLE_ATTRIBUTE = "bundle";
////////////////////////////////////////////////////////////////////////////////
+ public static class RDFAggregatorProducerNodeBuilder extends AbstractProducerNodeBuilder {
+ private final static String RDF_AGGREGATOR_KEY_ATTRIBUTE = KEY_ATTRIBUTE;
+ private final static String RDF_AGGREGATOR_SOURCE_ATTRIBUTE = "source";
+ private final static String RDF_AGGREGATOR_ORDER_ATTRIBUTE = ORDER_ATTRIBUTE;
+ private final static String RDF_AGGREGATOR_FILTER_ATTRIBUTE = "filter";
+
+ private final static String[] RDF_AGGREGATOR_REQUIRED_ATTRIBUTES = { RDF_AGGREGATOR_KEY_ATTRIBUTE, RDF_AGGREGATOR_SOURCE_ATTRIBUTE };
+ private final static String[] RDF_AGGREGATOR_OPTIONAL_ATTRIBUTES = { RDF_AGGREGATOR_ORDER_ATTRIBUTE, RDF_AGGREGATOR_FILTER_ATTRIBUTE };
+ private final static String[] RDF_AGGREGATOR_SUBNODES = { };
+
+ private String key;
+ private String source;
+ private String order;
+ private String filter;
+
+ public RDFAggregatorProducerNodeBuilder() {
+ super(RDF_AGGREGATOR_SUBNODES);
+ }
+
+ public void setAttributes(Map anAttributes) throws ProducerConfigExc, XMLReader.XMLReaderExc {
+ XMLReaderTool.checkAttributes(anAttributes, RDF_AGGREGATOR_REQUIRED_ATTRIBUTES, RDF_AGGREGATOR_OPTIONAL_ATTRIBUTES);
+
+ key = (String) anAttributes.get( RDF_AGGREGATOR_KEY_ATTRIBUTE );
+ source = (String) anAttributes.get( RDF_AGGREGATOR_SOURCE_ATTRIBUTE );
+ order = XMLReaderTool.getStringAttributeWithDefault(anAttributes, RDF_AGGREGATOR_SOURCE_ATTRIBUTE, "");
+ filter = XMLReaderTool.getStringAttributeWithDefault(anAttributes, RDF_AGGREGATOR_FILTER_ATTRIBUTE, "");
+ };
+
+ public ProducerNode constructNode() {
+ return new RDFAggregatorProducerNode(key, source, order, filter);
+ };
+ }
+
+////////////////////////////////////////////////////////////////////////////////
+
public static class ScriptedProducerParameterNodeBuilder implements ProducerNodeBuilder {
private String parameterName;
private String scriptedNodeName;