Skip to content

Commit 08ec4d0

Browse files
committed
FINERACT-2239: New command processing - resource notes
1 parent 5408921 commit 08ec4d0

File tree

35 files changed

+720
-887
lines changed

35 files changed

+720
-887
lines changed

custom/acme/note/service/src/main/java/com/acme/fineract/portfolio/note/service/AcmeNoteWritePlatformService.java

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,12 @@
1919
package com.acme.fineract.portfolio.note.service;
2020

2121
import lombok.extern.slf4j.Slf4j;
22-
import org.apache.fineract.infrastructure.core.api.JsonCommand;
23-
import org.apache.fineract.infrastructure.core.data.CommandProcessingResult;
24-
import org.apache.fineract.portfolio.client.domain.Client;
22+
import org.apache.fineract.portfolio.note.data.NoteCreateRequest;
23+
import org.apache.fineract.portfolio.note.data.NoteCreateResponse;
24+
import org.apache.fineract.portfolio.note.data.NoteDeleteRequest;
25+
import org.apache.fineract.portfolio.note.data.NoteDeleteResponse;
26+
import org.apache.fineract.portfolio.note.data.NoteUpdateRequest;
27+
import org.apache.fineract.portfolio.note.data.NoteUpdateResponse;
2528
import org.apache.fineract.portfolio.note.service.NoteWritePlatformService;
2629
import org.springframework.beans.factory.InitializingBean;
2730
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
@@ -38,27 +41,17 @@ public void afterPropertiesSet() throws Exception {
3841
}
3942

4043
@Override
41-
public CommandProcessingResult createNote(JsonCommand command) {
44+
public NoteCreateResponse createNote(NoteCreateRequest request) {
4245
throw new UnsupportedOperationException("createNote() is not yet implemented.");
4346
}
4447

4548
@Override
46-
public void createLoanTransactionNote(Long loanTransactionId, String note) {
47-
throw new UnsupportedOperationException("createLoanTransactionNote() is not yet implemented.");
48-
}
49-
50-
@Override
51-
public CommandProcessingResult updateNote(JsonCommand command) {
49+
public NoteUpdateResponse updateNote(NoteUpdateRequest request) {
5250
throw new UnsupportedOperationException("updateNote() is not yet implemented.");
5351
}
5452

5553
@Override
56-
public CommandProcessingResult deleteNote(JsonCommand command) {
54+
public NoteDeleteResponse deleteNote(NoteDeleteRequest request) {
5755
throw new UnsupportedOperationException("deleteNote() is not yet implemented.");
5856
}
59-
60-
@Override
61-
public void createAndPersistClientNote(Client client, JsonCommand command) {
62-
log.warn("createAndPersistClientNote() is intentionally left empty and does nothing.");
63-
}
6457
}

custom/acme/note/starter/src/test/java/com/acme/fineract/portfolio/note/starter/TestDefaultConfiguration.java

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,13 @@
2121
import static org.mockito.Mockito.mock;
2222

2323
import org.apache.fineract.infrastructure.core.config.FineractProperties;
24-
import org.apache.fineract.infrastructure.core.serialization.FromJsonHelper;
2524
import org.apache.fineract.infrastructure.core.service.database.RoutingDataSource;
2625
import org.apache.fineract.infrastructure.core.service.database.RoutingDataSourceServiceFactory;
2726
import org.apache.fineract.portfolio.client.domain.ClientRepositoryWrapper;
2827
import org.apache.fineract.portfolio.group.domain.GroupRepository;
2928
import org.apache.fineract.portfolio.loanaccount.domain.LoanRepositoryWrapper;
3029
import org.apache.fineract.portfolio.loanaccount.domain.LoanTransactionRepository;
3130
import org.apache.fineract.portfolio.note.domain.NoteRepository;
32-
import org.apache.fineract.portfolio.note.serialization.NoteCommandFromApiJsonDeserializer;
3331
import org.springframework.boot.context.properties.EnableConfigurationProperties;
3432
import org.springframework.context.annotation.Bean;
3533
import org.springframework.jdbc.core.JdbcTemplate;
@@ -38,11 +36,6 @@
3836
public class TestDefaultConfiguration {
3937
// NOTE: unfortunately an abastract base class that contains all these mock functions won't work
4038

41-
@Bean
42-
public FromJsonHelper fromJsonHelper() {
43-
return mock(FromJsonHelper.class);
44-
}
45-
4639
@Bean
4740
public RoutingDataSourceServiceFactory routingDataSourceServiceFactory() {
4841
return mock(RoutingDataSourceServiceFactory.class);
@@ -82,9 +75,4 @@ public LoanRepositoryWrapper loanRepository() {
8275
public LoanTransactionRepository loanTransactionRepository() {
8376
return mock(LoanTransactionRepository.class);
8477
}
85-
86-
@Bean
87-
public NoteCommandFromApiJsonDeserializer fromApiJsonDeserializer(FromJsonHelper fromJsonHelper) {
88-
return new NoteCommandFromApiJsonDeserializer(fromJsonHelper);
89-
}
9078
}

custom/acme/note/starter/src/test/java/com/acme/fineract/portfolio/note/starter/TestOverrideConfiguration.java

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,13 @@
2020

2121
import static org.mockito.Mockito.mock;
2222

23-
import org.apache.fineract.infrastructure.core.serialization.FromJsonHelper;
2423
import org.apache.fineract.infrastructure.core.service.database.RoutingDataSource;
2524
import org.apache.fineract.infrastructure.core.service.database.RoutingDataSourceServiceFactory;
2625
import org.apache.fineract.portfolio.client.domain.ClientRepositoryWrapper;
2726
import org.apache.fineract.portfolio.group.domain.GroupRepository;
2827
import org.apache.fineract.portfolio.loanaccount.domain.LoanRepositoryWrapper;
2928
import org.apache.fineract.portfolio.loanaccount.domain.LoanTransactionRepository;
3029
import org.apache.fineract.portfolio.note.domain.NoteRepository;
31-
import org.apache.fineract.portfolio.note.serialization.NoteCommandFromApiJsonDeserializer;
3230
import org.springframework.context.annotation.Bean;
3331
import org.springframework.context.annotation.ComponentScan;
3432
import org.springframework.jdbc.core.JdbcTemplate;
@@ -37,11 +35,6 @@
3735
public class TestOverrideConfiguration {
3836
// NOTE: unfortunately an abastract base class that contains all these mock functions won't work
3937

40-
@Bean
41-
public FromJsonHelper fromJsonHelper() {
42-
return mock(FromJsonHelper.class);
43-
}
44-
4538
@Bean
4639
public RoutingDataSourceServiceFactory routingDataSourceServiceFactory() {
4740
return mock(RoutingDataSourceServiceFactory.class);
@@ -81,9 +74,4 @@ public LoanRepositoryWrapper loanRepository() {
8174
public LoanTransactionRepository loanTransactionRepository() {
8275
return mock(LoanTransactionRepository.class);
8376
}
84-
85-
@Bean
86-
public NoteCommandFromApiJsonDeserializer fromApiJsonDeserializer(FromJsonHelper fromJsonHelper) {
87-
return new NoteCommandFromApiJsonDeserializer(fromJsonHelper);
88-
}
8977
}

fineract-core/src/main/java/org/apache/fineract/infrastructure/cache/data/CacheData.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
*/
1919
package org.apache.fineract.infrastructure.cache.data;
2020

21+
import java.io.Serial;
22+
import java.io.Serializable;
2123
import lombok.AllArgsConstructor;
2224
import lombok.Builder;
2325
import lombok.Data;
@@ -28,7 +30,10 @@
2830
@Data
2931
@NoArgsConstructor
3032
@AllArgsConstructor
31-
public final class CacheData {
33+
public final class CacheData implements Serializable {
34+
35+
@Serial
36+
private static final long serialVersionUID = 1L;
3237

3338
@SuppressWarnings("unused")
3439
private EnumOptionData cacheType;
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/**
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
package org.apache.fineract.portfolio.note.data;
20+
21+
import io.swagger.v3.oas.annotations.Hidden;
22+
import jakarta.validation.constraints.NotNull;
23+
import jakarta.validation.constraints.Size;
24+
import java.io.Serial;
25+
import java.io.Serializable;
26+
import lombok.AllArgsConstructor;
27+
import lombok.Builder;
28+
import lombok.Data;
29+
import lombok.NoArgsConstructor;
30+
import org.apache.fineract.portfolio.note.domain.NoteType;
31+
32+
@Builder
33+
@Data
34+
@NoArgsConstructor
35+
@AllArgsConstructor
36+
public class NoteCreateRequest implements Serializable {
37+
38+
@Serial
39+
private static final long serialVersionUID = 1L;
40+
41+
@Hidden
42+
private Long resourceId;
43+
@Hidden
44+
private NoteType type;
45+
@Size(max = 1000, message = "{org.apache.fineract.portfolio.note.note.size}")
46+
@NotNull(message = "{org.apache.fineract.portfolio.note.note.not-null}")
47+
private String note;
48+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/**
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
package org.apache.fineract.portfolio.note.data;
20+
21+
import java.io.Serial;
22+
import java.io.Serializable;
23+
import lombok.AllArgsConstructor;
24+
import lombok.Builder;
25+
import lombok.Data;
26+
import lombok.NoArgsConstructor;
27+
28+
@Builder
29+
@Data
30+
@NoArgsConstructor
31+
@AllArgsConstructor
32+
public class NoteCreateResponse implements Serializable {
33+
34+
@Serial
35+
private static final long serialVersionUID = 1L;
36+
37+
private Long entityId;
38+
private Long officeId;
39+
private Long resourceId;
40+
}

fineract-core/src/main/java/org/apache/fineract/portfolio/note/data/NoteData.java

Lines changed: 27 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -18,31 +18,37 @@
1818
*/
1919
package org.apache.fineract.portfolio.note.data;
2020

21+
import java.io.Serial;
22+
import java.io.Serializable;
2123
import java.time.OffsetDateTime;
24+
import lombok.AllArgsConstructor;
2225
import lombok.Builder;
23-
import lombok.Getter;
26+
import lombok.Data;
27+
import lombok.NoArgsConstructor;
2428
import org.apache.fineract.infrastructure.core.data.EnumOptionData;
2529

26-
/**
27-
* Immutable data object represent note or case information about a client, loan or loan transaction.
28-
*/
29-
@Getter
3030
@Builder
31-
public class NoteData {
31+
@Data
32+
@NoArgsConstructor
33+
@AllArgsConstructor
34+
public class NoteData implements Serializable {
35+
36+
@Serial
37+
private static final long serialVersionUID = 1L;
3238

33-
private final Long id;
34-
private final Long clientId;
35-
private final Long groupId;
36-
private final Long loanId;
37-
private final Long loanTransactionId;
38-
private final Long depositAccountId;
39-
private final Long savingAccountId;
40-
private final EnumOptionData noteType;
41-
private final String note;
42-
private final Long createdById;
43-
private final String createdByUsername;
44-
private final OffsetDateTime createdOn;
45-
private final Long updatedById;
46-
private final String updatedByUsername;
47-
private final OffsetDateTime updatedOn;
39+
private Long id;
40+
private Long clientId;
41+
private Long groupId;
42+
private Long loanId;
43+
private Long loanTransactionId;
44+
private Long depositAccountId;
45+
private Long savingAccountId;
46+
private EnumOptionData noteType;
47+
private String note;
48+
private Long createdById;
49+
private String createdByUsername;
50+
private OffsetDateTime createdOn;
51+
private Long updatedById;
52+
private String updatedByUsername;
53+
private OffsetDateTime updatedOn;
4854
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/**
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
package org.apache.fineract.portfolio.note.data;
20+
21+
import io.swagger.v3.oas.annotations.Hidden;
22+
import java.io.Serial;
23+
import java.io.Serializable;
24+
import lombok.AllArgsConstructor;
25+
import lombok.Builder;
26+
import lombok.Data;
27+
import lombok.NoArgsConstructor;
28+
import org.apache.fineract.portfolio.note.domain.NoteType;
29+
30+
@Builder
31+
@Data
32+
@NoArgsConstructor
33+
@AllArgsConstructor
34+
public class NoteDeleteRequest implements Serializable {
35+
36+
@Serial
37+
private static final long serialVersionUID = 1L;
38+
39+
@Hidden
40+
private Long id;
41+
@Hidden
42+
private Long resourceId;
43+
@Hidden
44+
private NoteType type;
45+
}

fineract-provider/src/main/java/org/apache/fineract/portfolio/note/data/NoteRequest.java renamed to fineract-core/src/main/java/org/apache/fineract/portfolio/note/data/NoteDeleteResponse.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,18 @@
2121
import java.io.Serial;
2222
import java.io.Serializable;
2323
import lombok.AllArgsConstructor;
24+
import lombok.Builder;
2425
import lombok.Data;
2526
import lombok.NoArgsConstructor;
2627

28+
@Builder
2729
@Data
2830
@NoArgsConstructor
2931
@AllArgsConstructor
30-
public class NoteRequest implements Serializable {
32+
public class NoteDeleteResponse implements Serializable {
3133

3234
@Serial
3335
private static final long serialVersionUID = 1L;
3436

35-
private String note;
37+
private Long resourceId;
3638
}

0 commit comments

Comments
 (0)