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

Commit bf55df3

Browse files
committed
XPath scoping to resource for collections and members ref:
#209
1 parent a44a2ac commit bf55df3

File tree

2 files changed

+22
-4
lines changed

2 files changed

+22
-4
lines changed

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

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import java.util.UUID;
2222

2323
import org.energyos.espi.common.domain.ElectricPowerQualitySummary;
24+
import org.energyos.espi.common.domain.ElectricPowerUsageSummary;
2425
import org.energyos.espi.common.domain.UsagePoint;
2526
import org.energyos.espi.common.models.atom.EntryType;
2627
import org.energyos.espi.common.repositories.ElectricPowerQualitySummaryRepository;
@@ -96,7 +97,14 @@ public EntryType findEntryType(Long retailCustomerId, Long usagePointId,
9697
try {
9798
// TODO - this is sub-optimal (but defers the need to understand creation of an EntryType
9899
List<Long> temp = new ArrayList<Long>();
99-
temp.add(electricPowerQualitySummaryId);
100+
temp = resourceService.findAllIdsByXPath(retailCustomerId, usagePointId, ElectricPowerUsageSummary.class);
101+
// temp.add(electricPowerQualitySummaryId);
102+
if (temp.contains(electricPowerQualitySummaryId)) {
103+
temp.clear();
104+
temp.add(electricPowerQualitySummaryId);
105+
} else {
106+
temp.clear();
107+
}
100108
result = (new EntryTypeIterator(resourceService, temp, ElectricPowerQualitySummary.class)).nextEntry(ElectricPowerQualitySummary.class);
101109
} catch (Exception e) {
102110
// TODO need a log file entry as we are going to return a null if
@@ -112,7 +120,9 @@ public EntryTypeIterator findEntryTypeIterator(Long retailCustomerId, Long usage
112120
try {
113121
// TODO - this is sub-optimal (but defers the need to understand creation of an EntryType
114122
List<Long> temp = new ArrayList<Long>();
115-
temp = resourceService.findAllIds(ElectricPowerQualitySummary.class);
123+
// temp = resourceService.findAllIds(ElectricPowerQualitySummary.class);
124+
temp = resourceService.findAllIdsByXPath(retailCustomerId, usagePointId, ElectricPowerQualitySummary.class);
125+
116126
result = (new EntryTypeIterator(resourceService, temp, ElectricPowerQualitySummary.class));
117127
} catch (Exception e) {
118128
// TODO need a log file entry as we are going to return a null if

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

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ public EntryTypeIterator findEntryTypeIterator(Long retailCustomerId, Long usage
9494
try {
9595
// TODO - this is sub-optimal (but defers the need to understan creation of an EntryType
9696
List<Long> temp = new ArrayList<Long>();
97-
temp = resourceService.findAllIds(ElectricPowerUsageSummary.class);
97+
temp = resourceService.findAllIdsByXPath(retailCustomerId, usagePointId, ElectricPowerUsageSummary.class);
9898
result = (new EntryTypeIterator(resourceService, temp, ElectricPowerUsageSummary.class));
9999
} catch (Exception e) {
100100
// TODO need a log file entry as we are going to return a null if
@@ -111,7 +111,15 @@ public EntryType findEntryType(Long retailCustomerId, Long usagePointId,
111111
try {
112112
// TODO - this is sub-optimal (but defers the need to understan creation of an EntryType
113113
List<Long> temp = new ArrayList<Long>();
114-
temp.add(electricPowerUsageSummaryId);
114+
temp = resourceService.findAllIdsByXPath(retailCustomerId, usagePointId, ElectricPowerUsageSummary.class);
115+
// temp.add(electricPowerUsageSummaryId);
116+
if (temp.contains(electricPowerUsageSummaryId)) {
117+
temp.clear();
118+
temp.add(electricPowerUsageSummaryId);
119+
} else {
120+
temp.clear();
121+
}
122+
115123
result = (new EntryTypeIterator(resourceService, temp, ElectricPowerUsageSummary.class)).nextEntry(ElectricPowerUsageSummary.class);
116124
} catch (Exception e) {
117125
// TODO need a log file entry as we are going to return a null if

0 commit comments

Comments
 (0)