Updated Notes in API doc
This commit is contained in:
+241
-168
@@ -187,23 +187,6 @@
|
|||||||
<td></td>
|
<td></td>
|
||||||
<td></td>
|
<td></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
|
||||||
<td></td>
|
|
||||||
<td>clients/{clientId}/notes</td>
|
|
||||||
<td><a href="#clients_addnote">Add a Client Note</a></td>
|
|
||||||
<td><a href="#clients_notes">Retrieve a Client's Notes</a></td>
|
|
||||||
<td></td>
|
|
||||||
<td></td>
|
|
||||||
</tr>
|
|
||||||
<tr class="alt">
|
|
||||||
<td></td>
|
|
||||||
<td>clients/{clientId}/notes/{noteId}</td>
|
|
||||||
<td></td>
|
|
||||||
<td><a href="#clients_retrievenote">Retrieve a Client
|
|
||||||
Note</a></td>
|
|
||||||
<td><a href="#clients_updatenote">Update a Client Note</a></td>
|
|
||||||
<td></td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -803,6 +786,22 @@
|
|||||||
<td><a href="#datatables_delete_1M">Delete Entry in
|
<td><a href="#datatables_delete_1M">Delete Entry in
|
||||||
Data Table (One to Many)</a></td>
|
Data Table (One to Many)</a></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><a href="#notes">NOTE</a></td>
|
||||||
|
<td>{resource}/{resourceId}/notes</td>
|
||||||
|
<td><a href="#resources_addnote">Add a Resource Note</td>
|
||||||
|
<td><a href="#resource_notelist">Retrieve a Resource's Notes</a></td>
|
||||||
|
<td></td>
|
||||||
|
<td></td>
|
||||||
|
</tr>
|
||||||
|
<tr class="alt">
|
||||||
|
<td></td>
|
||||||
|
<td>{resource}/{resourceId}/notes/{noteId}</td>
|
||||||
|
<td></td>
|
||||||
|
<td><a href="#resources_retrievenote">Retrieve a Resource Note</a></td>
|
||||||
|
<td><a href="#resources_updatenote">Update a Resource Note</a></td>
|
||||||
|
<td><a href="#resources_deletenote">Delete a Resource Note</a></td>
|
||||||
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -1266,6 +1265,8 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="main-content-wrapper">
|
<div id="main-content-wrapper">
|
||||||
@@ -2015,140 +2016,6 @@ GET https://DomainName/api/v1/clients/{clientId}/loans
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<a id="clients_notes" name="clients_notes" class="old-syle-anchor"> </a>
|
|
||||||
<div class="method-section">
|
|
||||||
<div class="method-description">
|
|
||||||
<h4>Retrieve a Client's Notes</h4>
|
|
||||||
<p>
|
|
||||||
<b>Note:</b> Notes are returned in descending createOn order.
|
|
||||||
</p>
|
|
||||||
<p>Example Requests:</p>
|
|
||||||
<div class=apiClick>clients/2/notes</div>
|
|
||||||
<br>
|
|
||||||
<br>
|
|
||||||
<div class=apiClick>clients/2/notes?fields=note,createdOn,createdByUsername</div>
|
|
||||||
</div>
|
|
||||||
<div class="method-example">
|
|
||||||
<code class="method-declaration">
|
|
||||||
GET https://DomainName/api/v1/clients/{clientId}/notes
|
|
||||||
</code>
|
|
||||||
<code class="method-response">
|
|
||||||
[
|
|
||||||
{
|
|
||||||
"id": 2,
|
|
||||||
"clientId": 1,
|
|
||||||
"noteType": {
|
|
||||||
"id": 100,
|
|
||||||
"code": "noteType.client",
|
|
||||||
"value": "Client note"
|
|
||||||
},
|
|
||||||
"note": "First note edited",
|
|
||||||
"createdById": 1,
|
|
||||||
"createdByUsername": "mifos",
|
|
||||||
"createdOn": 1342498505000,
|
|
||||||
"updatedById": 1,
|
|
||||||
"updatedByUsername": "mifos",
|
|
||||||
"updatedOn": 1342498517000
|
|
||||||
}
|
|
||||||
]
|
|
||||||
</code>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<a id="clients_addnote" name="clients_addnote"
|
|
||||||
class="old-syle-anchor"> </a>
|
|
||||||
<div class="method-section">
|
|
||||||
<div class="method-description">
|
|
||||||
<h4>Add a Client Note</h4>
|
|
||||||
</div>
|
|
||||||
<div class="method-example">
|
|
||||||
<code class="method-declaration">
|
|
||||||
POST https://DomainName/api/v1/clients/{clientId}/notes
|
|
||||||
</code>
|
|
||||||
<code class="method-request">
|
|
||||||
POST clients/1/notes
|
|
||||||
Content-Type: application/json
|
|
||||||
Request Body:
|
|
||||||
{
|
|
||||||
"note": "a note about the client"
|
|
||||||
}
|
|
||||||
</code>
|
|
||||||
<code class="method-response">
|
|
||||||
{
|
|
||||||
"officeId": 1,
|
|
||||||
"clientId": 1,
|
|
||||||
"resourceId": 76
|
|
||||||
}
|
|
||||||
</code>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<a id="clients_retrievenote" name="clients_retrievenote"
|
|
||||||
class="old-syle-anchor"> </a>
|
|
||||||
<div class="method-section">
|
|
||||||
<div class="method-description">
|
|
||||||
<h4>Retrieve a Client Note</h4>
|
|
||||||
<p>Example Requests:</p>
|
|
||||||
<div class=apiClick>clients/1/notes/76</div>
|
|
||||||
<br>
|
|
||||||
<br>
|
|
||||||
<div class=apiClick>clients/1/notes/76?fields=note,createdOn,createdByUsername</div>
|
|
||||||
</div>
|
|
||||||
<div class="method-example">
|
|
||||||
<code class="method-declaration">
|
|
||||||
GET https://DomainName/api/v1/clients/{clientId}/notes/{noteId}
|
|
||||||
</code>
|
|
||||||
<code class="method-response">
|
|
||||||
{
|
|
||||||
"id": 76,
|
|
||||||
"clientId": 1,
|
|
||||||
"noteType": {
|
|
||||||
"id": 100,
|
|
||||||
"code": "noteType.client",
|
|
||||||
"value": "Client note"
|
|
||||||
},
|
|
||||||
"note": "a note about the client",
|
|
||||||
"createdById": 1,
|
|
||||||
"createdByUsername": "mifos",
|
|
||||||
"createdOn": 1359463135000,
|
|
||||||
"updatedById": 1,
|
|
||||||
"updatedByUsername": "mifos",
|
|
||||||
"updatedOn": 1359463135000
|
|
||||||
}
|
|
||||||
</code>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<a id="clients_updatenote" name="clients_updatenote"
|
|
||||||
class="old-syle-anchor"> </a>
|
|
||||||
<div class="method-section">
|
|
||||||
<div class="method-description">
|
|
||||||
<h4>Update a Client Note</h4>
|
|
||||||
</div>
|
|
||||||
<div class="method-example">
|
|
||||||
<code class="method-declaration">
|
|
||||||
PUT https://DomainName/api/v1/clients/{clientId}/notes/{noteId}
|
|
||||||
</code>
|
|
||||||
<code class="method-request">
|
|
||||||
PUT clients/1/notes/76
|
|
||||||
Content-Type: application/json
|
|
||||||
Request Body:
|
|
||||||
{
|
|
||||||
"note": "and here the note is updated nicely." }
|
|
||||||
</code>
|
|
||||||
<code class="method-response">
|
|
||||||
{
|
|
||||||
"officeId": 1,
|
|
||||||
"clientId": 1,
|
|
||||||
"resourceId": 76,
|
|
||||||
"changes": {
|
|
||||||
"note": "and here the note is updated nicely."
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</code>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- start of Groups api docs -->
|
<!-- start of Groups api docs -->
|
||||||
<a id="groups" name="groups" class="old-syle-anchor"> </a>
|
<a id="groups" name="groups" class="old-syle-anchor"> </a>
|
||||||
<div class="method-section">
|
<div class="method-section">
|
||||||
@@ -2449,7 +2316,7 @@ DELETE groups/7
|
|||||||
</code>
|
</code>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<!-- group end anchor grpxxxx -->
|
<!-- end of group api docs -->
|
||||||
|
|
||||||
<!-- start of loans api docs -->
|
<!-- start of loans api docs -->
|
||||||
<a id="loans" name="loans" class="old-syle-anchor"> </a>
|
<a id="loans" name="loans" class="old-syle-anchor"> </a>
|
||||||
@@ -8297,7 +8164,229 @@ Request Body:
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!-- start of datatables api docs -->
|
||||||
|
|
||||||
|
<!-- start of Notes api docs -->
|
||||||
|
<a id="notes" name="notes" class="old-syle-anchor"> </a>
|
||||||
|
<div class="method-section">
|
||||||
|
<div class="method-description">
|
||||||
|
<h3>Notes</h3>
|
||||||
|
<p>Notes API allows to enter notes for supported resources.</p>
|
||||||
|
|
||||||
|
<table class=matrixHeading>
|
||||||
|
<tr class="matrixHeadingBG">
|
||||||
|
<td><div class="mifosXHeading2">Field Descriptions</div></td>
|
||||||
|
</tr>
|
||||||
|
<tr class=alt>
|
||||||
|
<td>note</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class=fielddesc>A simple text note created for supported resources.</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
<br>
|
||||||
|
<br>
|
||||||
|
<table class=matrixHeading>
|
||||||
|
<tr class="matrixHeadingBG">
|
||||||
|
<td><div class="mifosXHeading2">Supported Resources</div></td>
|
||||||
|
</tr>
|
||||||
|
<tr class=alt>
|
||||||
|
<td>
|
||||||
|
<a href="#clients">Client</a>
|
||||||
|
<br>
|
||||||
|
<a href="#loans">Loan</a>
|
||||||
|
<br>
|
||||||
|
<a href="#groups">Group</a>
|
||||||
|
<br>
|
||||||
|
<a href="#fixeddeposits">Deposit Account</a>
|
||||||
|
<br>
|
||||||
|
<a href="#savingaccounts">Saving Account</a>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<a id="resources_addnote" name="resources_addnote"
|
||||||
|
class="old-syle-anchor"> </a>
|
||||||
|
<div class="method-section">
|
||||||
|
<div class="method-description">
|
||||||
|
<h4>Add a Resource Note</h4>
|
||||||
|
<p>Adds a new note to a supported resource.</p>
|
||||||
|
<table class=matrixHeading>
|
||||||
|
<tr class="matrixHeadingBG">
|
||||||
|
<td><div class="mifosXHeading2">Mandatory Fields</div></td>
|
||||||
|
</tr>
|
||||||
|
<tr class=alt>
|
||||||
|
<td>note</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
<p>Example Requests:</p>
|
||||||
|
<div class=apiClick>clients/1/notes</div>
|
||||||
|
<br>
|
||||||
|
<br>
|
||||||
|
<div class=apiClick>groups/1/notes</div>
|
||||||
|
</div>
|
||||||
|
<div class="method-example">
|
||||||
|
<code class="method-declaration">
|
||||||
|
POST https://DomainName/api/v1/{resource}/{resourceId}/notes
|
||||||
|
</code>
|
||||||
|
<code class="method-request">
|
||||||
|
POST clients/1/notes
|
||||||
|
Content-Type: application/json
|
||||||
|
Request Body:
|
||||||
|
{
|
||||||
|
"note": "a note about the client"
|
||||||
|
}
|
||||||
|
</code>
|
||||||
|
<code class="method-response">
|
||||||
|
{
|
||||||
|
"officeId": 1,
|
||||||
|
"clientId": 1,
|
||||||
|
"resourceId": 76
|
||||||
|
}
|
||||||
|
</code>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<a id="resource_notelist" name="resource_notelist"
|
||||||
|
class="old-syle-anchor"> </a>
|
||||||
|
<div class="method-section">
|
||||||
|
<div class="method-description">
|
||||||
|
<h4>Retrieve a Resource's Notes</h4>
|
||||||
|
<p>
|
||||||
|
<b>Note:</b> Notes are returned in descending createOn order.
|
||||||
|
</p>
|
||||||
|
<p>Example Requests:</p>
|
||||||
|
<div class=apiClick>clients/2/notes</div>
|
||||||
|
<br>
|
||||||
|
<br>
|
||||||
|
<div class=apiClick>groups/2/notes?fields=note,createdOn,createdByUsername</div>
|
||||||
|
</div>
|
||||||
|
<div class="method-example">
|
||||||
|
<code class="method-declaration">
|
||||||
|
GET https://DomainName/api/v1/{resource}/{resourceId}/notes
|
||||||
|
</code>
|
||||||
|
<code class="method-response">
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"id": 2,
|
||||||
|
"clientId": 1,
|
||||||
|
"noteType": {
|
||||||
|
"id": 100,
|
||||||
|
"code": "noteType.client",
|
||||||
|
"value": "Client note"
|
||||||
|
},
|
||||||
|
"note": "First note edited",
|
||||||
|
"createdById": 1,
|
||||||
|
"createdByUsername": "mifos",
|
||||||
|
"createdOn": 1342498505000,
|
||||||
|
"updatedById": 1,
|
||||||
|
"updatedByUsername": "mifos",
|
||||||
|
"updatedOn": 1342498517000
|
||||||
|
}
|
||||||
|
]
|
||||||
|
</code>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<a id="resources_retrievenote" name="resources_retrievenote"
|
||||||
|
class="old-syle-anchor"> </a>
|
||||||
|
<div class="method-section">
|
||||||
|
<div class="method-description">
|
||||||
|
<h4>Retrieve a Resource Note</h4>
|
||||||
|
<p>Example Requests:</p>
|
||||||
|
<div class=apiClick>clients/1/notes/76</div>
|
||||||
|
<br>
|
||||||
|
<br>
|
||||||
|
<div class=apiClick>groups/1/notes/20</div>
|
||||||
|
<br>
|
||||||
|
<br>
|
||||||
|
<div class=apiClick>clients/1/notes/76?fields=note,createdOn,createdByUsername</div>
|
||||||
|
<br>
|
||||||
|
<br>
|
||||||
|
<div class=apiClick>groups/1/notes/20?fields=note,createdOn,createdByUsername</div>
|
||||||
|
</div>
|
||||||
|
<div class="method-example">
|
||||||
|
<code class="method-declaration">
|
||||||
|
GET https://DomainName/api/v1/{resource}/{resourceId}/notes/{noteId}
|
||||||
|
</code>
|
||||||
|
<code class="method-response">
|
||||||
|
{
|
||||||
|
"id": 76,
|
||||||
|
"clientId": 1,
|
||||||
|
"noteType": {
|
||||||
|
"id": 100,
|
||||||
|
"code": "noteType.client",
|
||||||
|
"value": "Client note"
|
||||||
|
},
|
||||||
|
"note": "a note about the client",
|
||||||
|
"createdById": 1,
|
||||||
|
"createdByUsername": "mifos",
|
||||||
|
"createdOn": 1359463135000,
|
||||||
|
"updatedById": 1,
|
||||||
|
"updatedByUsername": "mifos",
|
||||||
|
"updatedOn": 1359463135000
|
||||||
|
}
|
||||||
|
</code>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<a id="resources_updatenote" name="resources_updatenote"
|
||||||
|
class="old-syle-anchor"> </a>
|
||||||
|
<div class="method-section">
|
||||||
|
<div class="method-description">
|
||||||
|
<h4>Update a Resource Note</h4>
|
||||||
|
</div>
|
||||||
|
<div class="method-example">
|
||||||
|
<code class="method-declaration">
|
||||||
|
PUT https://DomainName/api/v1/{resource}/{resourceId}/notes/{noteId}
|
||||||
|
</code>
|
||||||
|
<code class="method-request">
|
||||||
|
PUT clients/1/notes/76
|
||||||
|
Content-Type: application/json
|
||||||
|
Request Body:
|
||||||
|
{
|
||||||
|
"note": "and here the note is updated nicely."
|
||||||
|
}
|
||||||
|
</code>
|
||||||
|
<code class="method-response">
|
||||||
|
{
|
||||||
|
"officeId": 1,
|
||||||
|
"clientId": 1,
|
||||||
|
"resourceId": 76,
|
||||||
|
"changes": {
|
||||||
|
"note": "and here the note is updated nicely."
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</code>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<a id="resources_deletenote" name="resources_deletenote"
|
||||||
|
class="old-syle-anchor"> </a>
|
||||||
|
<div class="method-section">
|
||||||
|
<div class="method-description">
|
||||||
|
<h4>Delete a Resource Note</h4>
|
||||||
|
</div>
|
||||||
|
<div class="method-example">
|
||||||
|
<code class="method-declaration">
|
||||||
|
DELETE https://DomainName/api/v1/{resource}/{resourceId}/notes/{noteId}
|
||||||
|
</code>
|
||||||
|
<code class="method-request">
|
||||||
|
DELETE clients/1/notes/76
|
||||||
|
Content-Type: application/json
|
||||||
|
No Request Body:
|
||||||
|
</code>
|
||||||
|
<code class="method-response">
|
||||||
|
{
|
||||||
|
"resourceId": 76
|
||||||
|
}
|
||||||
|
</code>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- end of Notes api docs -->
|
||||||
<!-- start of reports api docs -->
|
<!-- start of reports api docs -->
|
||||||
<a id="reports" name="reports" class="old-syle-anchor"> </a>
|
<a id="reports" name="reports" class="old-syle-anchor"> </a>
|
||||||
<div class="method-section">
|
<div class="method-section">
|
||||||
@@ -10911,22 +11000,6 @@ Content-Type: application/json
|
|||||||
<td></td>
|
<td></td>
|
||||||
<td></td>
|
<td></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
|
||||||
<td></td>
|
|
||||||
<td>clients/{clientId}/notes</td>
|
|
||||||
<td><a href="#clients_addnote">Add a Client Note</a></td>
|
|
||||||
<td><a href="#clients_notes">Retrieve a Client's Notes</a></td>
|
|
||||||
<td></td>
|
|
||||||
<td></td>
|
|
||||||
</tr>
|
|
||||||
<tr class="alt">
|
|
||||||
<td></td>
|
|
||||||
<td>clients/{clientId}/notes/{noteId}</td>
|
|
||||||
<td></td>
|
|
||||||
<td><a href="#clients_retrievenote">Retrieve a Client Note</a></td>
|
|
||||||
<td><a href="#clients_updatenote">Update a Client Note</a></td>
|
|
||||||
<td></td>
|
|
||||||
</tr>
|
|
||||||
<!-- loans api full matrix-->
|
<!-- loans api full matrix-->
|
||||||
<tr class="alt">
|
<tr class="alt">
|
||||||
<td><a href="#loans">Loans</a></td>
|
<td><a href="#loans">Loans</a></td>
|
||||||
|
|||||||
+16
@@ -32,6 +32,7 @@ import org.mifosplatform.infrastructure.core.serialization.DefaultToApiJsonSeria
|
|||||||
import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext;
|
import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext;
|
||||||
import org.mifosplatform.portfolio.note.data.NoteData;
|
import org.mifosplatform.portfolio.note.data.NoteData;
|
||||||
import org.mifosplatform.portfolio.note.domain.NoteType;
|
import org.mifosplatform.portfolio.note.domain.NoteType;
|
||||||
|
import org.mifosplatform.portfolio.note.exception.NoteResourceNotSupportedFoundException;
|
||||||
import org.mifosplatform.portfolio.note.service.NoteReadPlatformService;
|
import org.mifosplatform.portfolio.note.service.NoteReadPlatformService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.context.annotation.Scope;
|
import org.springframework.context.annotation.Scope;
|
||||||
@@ -70,6 +71,9 @@ public class NotesApiResource {
|
|||||||
@PathParam("resourceId") final Long resourceId, @Context final UriInfo uriInfo) {
|
@PathParam("resourceId") final Long resourceId, @Context final UriInfo uriInfo) {
|
||||||
|
|
||||||
NoteType noteType = NoteType.fromApiUrl(resourceType);
|
NoteType noteType = NoteType.fromApiUrl(resourceType);
|
||||||
|
|
||||||
|
if(noteType == null){ throw new NoteResourceNotSupportedFoundException(resourceType); };
|
||||||
|
|
||||||
this.context.authenticatedUser().validateHasReadPermission(getResourceNameForPermissions(noteType));
|
this.context.authenticatedUser().validateHasReadPermission(getResourceNameForPermissions(noteType));
|
||||||
|
|
||||||
final Integer noteTypeId = noteType.getValue();
|
final Integer noteTypeId = noteType.getValue();
|
||||||
@@ -88,6 +92,9 @@ public class NotesApiResource {
|
|||||||
@PathParam("noteId") final Long noteId, @Context final UriInfo uriInfo) {
|
@PathParam("noteId") final Long noteId, @Context final UriInfo uriInfo) {
|
||||||
|
|
||||||
NoteType noteType = NoteType.fromApiUrl(resourceType);
|
NoteType noteType = NoteType.fromApiUrl(resourceType);
|
||||||
|
|
||||||
|
if(noteType == null){ throw new NoteResourceNotSupportedFoundException(resourceType); };
|
||||||
|
|
||||||
this.context.authenticatedUser().validateHasReadPermission(getResourceNameForPermissions(noteType));
|
this.context.authenticatedUser().validateHasReadPermission(getResourceNameForPermissions(noteType));
|
||||||
|
|
||||||
final Integer noteTypeId = noteType.getValue();
|
final Integer noteTypeId = noteType.getValue();
|
||||||
@@ -105,6 +112,9 @@ public class NotesApiResource {
|
|||||||
final String apiRequestBodyAsJson) {
|
final String apiRequestBodyAsJson) {
|
||||||
|
|
||||||
NoteType noteType = NoteType.fromApiUrl(resourceType);
|
NoteType noteType = NoteType.fromApiUrl(resourceType);
|
||||||
|
|
||||||
|
if(noteType == null){ throw new NoteResourceNotSupportedFoundException(resourceType); };
|
||||||
|
|
||||||
final String resourceNameForPermissions = getResourceNameForPermissions(noteType);
|
final String resourceNameForPermissions = getResourceNameForPermissions(noteType);
|
||||||
final CommandWrapper commandRequest = new CommandWrapperBuilder().createNote(resourceNameForPermissions, resourceType, resourceId)
|
final CommandWrapper commandRequest = new CommandWrapperBuilder().createNote(resourceNameForPermissions, resourceType, resourceId)
|
||||||
.withJson(apiRequestBodyAsJson).build();
|
.withJson(apiRequestBodyAsJson).build();
|
||||||
@@ -122,6 +132,9 @@ public class NotesApiResource {
|
|||||||
@PathParam("noteId") final Long noteId, final String apiRequestBodyAsJson) {
|
@PathParam("noteId") final Long noteId, final String apiRequestBodyAsJson) {
|
||||||
|
|
||||||
NoteType noteType = NoteType.fromApiUrl(resourceType);
|
NoteType noteType = NoteType.fromApiUrl(resourceType);
|
||||||
|
|
||||||
|
if(noteType == null){ throw new NoteResourceNotSupportedFoundException(resourceType); };
|
||||||
|
|
||||||
final String resourceNameForPermissions = getResourceNameForPermissions(noteType);
|
final String resourceNameForPermissions = getResourceNameForPermissions(noteType);
|
||||||
|
|
||||||
final CommandWrapper commandRequest = new CommandWrapperBuilder().updateNote(resourceNameForPermissions, resourceType, resourceId, noteId).withJson(apiRequestBodyAsJson).build();
|
final CommandWrapper commandRequest = new CommandWrapperBuilder().updateNote(resourceNameForPermissions, resourceType, resourceId, noteId).withJson(apiRequestBodyAsJson).build();
|
||||||
@@ -139,6 +152,9 @@ public class NotesApiResource {
|
|||||||
@PathParam("noteId") final Long noteId) {
|
@PathParam("noteId") final Long noteId) {
|
||||||
|
|
||||||
NoteType noteType = NoteType.fromApiUrl(resourceType);
|
NoteType noteType = NoteType.fromApiUrl(resourceType);
|
||||||
|
|
||||||
|
if(noteType == null){ throw new NoteResourceNotSupportedFoundException(resourceType); };
|
||||||
|
|
||||||
final String resourceNameForPermissions = getResourceNameForPermissions(noteType);
|
final String resourceNameForPermissions = getResourceNameForPermissions(noteType);
|
||||||
|
|
||||||
final CommandWrapper commandRequest = new CommandWrapperBuilder().deleteNote(resourceNameForPermissions, resourceType, resourceId, noteId).build();
|
final CommandWrapper commandRequest = new CommandWrapperBuilder().deleteNote(resourceNameForPermissions, resourceType, resourceId, noteId).build();
|
||||||
|
|||||||
+18
@@ -0,0 +1,18 @@
|
|||||||
|
/**
|
||||||
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||||
|
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
|
*/
|
||||||
|
package org.mifosplatform.portfolio.note.exception;
|
||||||
|
|
||||||
|
import org.mifosplatform.infrastructure.core.exception.AbstractPlatformResourceNotFoundException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A {@link RuntimeException} thrown when Note does not support a resource.
|
||||||
|
*/
|
||||||
|
public class NoteResourceNotSupportedFoundException extends AbstractPlatformResourceNotFoundException {
|
||||||
|
|
||||||
|
public NoteResourceNotSupportedFoundException(final String resource) {
|
||||||
|
super("error.msg.note.resource.not.supported", "Note does not support resource " + resource);
|
||||||
|
}
|
||||||
|
}
|
||||||
+333
-67
@@ -26,6 +26,7 @@ import org.mifosplatform.portfolio.note.domain.Note;
|
|||||||
import org.mifosplatform.portfolio.note.domain.NoteRepository;
|
import org.mifosplatform.portfolio.note.domain.NoteRepository;
|
||||||
import org.mifosplatform.portfolio.note.domain.NoteType;
|
import org.mifosplatform.portfolio.note.domain.NoteType;
|
||||||
import org.mifosplatform.portfolio.note.exception.NoteNotFoundException;
|
import org.mifosplatform.portfolio.note.exception.NoteNotFoundException;
|
||||||
|
import org.mifosplatform.portfolio.note.exception.NoteResourceNotSupportedFoundException;
|
||||||
import org.mifosplatform.portfolio.note.serialization.NoteCommandFromApiJsonDeserializer;
|
import org.mifosplatform.portfolio.note.serialization.NoteCommandFromApiJsonDeserializer;
|
||||||
import org.mifosplatform.portfolio.savingsaccount.domain.SavingAccount;
|
import org.mifosplatform.portfolio.savingsaccount.domain.SavingAccount;
|
||||||
import org.mifosplatform.portfolio.savingsaccount.domain.SavingAccountRepository;
|
import org.mifosplatform.portfolio.savingsaccount.domain.SavingAccountRepository;
|
||||||
@@ -63,28 +64,169 @@ public class NoteWritePlatformServiceJpaRepositoryImpl implements NoteWritePlatf
|
|||||||
this.fromApiJsonDeserializer = fromApiJsonDeserializer;
|
this.fromApiJsonDeserializer = fromApiJsonDeserializer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private CommandProcessingResult createClientNote(final JsonCommand command) {
|
||||||
|
|
||||||
|
final Long resourceId = command.getSupportedEntityId();
|
||||||
|
|
||||||
|
final Client client = this.clientRepository.findOne(resourceId);
|
||||||
|
if (client == null) { throw new ClientNotFoundException(resourceId); }
|
||||||
|
final Note newNote = Note.clientNoteFromJson(client, command);
|
||||||
|
|
||||||
|
this.noteRepository.save(newNote);
|
||||||
|
|
||||||
|
return new CommandProcessingResultBuilder() //
|
||||||
|
.withCommandId(command.commandId()) //
|
||||||
|
.withEntityId(newNote.getId()) //
|
||||||
|
.withClientId(client.getId()).withOfficeId(client.getOffice().getId()).build();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private CommandProcessingResult createGroupNote(final JsonCommand command) {
|
||||||
|
|
||||||
|
final Long resourceId = command.getSupportedEntityId();
|
||||||
|
|
||||||
|
final Group group = this.groupRepository.findOne(resourceId);
|
||||||
|
if (group == null) { throw new GroupNotFoundException(resourceId); }
|
||||||
|
final Note newNote = Note.groupNoteFromJson(group, command);
|
||||||
|
|
||||||
|
this.noteRepository.save(newNote);
|
||||||
|
|
||||||
|
return new CommandProcessingResultBuilder() //
|
||||||
|
.withCommandId(command.commandId()) //
|
||||||
|
.withEntityId(newNote.getId()) //
|
||||||
|
.withClientId(group.getId()).withOfficeId(group.getOfficeId()).build();
|
||||||
|
}
|
||||||
|
|
||||||
|
private CommandProcessingResult createLoanNote(final JsonCommand command) {
|
||||||
|
|
||||||
|
final Long resourceId = command.getSupportedEntityId();
|
||||||
|
|
||||||
|
final Loan loan = this.loanRepository.findOne(resourceId);
|
||||||
|
if (loan == null) { throw new LoanNotFoundException(resourceId); }
|
||||||
|
|
||||||
|
final String note = command.stringValueOfParameterNamed("note");
|
||||||
|
final Note newNote = Note.loanNote(loan, note);
|
||||||
|
|
||||||
|
this.noteRepository.save(newNote);
|
||||||
|
|
||||||
|
return new CommandProcessingResultBuilder() //
|
||||||
|
.withCommandId(command.commandId()) //
|
||||||
|
.withEntityId(newNote.getId()) //
|
||||||
|
.withClientId(loan.getClientId()).withOfficeId(loan.getOfficeId()).withLoanId(loan.getId()).withGroupId(loan.getGroupId())// Loan
|
||||||
|
// can
|
||||||
|
// be
|
||||||
|
// associated
|
||||||
|
// to
|
||||||
|
// group
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
private CommandProcessingResult createLoanTransactionNote(final JsonCommand command) {
|
||||||
|
|
||||||
|
final Long resourceId = command.getSupportedEntityId();
|
||||||
|
|
||||||
|
final LoanTransaction loanTransaction = this.loanTransactionRepository.findOne(resourceId);
|
||||||
|
if (loanTransaction == null) { throw new LoanTransactionNotFoundException(resourceId); }
|
||||||
|
|
||||||
|
final Loan loan = loanTransaction.getLoan();
|
||||||
|
|
||||||
|
final String note = command.stringValueOfParameterNamed("note");
|
||||||
|
final Note newNote = Note.loanTransactionNote(loan, loanTransaction, note);
|
||||||
|
|
||||||
|
this.noteRepository.save(newNote);
|
||||||
|
|
||||||
|
return new CommandProcessingResultBuilder() //
|
||||||
|
.withCommandId(command.commandId()) //
|
||||||
|
.withEntityId(newNote.getId()) //
|
||||||
|
.withClientId(loan.getClientId()).withOfficeId(loan.getOfficeId()).withLoanId(loan.getId()).withGroupId(loan.getGroupId())// Loan
|
||||||
|
// can
|
||||||
|
// be
|
||||||
|
// associated
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
private CommandProcessingResult createDepositAccountNote(final JsonCommand command) {
|
||||||
|
|
||||||
|
final Long resourceId = command.getSupportedEntityId();
|
||||||
|
|
||||||
|
final DepositAccount depositAccount = this.depositAccountRepository.findOne(resourceId);
|
||||||
|
if (depositAccount == null) { throw new DepositAccountNotFoundException(resourceId); }
|
||||||
|
|
||||||
|
final String note = command.stringValueOfParameterNamed("note");
|
||||||
|
final Note newNote = Note.depositNote(depositAccount, note);
|
||||||
|
|
||||||
|
this.noteRepository.save(newNote);
|
||||||
|
|
||||||
|
return new CommandProcessingResultBuilder() //
|
||||||
|
.withCommandId(command.commandId()) //
|
||||||
|
.withEntityId(newNote.getId()) //
|
||||||
|
.withClientId(depositAccount.client().getId()).withOfficeId(depositAccount.client().getOffice().getId()).build();
|
||||||
|
}
|
||||||
|
|
||||||
|
private CommandProcessingResult createSavingAccountNote(final JsonCommand command) {
|
||||||
|
|
||||||
|
final Long resourceId = command.getSupportedEntityId();
|
||||||
|
|
||||||
|
final SavingAccount savingAccount = this.savingAccountRepository.findOne(resourceId);
|
||||||
|
if (savingAccount == null) { throw new SavingAccountNotFoundException(resourceId); }
|
||||||
|
|
||||||
|
final String note = command.stringValueOfParameterNamed("note");
|
||||||
|
final Note newNote = Note.savingNote(savingAccount, note);
|
||||||
|
|
||||||
|
this.noteRepository.save(newNote);
|
||||||
|
|
||||||
|
return new CommandProcessingResultBuilder() //
|
||||||
|
.withCommandId(command.commandId()) //
|
||||||
|
.withEntityId(newNote.getId()) //
|
||||||
|
.withClientId(savingAccount.getClient().getId()).withOfficeId(savingAccount.getClient().getOffice().getId()).build();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CommandProcessingResult createNote(final JsonCommand command) {
|
public CommandProcessingResult createNote(final JsonCommand command) {
|
||||||
|
|
||||||
this.fromApiJsonDeserializer.validateNote(command.json());
|
this.fromApiJsonDeserializer.validateNote(command.json());
|
||||||
|
|
||||||
final Note newNote = getNewNote(command);
|
final String resourceUrl = command.getSupportedEntityType();
|
||||||
|
final NoteType type = NoteType.fromApiUrl(resourceUrl);
|
||||||
this.noteRepository.save(newNote);
|
switch (type) {
|
||||||
return new CommandProcessingResultBuilder() //
|
case CLIENT: {
|
||||||
.withCommandId(command.commandId()) //
|
return createClientNote(command);
|
||||||
.withEntityId(newNote.getId()) //
|
}
|
||||||
.build();
|
case DEPOSIT: {
|
||||||
|
return createDepositAccountNote(command);
|
||||||
|
}
|
||||||
|
case GROUP: {
|
||||||
|
return createGroupNote(command);
|
||||||
|
}
|
||||||
|
case LOAN: {
|
||||||
|
return createLoanNote(command);
|
||||||
|
}
|
||||||
|
case LOAN_TRANSACTION: {
|
||||||
|
return createLoanTransactionNote(command);
|
||||||
|
}
|
||||||
|
case SAVING: {
|
||||||
|
return createSavingAccountNote(command);
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
throw new NoteResourceNotSupportedFoundException(resourceUrl);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
private CommandProcessingResult updateClientNote(final JsonCommand command) {
|
||||||
public CommandProcessingResult updateNote(final JsonCommand command) {
|
|
||||||
|
|
||||||
this.fromApiJsonDeserializer.validateNote(command.json());
|
final Long resourceId = command.getSupportedEntityId();
|
||||||
|
final Long noteId = command.entityId();
|
||||||
|
final String resourceUrl = command.getSupportedEntityType();
|
||||||
|
|
||||||
|
final NoteType type = NoteType.fromApiUrl(resourceUrl);
|
||||||
|
|
||||||
|
final Client client = this.clientRepository.findOne(resourceId);
|
||||||
|
if (client == null) { throw new ClientNotFoundException(resourceId); }
|
||||||
|
|
||||||
|
final Note noteForUpdate = this.noteRepository.findByClientIdAndId(resourceId, noteId);
|
||||||
|
if (noteForUpdate == null) { throw new NoteNotFoundException(noteId, resourceId, type.name().toLowerCase()); }
|
||||||
|
|
||||||
final Note noteForUpdate = getNoteForUpdate(command);
|
|
||||||
|
|
||||||
final Map<String, Object> changes = noteForUpdate.update(command);
|
final Map<String, Object> changes = noteForUpdate.update(command);
|
||||||
|
|
||||||
if (!changes.isEmpty()) {
|
if (!changes.isEmpty()) {
|
||||||
@@ -94,14 +236,187 @@ public class NoteWritePlatformServiceJpaRepositoryImpl implements NoteWritePlatf
|
|||||||
return new CommandProcessingResultBuilder() //
|
return new CommandProcessingResultBuilder() //
|
||||||
.withCommandId(command.commandId()) //
|
.withCommandId(command.commandId()) //
|
||||||
.withEntityId(noteForUpdate.getId()) //
|
.withEntityId(noteForUpdate.getId()) //
|
||||||
.with(changes) //
|
.withClientId(client.getId()).withOfficeId(client.getOffice().getId())
|
||||||
|
.with(changes)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private CommandProcessingResult updateDepositAccountNote(final JsonCommand command) {
|
||||||
|
|
||||||
|
final Long resourceId = command.getSupportedEntityId();
|
||||||
|
final Long noteId = command.entityId();
|
||||||
|
final String resourceUrl = command.getSupportedEntityType();
|
||||||
|
|
||||||
|
final NoteType type = NoteType.fromApiUrl(resourceUrl);
|
||||||
|
|
||||||
|
final DepositAccount depositAccount = this.depositAccountRepository.findOne(resourceId);
|
||||||
|
if (depositAccount == null) { throw new DepositAccountNotFoundException(resourceId); }
|
||||||
|
final Note noteForUpdate = this.noteRepository.findByDepositAccountIdAndId(resourceId, noteId);
|
||||||
|
|
||||||
|
if (noteForUpdate == null) { throw new NoteNotFoundException(noteId, resourceId, type.name().toLowerCase()); }
|
||||||
|
|
||||||
|
final Map<String, Object> changes = noteForUpdate.update(command);
|
||||||
|
|
||||||
|
if (!changes.isEmpty()) {
|
||||||
|
this.noteRepository.saveAndFlush(noteForUpdate);
|
||||||
|
}
|
||||||
|
|
||||||
|
return new CommandProcessingResultBuilder() //
|
||||||
|
.withCommandId(command.commandId()) //
|
||||||
|
.withEntityId(noteForUpdate.getId()) //
|
||||||
|
.withClientId(depositAccount.client().getId()).withOfficeId(depositAccount.client().getOffice().getId())
|
||||||
|
.with(changes)
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
private CommandProcessingResult updateGroupNote(final JsonCommand command) {
|
||||||
|
|
||||||
|
final Long resourceId = command.getSupportedEntityId();
|
||||||
|
final Long noteId = command.entityId();
|
||||||
|
final String resourceUrl = command.getSupportedEntityType();
|
||||||
|
|
||||||
|
final NoteType type = NoteType.fromApiUrl(resourceUrl);
|
||||||
|
|
||||||
|
final Group group = this.groupRepository.findOne(resourceId);
|
||||||
|
if (group == null) { throw new GroupNotFoundException(resourceId); }
|
||||||
|
final Note noteForUpdate = this.noteRepository.findByGroupIdAndId(resourceId, noteId);
|
||||||
|
|
||||||
|
if (noteForUpdate == null) { throw new NoteNotFoundException(noteId, resourceId, type.name().toLowerCase()); }
|
||||||
|
|
||||||
|
final Map<String, Object> changes = noteForUpdate.update(command);
|
||||||
|
|
||||||
|
if (!changes.isEmpty()) {
|
||||||
|
this.noteRepository.saveAndFlush(noteForUpdate);
|
||||||
|
}
|
||||||
|
|
||||||
|
return new CommandProcessingResultBuilder() //
|
||||||
|
.withCommandId(command.commandId()) //
|
||||||
|
.withEntityId(noteForUpdate.getId()) //
|
||||||
|
.withGroupId(group.getId()).withOfficeId(group.getOfficeId())
|
||||||
|
.with(changes)
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
private CommandProcessingResult updateLoanNote(final JsonCommand command) {
|
||||||
|
|
||||||
|
final Long resourceId = command.getSupportedEntityId();
|
||||||
|
final Long noteId = command.entityId();
|
||||||
|
final String resourceUrl = command.getSupportedEntityType();
|
||||||
|
|
||||||
|
final NoteType type = NoteType.fromApiUrl(resourceUrl);
|
||||||
|
|
||||||
|
final Loan loan = this.loanRepository.findOne(resourceId);
|
||||||
|
if (loan == null) { throw new LoanNotFoundException(resourceId); }
|
||||||
|
final Note noteForUpdate = this.noteRepository.findByLoanIdAndId(resourceId, noteId);
|
||||||
|
|
||||||
|
if (noteForUpdate == null) { throw new NoteNotFoundException(noteId, resourceId, type.name().toLowerCase()); }
|
||||||
|
|
||||||
|
final Map<String, Object> changes = noteForUpdate.update(command);
|
||||||
|
|
||||||
|
if (!changes.isEmpty()) {
|
||||||
|
this.noteRepository.saveAndFlush(noteForUpdate);
|
||||||
|
}
|
||||||
|
|
||||||
|
return new CommandProcessingResultBuilder().withCommandId(command.commandId()).withEntityId(noteForUpdate.getId())
|
||||||
|
.withClientId(loan.getClientId()).withLoanId(loan.getId()).withGroupId(loan.getGroupId()).withOfficeId(loan.getOfficeId())
|
||||||
|
.with(changes)
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
private CommandProcessingResult updateLoanTransactionNote(final JsonCommand command) {
|
||||||
|
|
||||||
|
final Long resourceId = command.getSupportedEntityId();
|
||||||
|
final Long noteId = command.entityId();
|
||||||
|
final String resourceUrl = command.getSupportedEntityType();
|
||||||
|
|
||||||
|
final NoteType type = NoteType.fromApiUrl(resourceUrl);
|
||||||
|
|
||||||
|
final LoanTransaction loanTransaction = this.loanTransactionRepository.findOne(resourceId);
|
||||||
|
if (loanTransaction == null) { throw new LoanTransactionNotFoundException(resourceId); }
|
||||||
|
final Loan loan = loanTransaction.getLoan();
|
||||||
|
|
||||||
|
final Note noteForUpdate = this.noteRepository.findByLoanTransactionIdAndId(resourceId, noteId);
|
||||||
|
|
||||||
|
if (noteForUpdate == null) { throw new NoteNotFoundException(noteId, resourceId, type.name().toLowerCase()); }
|
||||||
|
|
||||||
|
final Map<String, Object> changes = noteForUpdate.update(command);
|
||||||
|
|
||||||
|
if (!changes.isEmpty()) {
|
||||||
|
this.noteRepository.saveAndFlush(noteForUpdate);
|
||||||
|
}
|
||||||
|
|
||||||
|
return new CommandProcessingResultBuilder().withCommandId(command.commandId()).withEntityId(noteForUpdate.getId())
|
||||||
|
.withClientId(loan.getClientId()).withLoanId(loan.getId()).withGroupId(loan.getGroupId()).withOfficeId(loan.getOfficeId())
|
||||||
|
.with(changes)
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
private CommandProcessingResult updateSavingAccountNote(final JsonCommand command) {
|
||||||
|
|
||||||
|
final Long resourceId = command.getSupportedEntityId();
|
||||||
|
final Long noteId = command.entityId();
|
||||||
|
final String resourceUrl = command.getSupportedEntityType();
|
||||||
|
|
||||||
|
final NoteType type = NoteType.fromApiUrl(resourceUrl);
|
||||||
|
|
||||||
|
final SavingAccount savingAccount = this.savingAccountRepository.findOne(resourceId);
|
||||||
|
if (savingAccount == null) { throw new SavingAccountNotFoundException(resourceId); }
|
||||||
|
|
||||||
|
final Note noteForUpdate = this.noteRepository.findBySavingAccountIdAndId(resourceId, noteId);
|
||||||
|
|
||||||
|
if (noteForUpdate == null) { throw new NoteNotFoundException(noteId, resourceId, type.name().toLowerCase()); }
|
||||||
|
|
||||||
|
final Map<String, Object> changes = noteForUpdate.update(command);
|
||||||
|
|
||||||
|
if (!changes.isEmpty()) {
|
||||||
|
this.noteRepository.saveAndFlush(noteForUpdate);
|
||||||
|
}
|
||||||
|
|
||||||
|
return new CommandProcessingResultBuilder() //
|
||||||
|
.withCommandId(command.commandId()) //
|
||||||
|
.withEntityId(noteForUpdate.getId()) //
|
||||||
|
.withClientId(savingAccount.getClient().getId()).withOfficeId(savingAccount.getClient().getOffice().getId())
|
||||||
|
.with(changes)
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CommandProcessingResult deleteNote(JsonCommand command) {
|
public CommandProcessingResult updateNote(final JsonCommand command) {
|
||||||
|
|
||||||
final Note noteForDelete = getNoteForUpdate(command);
|
this.fromApiJsonDeserializer.validateNote(command.json());
|
||||||
|
|
||||||
|
final String resourceUrl = command.getSupportedEntityType();
|
||||||
|
final NoteType type = NoteType.fromApiUrl(resourceUrl);
|
||||||
|
|
||||||
|
switch (type) {
|
||||||
|
case CLIENT: {
|
||||||
|
return updateClientNote(command);
|
||||||
|
}
|
||||||
|
case DEPOSIT: {
|
||||||
|
return updateDepositAccountNote(command);
|
||||||
|
}
|
||||||
|
case GROUP: {
|
||||||
|
return updateGroupNote(command);
|
||||||
|
}
|
||||||
|
case LOAN: {
|
||||||
|
return updateLoanNote(command);
|
||||||
|
}
|
||||||
|
case LOAN_TRANSACTION: {
|
||||||
|
return updateLoanTransactionNote(command);
|
||||||
|
}
|
||||||
|
case SAVING: {
|
||||||
|
return updateSavingAccountNote(command);
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
throw new NoteResourceNotSupportedFoundException(resourceUrl);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CommandProcessingResult deleteNote(final JsonCommand command) {
|
||||||
|
|
||||||
|
final Note noteForDelete = getNoteForDelete(command);
|
||||||
|
|
||||||
this.noteRepository.delete(noteForDelete);
|
this.noteRepository.delete(noteForDelete);
|
||||||
return new CommandProcessingResultBuilder() //
|
return new CommandProcessingResultBuilder() //
|
||||||
@@ -110,56 +425,7 @@ public class NoteWritePlatformServiceJpaRepositoryImpl implements NoteWritePlatf
|
|||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
private Note getNewNote(final JsonCommand command) {
|
private Note getNoteForDelete(final JsonCommand command) {
|
||||||
final String resourceUrl = command.getSupportedEntityType();
|
|
||||||
final Long resourceId = command.getSupportedEntityId();
|
|
||||||
final NoteType type = NoteType.fromApiUrl(resourceUrl);
|
|
||||||
Note newNote = null;
|
|
||||||
final String note = command.stringValueOfParameterNamed("note");
|
|
||||||
switch (type) {
|
|
||||||
case CLIENT: {
|
|
||||||
final Client client = this.clientRepository.findOne(resourceId);
|
|
||||||
if (client == null) { throw new ClientNotFoundException(resourceId); }
|
|
||||||
newNote = Note.clientNoteFromJson(client, command);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case DEPOSIT: {
|
|
||||||
final DepositAccount depositAccount = this.depositAccountRepository.findOne(resourceId);
|
|
||||||
if (depositAccount == null) { throw new DepositAccountNotFoundException(resourceId); }
|
|
||||||
newNote = Note.depositNote(depositAccount, note);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case GROUP: {
|
|
||||||
final Group group = this.groupRepository.findOne(resourceId);
|
|
||||||
if (group == null) { throw new GroupNotFoundException(resourceId); }
|
|
||||||
newNote = Note.groupNoteFromJson(group, command);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case LOAN: {
|
|
||||||
final Loan loan = this.loanRepository.findOne(resourceId);
|
|
||||||
if (loan == null) { throw new LoanNotFoundException(resourceId); }
|
|
||||||
newNote = Note.loanNote(loan, note);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case LOAN_TRANSACTION: {
|
|
||||||
final LoanTransaction loanTransaction = this.loanTransactionRepository.findOne(resourceId);
|
|
||||||
if (loanTransaction == null) { throw new LoanTransactionNotFoundException(resourceId); }
|
|
||||||
final Loan loan = loanTransaction.getLoan();
|
|
||||||
newNote = Note.loanTransactionNote(loan, loanTransaction, note);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case SAVING: {
|
|
||||||
final SavingAccount savingAccount = this.savingAccountRepository.findOne(resourceId);
|
|
||||||
if (savingAccount == null) { throw new SavingAccountNotFoundException(resourceId); }
|
|
||||||
newNote = Note.savingNote(savingAccount, note);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return newNote;
|
|
||||||
}
|
|
||||||
|
|
||||||
private Note getNoteForUpdate(final JsonCommand command) {
|
|
||||||
final String resourceUrl = command.getSupportedEntityType();
|
final String resourceUrl = command.getSupportedEntityType();
|
||||||
final Long resourceId = command.getSupportedEntityId();
|
final Long resourceId = command.getSupportedEntityId();
|
||||||
final Long noteId = command.entityId();
|
final Long noteId = command.entityId();
|
||||||
@@ -194,5 +460,5 @@ public class NoteWritePlatformServiceJpaRepositoryImpl implements NoteWritePlatf
|
|||||||
if (noteForUpdate == null) { throw new NoteNotFoundException(noteId, resourceId, type.name().toLowerCase()); }
|
if (noteForUpdate == null) { throw new NoteNotFoundException(noteId, resourceId, type.name().toLowerCase()); }
|
||||||
return noteForUpdate;
|
return noteForUpdate;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user