Skip to content
This repository was archived by the owner on Jul 1, 2025. It is now read-only.

Commit 35f6155

Browse files
committed
Merge pull request #55 from jateeter/master
Fixed start-index=1 error (symptom was empty RESTful member get)
2 parents 3a1e800 + 7e216d4 commit 35f6155

5 files changed

Lines changed: 18 additions & 7 deletions

File tree

src/main/java/org/energyos/espi/common/domain/MeterReading.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@
7373
@NamedQuery(name = MeterReading.QUERY_FIND_ALL_IDS,
7474
query = "SELECT meterReading.id FROM MeterReading meterReading"),
7575
@NamedQuery(name = MeterReading.QUERY_FIND_ALL_IDS_BY_XPATH_2, query = "SELECT DISTINCT m.id FROM UsagePoint u, MeterReading m WHERE u.retailCustomer.id = :o1Id AND m.usagePoint.id = :o2Id"),
76-
@NamedQuery(name = MeterReading.QUERY_FIND_ID_BY_XPATH, query = "SELECT DISTINCT m.id FROM UsagePoint u, MeterReading m WHERE u.retailCustomer.id = :o1ID AND m.usagePoint.id = :o2Id AND m.id = :o3Id")
76+
@NamedQuery(name = MeterReading.QUERY_FIND_ID_BY_XPATH, query = "SELECT DISTINCT m.id FROM UsagePoint u, MeterReading m WHERE u.retailCustomer.id = :o1Id AND m.usagePoint.id = :o2Id AND m.id = :o3Id")
7777

7878
})
7979
public class MeterReading extends IdentifiedObject

src/main/java/org/energyos/espi/common/domain/ReadingType.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,9 @@
104104
@NamedQuery(name = ReadingType.QUERY_FIND_ALL_IDS_BY_USAGE_POINT_ID,
105105
query = "SELECT meterReading.readingType.id FROM MeterReading meterReading WHERE meterReading.usagePoint.id = :usagePointId"),
106106
@NamedQuery(name = ReadingType.QUERY_FIND_ALL_IDS,
107-
query = "SELECT readingType.id FROM ReadingType readingType")
107+
query = "SELECT readingType.id FROM ReadingType readingType"),
108+
@NamedQuery(name = ReadingType.QUERY_FIND_ALL_IDS_BY_XPATH_0, query = "SELECT DISTINCT r.id FROM ReadingType r"),
109+
@NamedQuery(name = ReadingType.QUERY_FIND_ID_BY_XPATH, query = "SELECT DISTINCT r.id FROM ReadingType r WHERE r.id = :o1Id")
108110

109111
})
110112
public class ReadingType
@@ -115,6 +117,8 @@ public class ReadingType
115117
public static final String QUERY_FIND_BY_UUID = "ReadingType.findByUUID";
116118
public static final String QUERY_FIND_ALL_IDS_BY_USAGE_POINT_ID = "ReadingType.findAllIdsByUsagePointId";
117119
public static final String QUERY_FIND_ALL_IDS = "ReadingType.findAllIds";
120+
public static final String QUERY_FIND_ALL_IDS_BY_XPATH_0 = "ReadingType.findAllIdsByXpath0";
121+
public static final String QUERY_FIND_ID_BY_XPATH = "ReadingType.findIdsByXpath";
118122

119123
@XmlTransient
120124
@OneToOne(cascade = CascadeType.PERSIST, fetch = FetchType.EAGER)

src/main/java/org/energyos/espi/common/domain/TimeConfiguration.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,9 @@
7373
@NamedQuery(name = TimeConfiguration.QUERY_FIND_ALL_IDS_BY_USAGE_POINT_ID,
7474
query = "SELECT usagePoint.localTimeParameters.id FROM UsagePoint usagePoint WHERE usagePoint.id = :usagePointId"),
7575
@NamedQuery(name = TimeConfiguration.QUERY_FIND_ALL_IDS,
76-
query = "SELECT timeConfiguration.id FROM TimeConfiguration timeConfiguration")
76+
query = "SELECT timeConfiguration.id FROM TimeConfiguration timeConfiguration"),
77+
@NamedQuery(name = TimeConfiguration.QUERY_FIND_ALL_IDS_BY_XPATH_0, query = "SELECT DISTINCT t.id FROM TimeConfiguration t"),
78+
@NamedQuery(name = TimeConfiguration.QUERY_FIND_ID_BY_XPATH, query = "SELECT DISTINCT t.id FROM TimeConfiguration t WHERE t.id = :o1Id")
7779

7880
})
7981
public class TimeConfiguration extends IdentifiedObject {
@@ -82,7 +84,9 @@ public class TimeConfiguration extends IdentifiedObject {
8284
public static final String QUERY_FIND_ALL_IDS = "TimeConfiguration.findAllIds";
8385
public static final String QUERY_FIND_BY_UUID = "TimeConfiguration.findByUUID";
8486
public static final String QUERY_FIND_ALL_IDS_BY_USAGE_POINT_ID = "TimeConfiguration.findAllIdsByUsagePointId";
85-
87+
public static final String QUERY_FIND_ALL_IDS_BY_XPATH_0 = "TimeConfiguration.findAllIdsByXpath0";
88+
public static final String QUERY_FIND_ID_BY_XPATH = "TimeConfiguration.findIdsByXpath";
89+
8690
@XmlElement(required = true, type = String.class)
8791
@XmlJavaTypeAdapter(HexBinaryAdapter.class)
8892
protected byte[] dstEndRule;

src/main/java/org/energyos/espi/common/service/impl/ExportServiceImpl.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -524,6 +524,7 @@ private void buildHeader (OutputStream stream, String hrefFragment) throws IOExc
524524
String uuid = UUID.randomUUID().toString();
525525

526526
stream.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n".getBytes());
527+
stream.write("<?xml-stylesheet type=\"text/xsl\" href=\"/GreenButtonDataStyleSheet.xslt\"?>".getBytes());
527528
stream.write("<feed xmlns=\"http://www.w3.org/2005/Atom\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">\n".getBytes());
528529
stream.write("<id>urn:uuid:".getBytes());
529530
stream.write(uuid.getBytes());

src/main/java/org/energyos/espi/common/utils/ExportFilter.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
package org.energyos.espi.common.utils;
22

33
import com.sun.org.apache.xerces.internal.jaxp.datatype.XMLGregorianCalendarImpl;
4+
45
import org.energyos.espi.common.models.atom.DateTimeType;
56
import org.energyos.espi.common.models.atom.EntryType;
67

78
import java.util.Map;
89

10+
@SuppressWarnings("restriction")
911
public class ExportFilter {
1012
private Map<String, String> params;
1113
private int matchedCounter = 0, emittedCounter = 0;
@@ -55,8 +57,7 @@ public boolean matches(EntryType entry) {
5557
}
5658

5759
if (hasParam("start-index")) {
58-
if (matchedCounter < Integer.valueOf(params.get("start-index"))) {
59-
matchedCounter++;
60+
if (++matchedCounter < Integer.valueOf(params.get("start-index"))) {
6061
return false;
6162

6263
}
@@ -77,7 +78,8 @@ private boolean hasParam(String paramName) {
7778
return params.get(paramName) != null;
7879
}
7980

80-
private long toTime(String key) {
81+
@SuppressWarnings("restriction")
82+
private long toTime(String key) {
8183
String param = params.get(key);
8284

8385
return XMLGregorianCalendarImpl.parse(param).toGregorianCalendar().getTimeInMillis();

0 commit comments

Comments
 (0)