refactor: add lombok to mix module
This commit is contained in:
committed by
Arnold Gálovics
parent
ad2f2862cb
commit
3d332f0840
@@ -18,29 +18,18 @@
|
|||||||
*/
|
*/
|
||||||
package org.apache.fineract.mix.data;
|
package org.apache.fineract.mix.data;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@NoArgsConstructor
|
||||||
|
@Accessors(chain = true)
|
||||||
public class ContextData {
|
public class ContextData {
|
||||||
|
|
||||||
private final String dimensionType;
|
private String dimensionType;
|
||||||
private final String dimension;
|
private String dimension;
|
||||||
private final Integer periodType;
|
private Integer periodType;
|
||||||
|
|
||||||
public ContextData(final String dimensionType, final String dimension, final Integer taxonomyType) {
|
|
||||||
this.dimensionType = dimensionType;
|
|
||||||
this.dimension = dimension;
|
|
||||||
this.periodType = taxonomyType.equals(MixTaxonomyData.BALANCESHEET) || taxonomyType.equals(MixTaxonomyData.PORTFOLIO) ? 0 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getDimensionType() {
|
|
||||||
return this.dimensionType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getDimension() {
|
|
||||||
return this.dimension;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getPeriodType() {
|
|
||||||
return this.periodType;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
|
|||||||
@@ -18,6 +18,13 @@
|
|||||||
*/
|
*/
|
||||||
package org.apache.fineract.mix.data;
|
package org.apache.fineract.mix.data;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@NoArgsConstructor
|
||||||
|
@Accessors(chain = true)
|
||||||
public class MixTaxonomyData {
|
public class MixTaxonomyData {
|
||||||
|
|
||||||
public static final Integer PORTFOLIO = 0;
|
public static final Integer PORTFOLIO = 0;
|
||||||
@@ -26,40 +33,13 @@ public class MixTaxonomyData {
|
|||||||
public static final Integer EXPENSE = 3;
|
public static final Integer EXPENSE = 3;
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
private final Long id;
|
private Long id;
|
||||||
private final String name;
|
private String name;
|
||||||
private final String namespace;
|
private String namespace;
|
||||||
private final String dimension;
|
private String dimension;
|
||||||
private final Integer type;
|
private Integer type;
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
private final String description;
|
private String description;
|
||||||
|
|
||||||
public MixTaxonomyData(final Long id, final String name, final String namespace, final String dimension, final Integer type,
|
|
||||||
final String description) {
|
|
||||||
|
|
||||||
this.id = id;
|
|
||||||
this.name = name;
|
|
||||||
this.namespace = namespace;
|
|
||||||
this.dimension = dimension;
|
|
||||||
this.type = type;
|
|
||||||
this.description = description;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getName() {
|
|
||||||
return this.name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getNamespace() {
|
|
||||||
return this.namespace;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getDimension() {
|
|
||||||
return this.dimension;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getType() {
|
|
||||||
return this.type;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isPortfolio() {
|
public boolean isPortfolio() {
|
||||||
return this.type == 5;
|
return this.type == 5;
|
||||||
|
|||||||
+9
-15
@@ -18,21 +18,15 @@
|
|||||||
*/
|
*/
|
||||||
package org.apache.fineract.mix.data;
|
package org.apache.fineract.mix.data;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@NoArgsConstructor
|
||||||
|
@Accessors(chain = true)
|
||||||
public class MixTaxonomyMappingData {
|
public class MixTaxonomyMappingData {
|
||||||
|
|
||||||
private final String identifier;
|
private String identifier;
|
||||||
private final String config;
|
private String config;
|
||||||
|
|
||||||
public MixTaxonomyMappingData(final String identifier, final String config) {
|
|
||||||
this.identifier = identifier;
|
|
||||||
this.config = config;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getIdentifier() {
|
|
||||||
return this.identifier;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getConfig() {
|
|
||||||
return this.config;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,22 +18,18 @@
|
|||||||
*/
|
*/
|
||||||
package org.apache.fineract.mix.data;
|
package org.apache.fineract.mix.data;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@NoArgsConstructor
|
||||||
|
@Accessors(chain = true)
|
||||||
public class NamespaceData {
|
public class NamespaceData {
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
private final Long id;
|
private Long id;
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
private final String prefix;
|
private String prefix;
|
||||||
private final String url;
|
private String url;
|
||||||
|
|
||||||
public NamespaceData(final Long id, final String prefix, final String url) {
|
|
||||||
|
|
||||||
this.id = id;
|
|
||||||
this.prefix = prefix;
|
|
||||||
this.url = url;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String url() {
|
|
||||||
return this.url;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,34 +21,17 @@ package org.apache.fineract.mix.data;
|
|||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.sql.Date;
|
import java.sql.Date;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@NoArgsConstructor
|
||||||
|
@Accessors(chain = true)
|
||||||
public class XBRLData {
|
public class XBRLData {
|
||||||
|
|
||||||
private final HashMap<MixTaxonomyData, BigDecimal> resultMap;
|
private HashMap<MixTaxonomyData, BigDecimal> resultMap;
|
||||||
private final Date startDate;
|
private Date startDate;
|
||||||
private final Date endDate;
|
private Date endDate;
|
||||||
private final String currency;
|
private String currency;
|
||||||
|
|
||||||
public XBRLData(final HashMap<MixTaxonomyData, BigDecimal> resultMap, final Date startDate, final Date endDate, final String currency) {
|
|
||||||
this.resultMap = resultMap;
|
|
||||||
this.startDate = startDate;
|
|
||||||
this.endDate = endDate;
|
|
||||||
this.currency = currency;
|
|
||||||
}
|
|
||||||
|
|
||||||
public HashMap<MixTaxonomyData, BigDecimal> getResultMap() {
|
|
||||||
return this.resultMap;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Date getStartDate() {
|
|
||||||
return this.startDate;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Date getEndDate() {
|
|
||||||
return this.endDate;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getCurrency() {
|
|
||||||
return this.currency;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
+9
-5
@@ -21,13 +21,21 @@ package org.apache.fineract.mix.domain;
|
|||||||
import javax.persistence.Column;
|
import javax.persistence.Column;
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
import javax.persistence.Table;
|
import javax.persistence.Table;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.Setter;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.apache.fineract.infrastructure.core.api.JsonCommand;
|
import org.apache.fineract.infrastructure.core.api.JsonCommand;
|
||||||
import org.apache.fineract.infrastructure.core.domain.AbstractPersistableCustom;
|
import org.apache.fineract.infrastructure.core.domain.AbstractPersistableCustom;
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "mix_taxonomy_mapping")
|
@Table(name = "mix_taxonomy_mapping")
|
||||||
public class MixTaxonomyMapping extends AbstractPersistableCustom {
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@NoArgsConstructor
|
||||||
|
@Accessors(chain = true)
|
||||||
|
public final class MixTaxonomyMapping extends AbstractPersistableCustom {
|
||||||
|
|
||||||
@Column(name = "identifier")
|
@Column(name = "identifier")
|
||||||
private String identifier;
|
private String identifier;
|
||||||
@@ -38,10 +46,6 @@ public class MixTaxonomyMapping extends AbstractPersistableCustom {
|
|||||||
@Column(name = "currency")
|
@Column(name = "currency")
|
||||||
private String currency;
|
private String currency;
|
||||||
|
|
||||||
protected MixTaxonomyMapping() {
|
|
||||||
// default
|
|
||||||
}
|
|
||||||
|
|
||||||
private MixTaxonomyMapping(final String identifier, final String config, final String currency) {
|
private MixTaxonomyMapping(final String identifier, final String config, final String currency) {
|
||||||
this.identifier = StringUtils.defaultIfEmpty(identifier, null);
|
this.identifier = StringUtils.defaultIfEmpty(identifier, null);
|
||||||
this.config = StringUtils.defaultIfEmpty(config, null);
|
this.config = StringUtils.defaultIfEmpty(config, null);
|
||||||
|
|||||||
+1
-1
@@ -47,7 +47,7 @@ public class MixTaxonomyMappingReadPlatformServiceImpl implements MixTaxonomyMap
|
|||||||
public MixTaxonomyMappingData mapRow(final ResultSet rs, @SuppressWarnings("unused") final int rowNum) throws SQLException {
|
public MixTaxonomyMappingData mapRow(final ResultSet rs, @SuppressWarnings("unused") final int rowNum) throws SQLException {
|
||||||
final String identifier = rs.getString("identifier");
|
final String identifier = rs.getString("identifier");
|
||||||
final String config = rs.getString("config");
|
final String config = rs.getString("config");
|
||||||
return new MixTaxonomyMappingData(identifier, config);
|
return new MixTaxonomyMappingData().setIdentifier(identifier).setConfig(config);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-1
@@ -55,7 +55,8 @@ public class MixTaxonomyReadPlatformServiceImpl implements MixTaxonomyReadPlatfo
|
|||||||
final String dimension = rs.getString("dimension");
|
final String dimension = rs.getString("dimension");
|
||||||
final Integer type = rs.getInt("type");
|
final Integer type = rs.getInt("type");
|
||||||
final String desc = rs.getString("description");
|
final String desc = rs.getString("description");
|
||||||
return new MixTaxonomyData(id, name, namespace, dimension, type, desc);
|
return new MixTaxonomyData().setId(id).setName(name).setNamespace(namespace).setDimension(dimension).setType(type)
|
||||||
|
.setDescription(desc);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -49,7 +49,7 @@ public class NamespaceReadPlatformServiceImpl implements NamespaceReadPlatformSe
|
|||||||
final long id = rs.getLong("id");
|
final long id = rs.getLong("id");
|
||||||
final String prefix = rs.getString("prefix");
|
final String prefix = rs.getString("prefix");
|
||||||
final String url = rs.getString("url");
|
final String url = rs.getString("url");
|
||||||
return new NamespaceData(id, prefix, url);
|
return new NamespaceData().setId(id).setPrefix(prefix).setUrl(url);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -100,7 +100,7 @@ public class XBRLBuilder {
|
|||||||
final NamespaceData ns = this.readNamespaceService.retrieveNamespaceByPrefix(prefix);
|
final NamespaceData ns = this.readNamespaceService.retrieveNamespaceByPrefix(prefix);
|
||||||
if (ns != null) {
|
if (ns != null) {
|
||||||
|
|
||||||
this.root.addNamespace(prefix, ns.url());
|
this.root.addNamespace(prefix, ns.getUrl());
|
||||||
}
|
}
|
||||||
qname = prefix + ":" + taxonomy.getName();
|
qname = prefix + ":" + taxonomy.getName();
|
||||||
|
|
||||||
@@ -115,12 +115,16 @@ public class XBRLBuilder {
|
|||||||
final List<String> dims = Splitter.on(':').splitToList(dimension);
|
final List<String> dims = Splitter.on(':').splitToList(dimension);
|
||||||
|
|
||||||
if (dims.size() == 2) {
|
if (dims.size() == 2) {
|
||||||
context = new ContextData(dims.get(0), dims.get(1), taxonomy.getType());
|
context = new ContextData().setDimensionType(dims.get(0)).setDimension(dims.get(1)).setPeriodType(
|
||||||
|
taxonomy.getType().equals(MixTaxonomyData.BALANCESHEET) || taxonomy.getType().equals(MixTaxonomyData.PORTFOLIO) ? 0
|
||||||
|
: 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (context == null) {
|
if (context == null) {
|
||||||
context = new ContextData(null, null, taxonomy.getType());
|
context = new ContextData().setPeriodType(
|
||||||
|
taxonomy.getType().equals(MixTaxonomyData.BALANCESHEET) || taxonomy.getType().equals(MixTaxonomyData.PORTFOLIO) ? 0
|
||||||
|
: 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!this.contextMap.containsKey(context)) {
|
if (!this.contextMap.containsKey(context)) {
|
||||||
|
|||||||
+1
-1
@@ -66,7 +66,7 @@ public class XBRLResultServiceImpl implements XBRLResultService {
|
|||||||
if (config == null || config.size() == 0) {
|
if (config == null || config.size() == 0) {
|
||||||
throw new XBRLMappingInvalidException("Mapping is empty");
|
throw new XBRLMappingInvalidException("Mapping is empty");
|
||||||
}
|
}
|
||||||
return new XBRLData(config, startDate, endDate, currency);
|
return new XBRLData().setResultMap(config).setStartDate(startDate).setEndDate(endDate).setCurrency(currency);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
|
|||||||
+1
-1
@@ -57,7 +57,7 @@ public class MixXbrlBuilderStepDefinitions implements En {
|
|||||||
(String start, String end, String currency, String taxonomy, String sample) -> {
|
(String start, String end, String currency, String taxonomy, String sample) -> {
|
||||||
readNamespaceService = mock(NamespaceReadPlatformServiceImpl.class);
|
readNamespaceService = mock(NamespaceReadPlatformServiceImpl.class);
|
||||||
lenient().when(this.readNamespaceService.retrieveNamespaceByPrefix(ArgumentMatchers.anyString()))
|
lenient().when(this.readNamespaceService.retrieveNamespaceByPrefix(ArgumentMatchers.anyString()))
|
||||||
.thenReturn(new NamespaceData(1L, "mockedprefix", "mockedurl"));
|
.thenReturn(new NamespaceData().setId(1L).setPrefix("mockedprefix").setUrl("mockedurl"));
|
||||||
|
|
||||||
this.start = Date.valueOf(start);
|
this.start = Date.valueOf(start);
|
||||||
this.end = Date.valueOf(end);
|
this.end = Date.valueOf(end);
|
||||||
|
|||||||
Reference in New Issue
Block a user