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

Commit 6d8571a

Browse files
committed
added /Subscription/{subscriptionId/UsagePoint and /{usagePointId}
1 parent 6eec323 commit 6d8571a

File tree

3 files changed

+50
-6
lines changed

3 files changed

+50
-6
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,8 @@ public class Routes {
124124
public static final String BATCH_UPLOAD_MY_DATA = "/espi/1_1/resource/Batch/RetailCustomer/{retailCustomerId}/UsagePoint";
125125
public static final String BATCH_BULK_MEMBER = "/espi/1_1/resource/Batch/Bulk/{bulkId}";
126126
public static final String BATCH_SUBSCRIPTION = "/espi/1_1/resource/Batch/Subscription/{subscriptionId}";
127+
public static final String BATCH_SUBSCRIPTION_USAGEPOINT = "/espi/1_1/resource/Batch/Subscription/{subscriptionId}/UsagePoint";
128+
public static final String BATCH_SUBSCRIPTION_USAGEPOINT_MEMBER = "/espi/1_1/resource/Batch/Subscription/{subscriptionId}/UsagePoint/{usagePointId}";
127129

128130
public static String buildDataCustodianRESTUsagePointCollection(String retailCustomerHashedId) {
129131
return DATA_CUSTODIAN_REST_USAGE_POINT_COLLECTION.replace("{retailCustomerId}", retailCustomerHashedId);

src/main/java/org/energyos/espi/common/service/ExportService.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -405,4 +405,21 @@ void exportUsagePointFull(Long subscriptionId, Long usagePointId, Long RetailCus
405405
*/
406406
public void exportBatchSubscription(Long subscriptionId, OutputStream outputStream, ExportFilter exportFilter) throws IOException;
407407

408+
/**
409+
* @param subscriptionId
410+
* @param outputStream
411+
* @param exportFilter
412+
* @throws IOException
413+
*/
414+
public void exportBatchSubscriptionUsagePoint(Long subscriptionId, OutputStream outputStream, ExportFilter exportFilter) throws IOException;
415+
416+
/**
417+
* @param subscriptionId
418+
* @param usagePointId
419+
* @param outputStream
420+
* @param exportFilter
421+
* @throws IOException
422+
*/
423+
public void exportBatchSubscriptionUsagePoint(Long subscriptionId, Long usagePointId, OutputStream outputStream, ExportFilter exportFilter) throws IOException;
424+
408425
}

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

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -674,6 +674,33 @@ public void exportBatchSubscription(Long subscriptionId,
674674
usagePointIdList, UsagePoint.class), stream, exportFilter,
675675
hrefFragment);
676676
}
677+
678+
@Override
679+
public void exportBatchSubscriptionUsagePoint(Long subscriptionId,
680+
OutputStream stream, ExportFilter exportFilter) throws IOException {
681+
String hrefFragment = "/Batch/Subscription/" + subscriptionId + "/UsagePoint";
682+
// first find all the usagePointIds this subscription is related to
683+
List<Long> usagePointIdList = subscriptionService
684+
.findUsagePointIds(subscriptionId);
685+
exportEntriesFull(subscriptionId, resourceService.findEntryTypeIterator(
686+
usagePointIdList, UsagePoint.class), stream, exportFilter,
687+
hrefFragment);
688+
}
689+
690+
@Override
691+
public void exportBatchSubscriptionUsagePoint(Long subscriptionId, Long usagePointId,
692+
OutputStream stream, ExportFilter exportFilter) throws IOException {
693+
String hrefFragment = "/Batch/Subscription/" + subscriptionId + "/UsagePoint/" + usagePointId;
694+
List<Long> usagePointIdList = new ArrayList<Long> ();
695+
List<Long> temp = subscriptionService
696+
.findUsagePointIds(subscriptionId);
697+
if (temp.contains(usagePointId)) {
698+
usagePointIdList.add(usagePointId);
699+
}
700+
exportEntriesFull(subscriptionId, resourceService.findEntryTypeIterator(
701+
usagePointIdList, UsagePoint.class), stream, exportFilter,
702+
hrefFragment);
703+
}
677704

678705
@Override
679706
public void exportBatchBulk(Long bulkId, String thirdParty, OutputStream outputStream,
@@ -757,8 +784,7 @@ private void exportEntries(EntryTypeIterator entries, OutputStream stream,
757784
}
758785

759786
@SuppressWarnings({ "rawtypes", "unchecked" })
760-
// TODO: this needs to be templated and RetailCustomer inherited from
761-
// IdentifiedObject to remove the above supress warnings
787+
762788
private void exportEntries(Long subscriptionId, EntryTypeIterator entries, OutputStream stream,
763789
ExportFilter exportFilter, Class resourceClass, String hrefFragment)
764790
throws IOException {
@@ -884,18 +910,17 @@ private void exportEntries_Root(Long subscriptionId, EntryTypeIterator entries,
884910

885911

886912
private String adjustFragment(String fragment, EntryType entry) {
887-
// TODO there may be other setup things - Likely BatchList
888-
// if that still exists.
913+
889914
String result = fragment;
890915
if (fragment.contains("DownloadMyData")) {
891916
result.replace("DownloadMyData", "UsagePoint");
892917
}
893918
if (fragment.contains("Batch")) {
894919
if (fragment.contains("Bulk")) {
895-
// ToDo need the proper URI fragment for a Bulk
920+
896921
UsagePoint up = entry.getContent().getUsagePoint();
897922
RetailCustomer rc = up.getRetailCustomer();
898-
// TODO here need the proper URI fragment for a subscription
923+
899924
result = "/RetailCustomer/" + rc.getId() + "/UsagePoint";
900925
}
901926
// if (fragment.contains("Subscription")) {

0 commit comments

Comments
 (0)