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

Commit 571cfb4

Browse files
committed
Merge pull request #139 from jateeter/master
SFTP; Subscription/Usagepoint; sprint 4.0.6
2 parents 6632c98 + 2f3d9db commit 571cfb4

File tree

7 files changed

+87
-23
lines changed

7 files changed

+87
-23
lines changed

pom.xml

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -12,32 +12,29 @@
1212
<name>Common</name>
1313

1414
<profiles>
15+
16+
<!-- <profile> -->
17+
<!-- <id>dev</id> -->
18+
<!-- <activation> -->
19+
<!-- <activeByDefault>true</activeByDefault> -->
20+
<!-- </activation> -->
21+
<!-- <properties> -->
22+
<!-- <profile>dev</profile> -->
23+
<!-- <database>hsql</database> -->
24+
<!-- </properties> -->
25+
<!-- </profile> -->
26+
1527
<profile>
16-
<id>dev</id>
28+
<id>devmysql</id>
1729
<activation>
1830
<activeByDefault>true</activeByDefault>
1931
</activation>
20-
<properties>
21-
<profile>dev</profile>
22-
<database>hsql</database>
23-
</properties>
24-
</profile>
25-
<profile>
26-
<id>devmysql</id>
2732
<properties>
2833
<profile>devmysql</profile>
2934
<database>mysql</database>
3035
</properties>
3136
</profile>
3237

33-
<profile>
34-
<id>devmysql-regeneratedatabase</id>
35-
<properties>
36-
<profile>devmysql-regeneratedatabase</profile>
37-
<database>mysql</database>
38-
</properties>
39-
</profile>
40-
4138
<profile>
4239
<id>greenbuttondata</id>
4340
<properties>
@@ -50,7 +47,7 @@
5047

5148
<properties>
5249
<!-- Spring -->
53-
<spring.version>4.0.3.RELEASE</spring.version>
50+
<spring.version>4.0.6.RELEASE</spring.version>
5451
<spring.security.version>3.2.3.RELEASE</spring.security.version>
5552
<spring-security-oauth.version>2.0.2.RELEASE</spring-security-oauth.version>
5653

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/NotificationService.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import javax.xml.datatype.XMLGregorianCalendar;
44

5+
import org.energyos.espi.common.domain.ApplicationInformation;
56
import org.energyos.espi.common.domain.RetailCustomer;
67
import org.energyos.espi.common.domain.Subscription;
78
import org.springframework.stereotype.Service;
@@ -14,4 +15,6 @@ public interface NotificationService {
1415

1516
void notifyAllNeed();
1617

18+
void notify(ApplicationInformation applicationInformation, Long bulkId);
19+
1720
}

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")) {

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

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,12 @@
2121

2222
import javax.xml.datatype.XMLGregorianCalendar;
2323

24+
import org.energyos.espi.common.domain.ApplicationInformation;
2425
import org.energyos.espi.common.domain.Authorization;
2526
import org.energyos.espi.common.domain.BatchList;
2627
import org.energyos.espi.common.domain.RetailCustomer;
2728
import org.energyos.espi.common.domain.Subscription;
29+
import org.energyos.espi.common.service.ApplicationInformationService;
2830
import org.energyos.espi.common.service.AuthorizationService;
2931
import org.energyos.espi.common.service.NotificationService;
3032
import org.energyos.espi.common.service.ResourceService;
@@ -34,6 +36,10 @@
3436
import org.springframework.stereotype.Service;
3537
import org.springframework.web.client.RestTemplate;
3638

39+
/**
40+
* @author steph
41+
*
42+
*/
3743
@Service
3844
public class NotificationServiceImpl implements NotificationService {
3945
@Autowired
@@ -134,6 +140,18 @@ public void setRestTemplate(RestTemplate restTemplate) {
134140
this.restTemplate = restTemplate;
135141
}
136142

143+
144+
@Override
145+
public void notify(ApplicationInformation applicationInformation, Long bulkId) {
146+
String bulkRequestUri = applicationInformation.getDataCustodianBulkRequestURI() + "/" + bulkId;
147+
String thirdPartyNotificationURI = applicationInformation.getThirdPartyNotifyUri();
148+
BatchList batchList = new BatchList();
149+
batchList.getResources().add(bulkRequestUri);
150+
151+
notifyInternal(thirdPartyNotificationURI, batchList);
152+
153+
}
154+
137155
public RestTemplate getRestTemplate () {
138156
return this.restTemplate;
139157
}
@@ -144,6 +162,7 @@ public void setResourceService(ResourceService resourceService) {
144162
public ResourceService getResourceService () {
145163
return this.resourceService;
146164
}
165+
147166
public void setAuthorizationService(AuthorizationService authorizationService) {
148167
this.authorizationService = authorizationService;
149168
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,7 @@ public <T extends IdentifiedObject> void deleteByXPathId(Long id1,
308308

309309
}
310310

311+
@Transactional
311312
@Override
312313
public<T extends IdentifiedObject> T merge(IdentifiedObject resource) {
313314
return repository.merge(resource);

0 commit comments

Comments
 (0)