Skip to content

Commit

Permalink
Merge branch 'develop' into feature/lucence-range-index
Browse files Browse the repository at this point in the history
  • Loading branch information
wolfgangmm committed Sep 14, 2013
2 parents 2f815e1 + 977cbbf commit 41c094d
Show file tree
Hide file tree
Showing 51 changed files with 1,900 additions and 1,065 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public void run() {
try {
db = BrokerPool.getInstance();

db.addObserver(this);
BrokerPool.registerStatusObserver(this);

broker = db.get(null);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* eXist Open Source Native XML Database
* Copyright (C) 2009 The eXist Project
* Copyright (C) 2009-2013 The eXist-db Project
* http://exist-db.org
*
* This program is free software; you can redistribute it and/or
Expand All @@ -23,6 +23,7 @@

import org.apache.log4j.Logger;
import org.exist.xquery.XPathException;
import org.jfree.chart.axis.CategoryLabelPositions;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.util.TableOrder;
import org.w3c.dom.Node;
Expand All @@ -34,6 +35,7 @@
*
* @author Dannes Wessels (dizzzz@exist-db.org)
* @author Andrzej Taramina (andrzej@chaeron.com)
* @author Leif-Jöran Olsson (ljo@exist-db.org)
*/
public class Configuration {

Expand Down Expand Up @@ -63,6 +65,7 @@ public class Configuration {
private String categoryItemLabelGeneratorClass;
private String categoryItemLabelGeneratorParameter = "{2}";
private String categoryItemLabelGeneratorNumberFormat = "0";
private CategoryLabelPositions categoryLabelPositions = CategoryLabelPositions.STANDARD;

// Orientation and Order
private TableOrder order = TableOrder.BY_COLUMN;
Expand Down Expand Up @@ -207,6 +210,10 @@ public String getCategoryItemLabelGeneratorParameter() {
public String getCategoryItemLabelGeneratorNumberFormat() {
return categoryItemLabelGeneratorNumberFormat;
}

public CategoryLabelPositions getCategoryLabelPositions() {
return categoryLabelPositions;
}

public String getSeriesColors() {
return seriesColors;
Expand Down Expand Up @@ -489,7 +496,25 @@ public void parse(Node configuration) throws XPathException {
} else {
categoryItemLabelGeneratorNumberFormat = value;
}


} else if (child.getLocalName().equals("categoryLabelPositions")) {
String value = getValue(child);
if (value == null) {
throw new XPathException("Value for 'categoryLabelPostions' cannot be parsed");
} else if ("UP_45".equalsIgnoreCase(value)) {
categoryLabelPositions = CategoryLabelPositions.UP_45;
} else if ("UP_90".equalsIgnoreCase(value)) {
categoryLabelPositions = CategoryLabelPositions.UP_90;
} else if ("DOWN_45".equalsIgnoreCase(value)) {
categoryLabelPositions = CategoryLabelPositions.DOWN_45;

} else if ("DOWN_90".equalsIgnoreCase(value)) {
categoryLabelPositions = CategoryLabelPositions.DOWN_90;

} else {
throw new XPathException("Wrong value for 'categoryLabelPositions'");
}

} else if (child.getLocalName().equals("imageType")) {
String value = getValue(child);
if (value == null) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* eXist Open Source Native XML Database
* Copyright (C) 2009 The eXist Project
* Copyright (C) 2009-2013 The eXist-db Project
* http://exist-db.org
*
* This program is free software; you can redistribute it and/or
Expand Down Expand Up @@ -33,11 +33,13 @@
import org.exist.xquery.XPathException;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.axis.CategoryLabelPositions;
import org.jfree.chart.labels.CategoryItemLabelGenerator;
import org.jfree.chart.labels.StandardCategoryToolTipGenerator;
import org.jfree.chart.labels.StandardPieSectionLabelGenerator;
import org.jfree.chart.plot.CategoryPlot;
import org.jfree.chart.plot.PiePlot;
import org.jfree.chart.plot.MultiplePiePlot;
import org.jfree.chart.plot.SpiderWebPlot;
import org.jfree.chart.renderer.category.CategoryItemRenderer;
import org.jfree.chart.title.LegendTitle;
Expand Down Expand Up @@ -237,8 +239,9 @@ private static void setCategoryChartParameters( JFreeChart chart, Configuration
{
setCategoryRange( chart, config );
setCategoryItemLabelGenerator( chart, config );
setCategoryLabelPositions( chart, config );
setSeriesColors( chart, config );
setAxisColors( chart, config );
setAxisColors( chart, config );
}


Expand Down Expand Up @@ -295,6 +298,13 @@ private static void setCategoryItemLabelGenerator( JFreeChart chart, Configurati
}
}

private static void setCategoryLabelPositions( JFreeChart chart, Configuration config )
{
CategoryLabelPositions positions = config.getCategoryLabelPositions();
if (chart.getPlot() instanceof CategoryPlot) {
((CategoryPlot)chart.getPlot()).getDomainAxis().setCategoryLabelPositions(positions);
}
}

private static void setSeriesColors( JFreeChart chart, Configuration config )
{
Expand Down Expand Up @@ -373,7 +383,11 @@ private static void setPieSectionLabel( JFreeChart chart, Configuration config )
String pieSectionPercentFormat = config.getPieSectionPercentFormat();

if( pieSectionLabel != null ) {
if (chart.getPlot() instanceof MultiplePiePlot) {
((PiePlot) ((MultiplePiePlot)chart.getPlot()).getPieChart().getPlot()).setLabelGenerator( new StandardPieSectionLabelGenerator( pieSectionLabel, new DecimalFormat( pieSectionNumberFormat ), new DecimalFormat( pieSectionPercentFormat ) ) );
} else {
((PiePlot)chart.getPlot()).setLabelGenerator( new StandardPieSectionLabelGenerator( pieSectionLabel, new DecimalFormat( pieSectionNumberFormat ), new DecimalFormat( pieSectionPercentFormat ) ) );
}
}
}

Expand Down
30 changes: 22 additions & 8 deletions schema/conf.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,21 @@
-->

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" version="1.0">

<!-- Shared types -->
<xs:simpleType name="yes_no">
<xs:restriction base="xs:string">
<xs:enumeration value="yes"/>
<xs:enumeration value="no"/>
</xs:restriction>
</xs:simpleType>

<xs:complexType name="parameterType">
<xs:attribute name="name" type="xs:string"/>
<xs:attribute name="value" type="xs:string"/>
</xs:complexType>

<!-- Root element -->
<xs:element name="exist">
<xs:complexType>
<xs:sequence>
Expand All @@ -28,12 +37,14 @@
<xs:element name="startup" minOccurs="0">
<xs:complexType>
<xs:sequence>
<!-- TODO commonise with collection.xconf.xsd -->
<xs:element name="triggers" minOccurs="0">
<xs:complexType>
<xs:sequence>
<xs:element name="trigger" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence minOccurs="0" maxOccurs="unbounded">
<xs:element name="parameter" type="parameterType"/>
</xs:sequence>
<xs:attribute name="class" type="xs:string"/>
</xs:complexType>
</xs:element>
Expand Down Expand Up @@ -150,7 +161,8 @@
<xs:attribute name="flushAfter" type="xs:integer"
default="300"/>
<xs:attribute name="n" type="xs:integer" default="3"/>
<xs:attribute name="buffer" type="xs:integer" default="32"/>
<xs:attribute name="buffer" type="xs:integer"
default="32"/>
</xs:complexType>
</xs:element>
</xs:sequence>
Expand Down Expand Up @@ -343,12 +355,13 @@
<xs:element name="module" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="parameter" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="name" type="xs:string"/>
<xs:attribute name="value" type="xs:string"/>
</xs:complexType>
</xs:element>
<xs:element name="parameter" minOccurs="0"
maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="name" type="xs:string"/>
<xs:attribute name="value" type="xs:string"/>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="class" type="xs:string"/>
<xs:attribute name="uri" type="xs:anyURI"/>
Expand Down Expand Up @@ -385,4 +398,5 @@
</xs:sequence>
</xs:complexType>
</xs:element>

</xs:schema>
5 changes: 4 additions & 1 deletion src/org/exist/memtree/DocumentImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ public int addAttribute(int nodeNum, QName qname, String value, int type) throws
if (nodeKind == null) {
init();
}
if ((nodeNum > 0 ) && (nodeKind[nodeNum] != Node.ELEMENT_NODE)) {
if ((nodeNum > 0 ) && !(nodeKind[nodeNum] == Node.ELEMENT_NODE || nodeKind[nodeNum] == NodeImpl.NAMESPACE_NODE)) {
throw( new DOMException( DOMException.INUSE_ATTRIBUTE_ERR,
"err:XQTY0024: An attribute node cannot follow a node that is not an attribute node."));
}
Expand Down Expand Up @@ -1104,6 +1104,9 @@ private void copyStartNode(NodeImpl node, DocumentBuilderReceiver receiver, bool
final String data = new String(document.characters, document.alpha[nr], document.alphaLen[nr]);
receiver.processingInstruction(qn.getLocalName(), data);
break;
case NodeImpl.NAMESPACE_NODE:
receiver.addNamespaceNode(document.namespaceCode[nr]);
break;
case NodeImpl.REFERENCE_NODE:
if (expandRefs) {
DBBroker broker = null;
Expand Down
17 changes: 11 additions & 6 deletions src/org/exist/memtree/MemTreeBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -446,13 +446,18 @@ public int namespaceNode( String prefix, String uri )
public int namespaceNode( QName qn )
{
final int lastNode = doc.getLastNode();
final QName elemQN = doc.nodeName[lastNode];
final String elemPrefix = ( elemQN.getPrefix() == null ) ? "" : elemQN.getPrefix();

if( elemPrefix.equals( qn.getLocalName() ) && ( elemQN.getNamespaceURI() != null ) && !elemQN.getNamespaceURI().equals( qn.getNamespaceURI() ) ) {
return( -1 );
boolean addNode = true;
if (doc.nodeName != null) {
final QName elemQN = doc.nodeName[lastNode];
if (elemQN != null) {
final String elemPrefix = ( elemQN.getPrefix() == null ) ? "" : elemQN.getPrefix();

if( elemPrefix.equals( qn.getLocalName() ) && ( elemQN.getNamespaceURI() != null ) ) {
addNode = false;
}
}
}
return( doc.addNamespace( lastNode, qn ) );
return( addNode ? doc.addNamespace( lastNode, qn ) : -1 );
}


Expand Down
11 changes: 10 additions & 1 deletion src/org/exist/memtree/NamespaceNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public short getNodeType()
//XQuery doesn't support namespace nodes
//so, mapping as an attribute at *serialization tile* makes sense
//however, the Query parser should not accept them in constructors !
return( Node.ATTRIBUTE_NODE );
return( NodeImpl.NAMESPACE_NODE);
}


Expand Down Expand Up @@ -142,6 +142,15 @@ public void setValue( String value ) throws DOMException
{
}

@Override
public Node getFirstChild() {
return null;
}

@Override
public Node getLastChild() {
return null;
}

public String getNodeValue() throws DOMException
{
Expand Down
1 change: 1 addition & 0 deletions src/org/exist/xquery/DynamicFunctionCall.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ public Sequence eval(Sequence contextSequence, Item contextItem)
final FunctionCall call = ref.getCall();
call.setArguments(arguments);
final PartialFunctionApplication partialApp = new PartialFunctionApplication(context, call);
partialApp.analyze(new AnalyzeContextInfo(cachedContextInfo));
return partialApp.eval(contextSequence, contextItem);
} catch (final XPathException e) {
e.setLocation(line, column, getSource());
Expand Down
2 changes: 1 addition & 1 deletion src/org/exist/xquery/EnclosedExpr.java
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ else if (buf.length() > 0)
{throw new XPathException(this, ErrorCodes.XQTY0024,
"An attribute may not appear after another child node.");}
next.copyTo(context.getBroker(), receiver);
allowAttribs = next.getType() == Type.ATTRIBUTE;
allowAttribs = next.getType() == Type.ATTRIBUTE || next.getType() == Type.NAMESPACE;
next = i.nextItem();
}
}
Expand Down
6 changes: 6 additions & 0 deletions src/org/exist/xquery/ErrorCodes.java
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,12 @@ public class ErrorCodes {
public static ErrorCode XQDY0091 = new W3CErrorCode("XQDY0091", "An implementation MAY raise a dynamic error if an xml:id error, as defined in [XML ID], is encountered during construction of an attribute named xml:id.");
public static ErrorCode XQDY0092 = new W3CErrorCode("XQDY0092", "An implementation MAY raise a dynamic error if a constructed attribute named xml:space has a value other than preserve or default.");
public static ErrorCode XQST0093 = new W3CErrorCode("XQST0093", "It is a static error to import a module M1 if there exists a sequence of modules M1 ... Mi ... M1 such that each module directly depends on the next module in the sequence (informally, if M1 depends on itself through some chain of module dependencies.)");
public static ErrorCode XQDY0101 = new W3CErrorCode("XQDY0101", "An error is raised if a computed namespace constructor attempts to do any of the following:\n" +
"Bind the prefix xml to some namespace URI other than http://www.w3.org/XML/1998/namespace.\n" +
"Bind a prefix other than xml to the namespace URI http://www.w3.org/XML/1998/namespace.\n" +
"Bind the prefix xmlns to any namespace URI.\n" +
"Bind a prefix to the namespace URI http://www.w3.org/2000/xmlns/.\n" +
"Bind any prefix (including the empty prefix) to a zero-length namespace URI.");

/* XQuery 1.0 and XPath 2.0 Functions and Operators http://www.w3.org/TR/xpath-functions/#error-summary */
public static ErrorCode FOER0000 = new W3CErrorCode("FOER0000", "Unidentified error.");
Expand Down
Loading

0 comments on commit 41c094d

Please sign in to comment.