Started implementing rhythm spi.
diff --git a/api/src/main/java/io/mifos/portfolio/api/v1/PermittableGroupIds.java b/api/src/main/java/io/mifos/portfolio/api/v1/PermittableGroupIds.java
index 15629c3..85dab16 100644
--- a/api/src/main/java/io/mifos/portfolio/api/v1/PermittableGroupIds.java
+++ b/api/src/main/java/io/mifos/portfolio/api/v1/PermittableGroupIds.java
@@ -18,6 +18,7 @@
/**
* @author Myrle Krantz
*/
+@SuppressWarnings("unused")
public interface PermittableGroupIds {
String PRODUCT_OPERATIONS_MANAGEMENT = "portfolio__v1__products__enable";
String PRODUCT_MANAGEMENT = "portfolio__v1__products";
diff --git a/api/src/main/java/io/mifos/portfolio/api/v1/events/EventConstants.java b/api/src/main/java/io/mifos/portfolio/api/v1/events/EventConstants.java
index 6fc00f0..cb687ae 100644
--- a/api/src/main/java/io/mifos/portfolio/api/v1/events/EventConstants.java
+++ b/api/src/main/java/io/mifos/portfolio/api/v1/events/EventConstants.java
@@ -15,6 +15,10 @@
*/
package io.mifos.portfolio.api.v1.events;
+/**
+ * @author Myrle Krantz
+ */
+@SuppressWarnings("unused")
public interface EventConstants {
String DESTINATION = "portfolio-v1";
String SELECTOR_NAME = "action";
diff --git a/api/src/test/java/io/mifos/portfolio/api/v1/domain/InterestRangeTest.java b/api/src/test/java/io/mifos/portfolio/api/v1/domain/InterestRangeTest.java
index db1b3bc..666aeac 100644
--- a/api/src/test/java/io/mifos/portfolio/api/v1/domain/InterestRangeTest.java
+++ b/api/src/test/java/io/mifos/portfolio/api/v1/domain/InterestRangeTest.java
@@ -1,3 +1,18 @@
+/*
+ * Copyright 2017 The Mifos Initiative.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package io.mifos.portfolio.api.v1.domain;
import io.mifos.core.test.domain.ValidationTest;
@@ -9,8 +24,6 @@
import java.util.ArrayList;
import java.util.Collection;
-import static org.junit.Assert.*;
-
/**
* @author Myrle Krantz
*/
diff --git a/service/build.gradle b/service/build.gradle
index 6bce911..e5a945a 100644
--- a/service/build.gradle
+++ b/service/build.gradle
@@ -32,6 +32,7 @@
[group: 'org.springframework.cloud', name: 'spring-cloud-spring-service-connector'],
[group: 'org.springframework.boot', name: 'spring-boot-starter-jetty'],
[group: 'io.mifos.portfolio', name: 'api', version: project.version],
+ [group: 'io.mifos.rhythm', name: 'spi', version: versions.mifosrhythm],
[group: 'io.mifos.accounting', name: 'api', version: versions.frameworkaccounting],
[group: 'io.mifos.anubis', name: 'library', version: versions.frameworkanubis],
[group: 'com.google.code.gson', name: 'gson'],
diff --git a/service/src/main/java/io/mifos/portfolio/service/internal/command/CreateBeatPublishCommand.java b/service/src/main/java/io/mifos/portfolio/service/internal/command/CreateBeatPublishCommand.java
new file mode 100644
index 0000000..c64eeb7
--- /dev/null
+++ b/service/src/main/java/io/mifos/portfolio/service/internal/command/CreateBeatPublishCommand.java
@@ -0,0 +1,33 @@
+/*
+ * Copyright 2017 The Mifos Initiative.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package io.mifos.portfolio.service.internal.command;
+
+import io.mifos.rhythm.spi.v1.domain.BeatPublish;
+
+/**
+ * @author Myrle Krantz
+ */
+public class CreateBeatPublishCommand {
+ private final BeatPublish instance;
+
+ public CreateBeatPublishCommand(final BeatPublish instance) {
+ this.instance = instance;
+ }
+
+ public BeatPublish getInstance() {
+ return instance;
+ }
+}
diff --git a/service/src/main/java/io/mifos/portfolio/service/internal/command/handler/BeatPublishCommandHandler.java b/service/src/main/java/io/mifos/portfolio/service/internal/command/handler/BeatPublishCommandHandler.java
new file mode 100644
index 0000000..b4047f1
--- /dev/null
+++ b/service/src/main/java/io/mifos/portfolio/service/internal/command/handler/BeatPublishCommandHandler.java
@@ -0,0 +1,35 @@
+package io.mifos.portfolio.service.internal.command.handler;
+
+import io.mifos.core.command.annotation.Aggregate;
+import io.mifos.core.command.annotation.CommandHandler;
+import io.mifos.core.command.annotation.EventEmitter;
+import io.mifos.core.lang.ApplicationName;
+import io.mifos.rhythm.spi.v1.domain.BeatPublish;
+import io.mifos.rhythm.spi.v1.events.BeatPublishEvent;
+import io.mifos.rhythm.spi.v1.events.EventConstants;
+import io.mifos.portfolio.service.internal.command.CreateBeatPublishCommand;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.transaction.annotation.Transactional;
+
+/**
+ * @author Myrle Krantz
+ */
+@SuppressWarnings("unused")
+@Aggregate
+public class BeatPublishCommandHandler {
+
+ private final ApplicationName applicationName;
+
+ @Autowired
+ public BeatPublishCommandHandler(final ApplicationName applicationName) {
+ this.applicationName = applicationName;
+ }
+
+ @Transactional
+ @CommandHandler
+ @EventEmitter(selectorName = EventConstants.SELECTOR_NAME, selectorValue = EventConstants.POST_PUBLISHEDBEAT)
+ public BeatPublishEvent process(final CreateBeatPublishCommand createBeatPublishCommand) {
+ final BeatPublish instance = createBeatPublishCommand.getInstance();
+ return new BeatPublishEvent(applicationName.toString(), instance.getIdentifier(), instance.getForTime());
+ }
+}
diff --git a/service/src/main/java/io/mifos/portfolio/service/rest/BeatPublishListenerRestController.java b/service/src/main/java/io/mifos/portfolio/service/rest/BeatPublishListenerRestController.java
new file mode 100644
index 0000000..ef7bda8
--- /dev/null
+++ b/service/src/main/java/io/mifos/portfolio/service/rest/BeatPublishListenerRestController.java
@@ -0,0 +1,60 @@
+/*
+ * Copyright 2017 The Mifos Initiative.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package io.mifos.portfolio.service.rest;
+
+import io.mifos.anubis.annotation.AcceptedTokenType;
+import io.mifos.anubis.annotation.Permittable;
+import io.mifos.core.command.gateway.CommandGateway;
+import io.mifos.portfolio.service.internal.command.CreateBeatPublishCommand;
+import io.mifos.rhythm.spi.v1.client.BeatListener;
+import io.mifos.rhythm.spi.v1.domain.BeatPublish;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.MediaType;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.*;
+
+import javax.validation.Valid;
+
+/**
+ * @author Myrle Krantz
+ */
+@SuppressWarnings("unused")
+@RestController
+@RequestMapping(BeatListener.PUBLISH_BEAT_PATH) //
+public class BeatPublishListenerRestController {
+ private final static String BEAT_PUBLISH = "portfolio__v1__khepri"; //PermittableGroupIds.forApplication("portfolio-v1");
+
+ private final CommandGateway commandGateway;
+
+ @Autowired
+ public BeatPublishListenerRestController(final CommandGateway commandGateway) {
+ this.commandGateway = commandGateway;
+ }
+
+ @Permittable(value = AcceptedTokenType.TENANT, groupId = BEAT_PUBLISH)
+ @RequestMapping(
+ method = RequestMethod.POST,
+ consumes = MediaType.APPLICATION_JSON_VALUE,
+ produces = MediaType.APPLICATION_JSON_VALUE
+ )
+ public @ResponseBody
+ ResponseEntity<Void> publishBeat(@RequestBody @Valid final BeatPublish instance)
+ {
+ this.commandGateway.process(new CreateBeatPublishCommand(instance));
+ return new ResponseEntity<>(HttpStatus.ACCEPTED);
+ }
+}
diff --git a/shared.gradle b/shared.gradle
index 946b9b9..2a91771 100644
--- a/shared.gradle
+++ b/shared.gradle
@@ -11,6 +11,7 @@
frameworktest : '0.1.0-BUILD-SNAPSHOT',
frameworkasync : '0.1.0-BUILD-SNAPSHOT',
frameworkaccounting : '0.1.0-BUILD-SNAPSHOT',
+ mifosrhythm : '0.1.0-BUILD-SNAPSHOT',
validator : '5.3.0.Final',
javamoneylib : '0.9-SNAPSHOT'
]