FINERACT-2245: New command processing - mix taxonomy
This commit is contained in:
committed by
Aleksandar Vidakovic
parent
fe98aa6a58
commit
ae3e2a6343
+28
@@ -297,6 +297,34 @@ public class SecurityConfig {
|
||||
.hasAnyAuthority(ALL_FUNCTIONS, ALL_FUNCTIONS_WRITE, "UPDATE_PAYMENTTYPE")
|
||||
.requestMatchers(API_MATCHER.matcher(HttpMethod.POST, "/api/*/paymenttypes"))
|
||||
.hasAnyAuthority(ALL_FUNCTIONS, ALL_FUNCTIONS_WRITE, "DELETE_PAYMENTTYPE")
|
||||
// mix: taxonomy
|
||||
.requestMatchers(API_MATCHER.matcher(HttpMethod.GET, "/api/*/mixtaxonomy/*"))
|
||||
.hasAnyAuthority(ALL_FUNCTIONS, ALL_FUNCTIONS_READ, "READ_MIX_TAXONOMY")
|
||||
.requestMatchers(API_MATCHER.matcher(HttpMethod.POST, "/api/*/mixtaxonomy/*"))
|
||||
.hasAnyAuthority(ALL_FUNCTIONS, ALL_FUNCTIONS_WRITE, "CREATE_MIX_TAXONOMY")
|
||||
.requestMatchers(API_MATCHER.matcher(HttpMethod.PUT, "/api/*/mixtaxonomy/*"))
|
||||
.hasAnyAuthority(ALL_FUNCTIONS, ALL_FUNCTIONS_WRITE, "UPDATE_MIX_TAXONOMY")
|
||||
.requestMatchers(API_MATCHER.matcher(HttpMethod.DELETE, "/api/*/mixtaxonomy/*"))
|
||||
.hasAnyAuthority(ALL_FUNCTIONS, ALL_FUNCTIONS_WRITE, "DELETE_MIX_TAXONOMY")
|
||||
// mix: mapping
|
||||
.requestMatchers(API_MATCHER.matcher(HttpMethod.GET, "/api/*/mixmapping/*"))
|
||||
.hasAnyAuthority(ALL_FUNCTIONS, ALL_FUNCTIONS_READ, "READ_MIX_MAPPING")
|
||||
.requestMatchers(API_MATCHER.matcher(HttpMethod.POST, "/api/*/mixmapping/*"))
|
||||
.hasAnyAuthority(ALL_FUNCTIONS, ALL_FUNCTIONS_WRITE, "CREATE_MIX_MAPPING")
|
||||
.requestMatchers(API_MATCHER.matcher(HttpMethod.PUT, "/api/*/mixmapping/*"))
|
||||
// TODO: "UPDATE_XBRLMAPPING" is the legacy permission name; we should rename for consistency
|
||||
.hasAnyAuthority(ALL_FUNCTIONS, ALL_FUNCTIONS_WRITE, "UPDATE_MIX_MAPPING", "UPDATE_XBRLMAPPING")
|
||||
.requestMatchers(API_MATCHER.matcher(HttpMethod.DELETE, "/api/*/mixmapping/*"))
|
||||
.hasAnyAuthority(ALL_FUNCTIONS, ALL_FUNCTIONS_WRITE, "DELETE_MIX_MAPPING")
|
||||
// mix: report
|
||||
.requestMatchers(API_MATCHER.matcher(HttpMethod.GET, "/api/*/mixreport/*"))
|
||||
.hasAnyAuthority(ALL_FUNCTIONS, ALL_FUNCTIONS_READ, "READ_MIX_REPORT")
|
||||
.requestMatchers(API_MATCHER.matcher(HttpMethod.POST, "/api/*/mixreport/*"))
|
||||
.hasAnyAuthority(ALL_FUNCTIONS, ALL_FUNCTIONS_WRITE, "CREATE_MIX_REPORT")
|
||||
.requestMatchers(API_MATCHER.matcher(HttpMethod.PUT, "/api/*/mixreport/*"))
|
||||
.hasAnyAuthority(ALL_FUNCTIONS, ALL_FUNCTIONS_WRITE, "UPDATE_MIX_REPORT")
|
||||
.requestMatchers(API_MATCHER.matcher(HttpMethod.DELETE, "/api/*/mixreport/*"))
|
||||
.hasAnyAuthority(ALL_FUNCTIONS, ALL_FUNCTIONS_WRITE, "DELETE_MIX_REPORT")
|
||||
|
||||
.requestMatchers(API_MATCHER.matcher(HttpMethod.POST, "/api/*/twofactor/validate")).fullyAuthenticated()
|
||||
.requestMatchers(API_MATCHER.matcher("/api/*/twofactor")).fullyAuthenticated()
|
||||
|
||||
@@ -1,52 +0,0 @@
|
||||
/**
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you 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 org.apache.fineract.mix.api;
|
||||
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.ws.rs.GET;
|
||||
import jakarta.ws.rs.Path;
|
||||
import jakarta.ws.rs.Produces;
|
||||
import jakarta.ws.rs.QueryParam;
|
||||
import jakarta.ws.rs.core.MediaType;
|
||||
import java.sql.Date;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.apache.fineract.mix.data.XBRLData;
|
||||
import org.apache.fineract.mix.service.XBRLBuilder;
|
||||
import org.apache.fineract.mix.service.XBRLResultService;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Path("/v1/mixreport")
|
||||
@Component
|
||||
@Tag(name = "Mix Report", description = "")
|
||||
@RequiredArgsConstructor
|
||||
public class MixReportApiResource {
|
||||
|
||||
private final XBRLResultService xbrlResultService;
|
||||
private final XBRLBuilder xbrlBuilder;
|
||||
|
||||
@GET
|
||||
@Produces({ MediaType.APPLICATION_XML })
|
||||
public String retrieveXBRLReport(@QueryParam("startDate") final Date startDate, @QueryParam("endDate") final Date endDate,
|
||||
@QueryParam("currency") final String currency) {
|
||||
|
||||
final XBRLData data = this.xbrlResultService.getXBRLResult(startDate, endDate, currency);
|
||||
|
||||
return this.xbrlBuilder.build(data);
|
||||
}
|
||||
}
|
||||
-53
@@ -1,53 +0,0 @@
|
||||
/**
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you 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 org.apache.fineract.mix.api;
|
||||
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.ws.rs.Consumes;
|
||||
import jakarta.ws.rs.GET;
|
||||
import jakarta.ws.rs.Path;
|
||||
import jakarta.ws.rs.Produces;
|
||||
import jakarta.ws.rs.core.MediaType;
|
||||
import java.util.List;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.apache.fineract.infrastructure.security.service.PlatformSecurityContext;
|
||||
import org.apache.fineract.mix.data.MixTaxonomyData;
|
||||
import org.apache.fineract.mix.service.MixTaxonomyReadPlatformService;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Path("/v1/mixtaxonomy")
|
||||
@Component
|
||||
@Tag(name = "Mix Taxonomy", description = "")
|
||||
@RequiredArgsConstructor
|
||||
public class MixTaxonomyApiResource {
|
||||
|
||||
private final PlatformSecurityContext context;
|
||||
private final MixTaxonomyReadPlatformService readTaxonomyService;
|
||||
|
||||
@GET
|
||||
@Consumes({ MediaType.APPLICATION_JSON })
|
||||
@Produces({ MediaType.APPLICATION_JSON })
|
||||
public List<MixTaxonomyData> retrieveAll() {
|
||||
|
||||
// FIXME - KW - no check for permission to read mix taxonomy data.
|
||||
this.context.authenticatedUser();
|
||||
|
||||
return readTaxonomyService.retrieveAll();
|
||||
}
|
||||
}
|
||||
-73
@@ -1,73 +0,0 @@
|
||||
/**
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you 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 org.apache.fineract.mix.api;
|
||||
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.ws.rs.Consumes;
|
||||
import jakarta.ws.rs.GET;
|
||||
import jakarta.ws.rs.PUT;
|
||||
import jakarta.ws.rs.Path;
|
||||
import jakarta.ws.rs.Produces;
|
||||
import jakarta.ws.rs.core.MediaType;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.apache.fineract.commands.domain.CommandWrapper;
|
||||
import org.apache.fineract.commands.service.CommandWrapperBuilder;
|
||||
import org.apache.fineract.commands.service.PortfolioCommandSourceWritePlatformService;
|
||||
import org.apache.fineract.infrastructure.core.data.CommandProcessingResult;
|
||||
import org.apache.fineract.infrastructure.core.serialization.ToApiJsonSerializer;
|
||||
import org.apache.fineract.infrastructure.security.service.PlatformSecurityContext;
|
||||
import org.apache.fineract.mix.data.MixTaxonomyMappingData;
|
||||
import org.apache.fineract.mix.data.MixTaxonomyRequest;
|
||||
import org.apache.fineract.mix.service.MixTaxonomyMappingReadPlatformService;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Path("/v1/mixmapping")
|
||||
@Component
|
||||
@Tag(name = "Mix Mapping", description = "")
|
||||
@RequiredArgsConstructor
|
||||
public class MixTaxonomyMappingApiResource {
|
||||
|
||||
private final PlatformSecurityContext context;
|
||||
private final ToApiJsonSerializer<MixTaxonomyMappingData> toApiJsonSerializer;
|
||||
private final MixTaxonomyMappingReadPlatformService readTaxonomyMappingService;
|
||||
private final PortfolioCommandSourceWritePlatformService commandsSourceWritePlatformService;
|
||||
|
||||
@GET
|
||||
@Consumes({ MediaType.APPLICATION_JSON })
|
||||
@Produces({ MediaType.APPLICATION_JSON })
|
||||
public MixTaxonomyMappingData retrieveTaxonomyMapping() {
|
||||
this.context.authenticatedUser();
|
||||
return this.readTaxonomyMappingService.retrieveTaxonomyMapping();
|
||||
}
|
||||
|
||||
@PUT
|
||||
@Consumes({ MediaType.APPLICATION_JSON })
|
||||
@Produces({ MediaType.APPLICATION_JSON })
|
||||
public String updateTaxonomyMapping(final MixTaxonomyRequest mixTaxonomyRequest) {
|
||||
// TODO support multiple configuration file loading
|
||||
final Long mappingId = (long) 1;
|
||||
final CommandWrapper commandRequest = new CommandWrapperBuilder().updateTaxonomyMapping(mappingId)
|
||||
.withJson(toApiJsonSerializer.serialize(mixTaxonomyRequest)).build();
|
||||
|
||||
final CommandProcessingResult result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest);
|
||||
|
||||
return this.toApiJsonSerializer.serialize(result);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,79 +0,0 @@
|
||||
/**
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you 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 org.apache.fineract.mix.data;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@Accessors(chain = true)
|
||||
public class ContextData {
|
||||
|
||||
private String dimensionType;
|
||||
private String dimension;
|
||||
private Integer periodType;
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + (this.dimension == null ? 0 : this.dimension.hashCode());
|
||||
result = prime * result + (this.dimensionType == null ? 0 : this.dimensionType.hashCode());
|
||||
result = prime * result + (this.periodType == null ? 0 : this.periodType.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(final Object obj) {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
if (obj == null) {
|
||||
return false;
|
||||
}
|
||||
if (!(obj instanceof ContextData)) {
|
||||
return false;
|
||||
}
|
||||
final ContextData other = (ContextData) obj;
|
||||
if (this.dimension == null) {
|
||||
if (other.dimension != null) {
|
||||
return false;
|
||||
}
|
||||
} else if (!this.dimension.equals(other.dimension)) {
|
||||
return false;
|
||||
}
|
||||
if (this.dimensionType == null) {
|
||||
if (other.dimensionType != null) {
|
||||
return false;
|
||||
}
|
||||
} else if (!this.dimensionType.equals(other.dimensionType)) {
|
||||
return false;
|
||||
}
|
||||
if (this.periodType == null) {
|
||||
if (other.periodType != null) {
|
||||
return false;
|
||||
}
|
||||
} else if (!this.periodType.equals(other.periodType)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -1,49 +0,0 @@
|
||||
/**
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you 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 org.apache.fineract.mix.data;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@Accessors(chain = true)
|
||||
public class MixTaxonomyData {
|
||||
|
||||
public static final Integer PORTFOLIO = 0;
|
||||
public static final Integer BALANCESHEET = 1;
|
||||
public static final Integer INCOME = 2;
|
||||
public static final Integer EXPENSE = 3;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private Long id;
|
||||
private String name;
|
||||
private String namespace;
|
||||
private String dimension;
|
||||
private Integer type;
|
||||
@SuppressWarnings("unused")
|
||||
private String description;
|
||||
|
||||
@JsonIgnore
|
||||
public boolean isPortfolio() {
|
||||
return this.type == 5;
|
||||
}
|
||||
}
|
||||
-34
@@ -1,34 +0,0 @@
|
||||
/**
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you 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 org.apache.fineract.mix.data;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@Accessors(chain = true)
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class MixTaxonomyMappingData {
|
||||
|
||||
private String identifier;
|
||||
private String config;
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
/**
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you 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 org.apache.fineract.mix.data;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class MixTaxonomyRequest implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private String identifier;
|
||||
private String config;
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
/**
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you 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 org.apache.fineract.mix.data;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@Accessors(chain = true)
|
||||
public class NamespaceData {
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private Long id;
|
||||
@SuppressWarnings("unused")
|
||||
private String prefix;
|
||||
private String url;
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
/**
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you 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 org.apache.fineract.mix.data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.Date;
|
||||
import java.util.HashMap;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@Accessors(chain = true)
|
||||
public class XBRLData {
|
||||
|
||||
private HashMap<MixTaxonomyData, BigDecimal> resultMap;
|
||||
private Date startDate;
|
||||
private Date endDate;
|
||||
private String currency;
|
||||
}
|
||||
-70
@@ -1,70 +0,0 @@
|
||||
/**
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you 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 org.apache.fineract.mix.domain;
|
||||
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.Table;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.fineract.infrastructure.core.api.JsonCommand;
|
||||
import org.apache.fineract.infrastructure.core.domain.AbstractPersistableCustom;
|
||||
|
||||
@Entity
|
||||
@Table(name = "mix_taxonomy_mapping")
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@Accessors(chain = true)
|
||||
public final class MixTaxonomyMapping extends AbstractPersistableCustom<Long> {
|
||||
|
||||
@Column(name = "identifier")
|
||||
private String identifier;
|
||||
|
||||
@Column(name = "config")
|
||||
private String config;
|
||||
|
||||
@Column(name = "currency")
|
||||
private String currency;
|
||||
|
||||
private MixTaxonomyMapping(final String identifier, final String config, final String currency) {
|
||||
this.identifier = StringUtils.defaultIfEmpty(identifier, null);
|
||||
this.config = StringUtils.defaultIfEmpty(config, null);
|
||||
this.currency = StringUtils.defaultIfEmpty(currency, null);
|
||||
}
|
||||
|
||||
public static MixTaxonomyMapping fromJson(final JsonCommand command) {
|
||||
final String identifier = command.stringValueOfParameterNamed("identifier");
|
||||
final String config = command.stringValueOfParameterNamed("config");
|
||||
final String currency = command.stringValueOfParameterNamed("currency");
|
||||
return new MixTaxonomyMapping(identifier, config, currency);
|
||||
}
|
||||
|
||||
public void update(final JsonCommand command) {
|
||||
|
||||
this.identifier = command.stringValueOfParameterNamed("identifier");
|
||||
this.config = command.stringValueOfParameterNamed("config");
|
||||
this.currency = command.stringValueOfParameterNamed("currency");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
-27
@@ -1,27 +0,0 @@
|
||||
/**
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you 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 org.apache.fineract.mix.domain;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||
|
||||
public interface MixTaxonomyMappingRepository
|
||||
extends JpaRepository<MixTaxonomyMapping, Long>, JpaSpecificationExecutor<MixTaxonomyMapping> {
|
||||
|
||||
}
|
||||
-29
@@ -1,29 +0,0 @@
|
||||
/**
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you 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 org.apache.fineract.mix.exception;
|
||||
|
||||
import org.apache.fineract.infrastructure.core.exception.AbstractPlatformDomainRuleException;
|
||||
|
||||
public class XBRLMappingInvalidException extends AbstractPlatformDomainRuleException {
|
||||
|
||||
public XBRLMappingInvalidException(final String msg) {
|
||||
super("error.msg.xbrl.report.mapping.invalid.id", "Mapping does not exist", msg);
|
||||
}
|
||||
|
||||
}
|
||||
-47
@@ -1,47 +0,0 @@
|
||||
/**
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you 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 org.apache.fineract.mix.handler;
|
||||
|
||||
import org.apache.fineract.commands.annotation.CommandType;
|
||||
import org.apache.fineract.commands.handler.NewCommandSourceHandler;
|
||||
import org.apache.fineract.infrastructure.core.api.JsonCommand;
|
||||
import org.apache.fineract.infrastructure.core.data.CommandProcessingResult;
|
||||
import org.apache.fineract.mix.service.MixTaxonomyMappingWritePlatformService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@Service
|
||||
@CommandType(entity = "XBRLMAPPING", action = "UPDATE")
|
||||
public class UpdateTaxonomyMappingCommandHandler implements NewCommandSourceHandler {
|
||||
|
||||
private final MixTaxonomyMappingWritePlatformService writeTaxonomyService;
|
||||
|
||||
@Autowired
|
||||
public UpdateTaxonomyMappingCommandHandler(final MixTaxonomyMappingWritePlatformService writeTaxonomyService) {
|
||||
this.writeTaxonomyService = writeTaxonomyService;
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public CommandProcessingResult processCommand(final JsonCommand command) {
|
||||
return this.writeTaxonomyService.updateMapping(command.entityId(), command);
|
||||
}
|
||||
|
||||
}
|
||||
-26
@@ -1,26 +0,0 @@
|
||||
/**
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you 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 org.apache.fineract.mix.service;
|
||||
|
||||
import org.apache.fineract.mix.data.MixTaxonomyMappingData;
|
||||
|
||||
public interface MixTaxonomyMappingReadPlatformService {
|
||||
|
||||
MixTaxonomyMappingData retrieveTaxonomyMapping();
|
||||
}
|
||||
-60
@@ -1,60 +0,0 @@
|
||||
/**
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you 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 org.apache.fineract.mix.service;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.apache.fineract.mix.data.MixTaxonomyMappingData;
|
||||
import org.springframework.dao.EmptyResultDataAccessException;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.jdbc.core.RowMapper;
|
||||
|
||||
@RequiredArgsConstructor
|
||||
public class MixTaxonomyMappingReadPlatformServiceImpl implements MixTaxonomyMappingReadPlatformService {
|
||||
|
||||
private final JdbcTemplate jdbcTemplate;
|
||||
|
||||
private static final class TaxonomyMappingMapper implements RowMapper<MixTaxonomyMappingData> {
|
||||
|
||||
public String schema() {
|
||||
return "identifier, config " + "from mix_taxonomy_mapping";
|
||||
}
|
||||
|
||||
@Override
|
||||
public MixTaxonomyMappingData mapRow(final ResultSet rs, @SuppressWarnings("unused") final int rowNum) throws SQLException {
|
||||
final String identifier = rs.getString("identifier");
|
||||
final String config = rs.getString("config");
|
||||
return new MixTaxonomyMappingData().setIdentifier(identifier).setConfig(config);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public MixTaxonomyMappingData retrieveTaxonomyMapping() {
|
||||
try {
|
||||
final TaxonomyMappingMapper rm = new TaxonomyMappingMapper();
|
||||
final String sqlString = "select " + rm.schema();
|
||||
return this.jdbcTemplate.queryForObject(sqlString, rm); // NOSONAR
|
||||
} catch (final EmptyResultDataAccessException e) {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
-27
@@ -1,27 +0,0 @@
|
||||
/**
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you 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 org.apache.fineract.mix.service;
|
||||
|
||||
import org.apache.fineract.infrastructure.core.api.JsonCommand;
|
||||
import org.apache.fineract.infrastructure.core.data.CommandProcessingResult;
|
||||
|
||||
public interface MixTaxonomyMappingWritePlatformService {
|
||||
|
||||
CommandProcessingResult updateMapping(Long mappingId, JsonCommand command);
|
||||
}
|
||||
-55
@@ -1,55 +0,0 @@
|
||||
/**
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you 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 org.apache.fineract.mix.service;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.apache.fineract.infrastructure.core.api.JsonCommand;
|
||||
import org.apache.fineract.infrastructure.core.data.CommandProcessingResult;
|
||||
import org.apache.fineract.infrastructure.core.data.CommandProcessingResultBuilder;
|
||||
import org.apache.fineract.mix.domain.MixTaxonomyMapping;
|
||||
import org.apache.fineract.mix.domain.MixTaxonomyMappingRepository;
|
||||
import org.springframework.dao.DataIntegrityViolationException;
|
||||
import org.springframework.orm.jpa.JpaSystemException;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@RequiredArgsConstructor
|
||||
public class MixTaxonomyMappingWritePlatformServiceImpl implements MixTaxonomyMappingWritePlatformService {
|
||||
|
||||
private final MixTaxonomyMappingRepository mappingRepository;
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public CommandProcessingResult updateMapping(final Long mappingId, final JsonCommand command) {
|
||||
try {
|
||||
MixTaxonomyMapping mapping = this.mappingRepository.findById(mappingId).orElse(null);
|
||||
if (mapping == null) {
|
||||
mapping = MixTaxonomyMapping.fromJson(command);
|
||||
} else {
|
||||
mapping.update(command);
|
||||
}
|
||||
|
||||
this.mappingRepository.saveAndFlush(mapping);
|
||||
|
||||
return new CommandProcessingResultBuilder().withCommandId(command.commandId()).withEntityId(mapping.getId()).build();
|
||||
|
||||
} catch (final JpaSystemException | DataIntegrityViolationException dve) {
|
||||
return CommandProcessingResult.empty();
|
||||
}
|
||||
}
|
||||
}
|
||||
-29
@@ -1,29 +0,0 @@
|
||||
/**
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you 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 org.apache.fineract.mix.service;
|
||||
|
||||
import java.util.List;
|
||||
import org.apache.fineract.mix.data.MixTaxonomyData;
|
||||
|
||||
public interface MixTaxonomyReadPlatformService {
|
||||
|
||||
List<MixTaxonomyData> retrieveAll();
|
||||
|
||||
MixTaxonomyData retrieveOne(Long id);
|
||||
}
|
||||
-71
@@ -1,71 +0,0 @@
|
||||
/**
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you 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 org.apache.fineract.mix.service;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.List;
|
||||
import org.apache.fineract.mix.data.MixTaxonomyData;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.jdbc.core.RowMapper;
|
||||
|
||||
public class MixTaxonomyReadPlatformServiceImpl implements MixTaxonomyReadPlatformService {
|
||||
|
||||
private final JdbcTemplate jdbcTemplate;
|
||||
private final MixTaxonomyMapper mixTaxonomyMapper;
|
||||
|
||||
public MixTaxonomyReadPlatformServiceImpl(final JdbcTemplate jdbcTemplate) {
|
||||
this.jdbcTemplate = jdbcTemplate;
|
||||
this.mixTaxonomyMapper = new MixTaxonomyMapper();
|
||||
}
|
||||
|
||||
private static final class MixTaxonomyMapper implements RowMapper<MixTaxonomyData> {
|
||||
|
||||
public String schema() {
|
||||
return "tx.id as id, name, dimension, type, description, prefix "
|
||||
+ "from mix_taxonomy tx left join mix_xbrl_namespace xn on tx.namespace_id=xn.id";
|
||||
}
|
||||
|
||||
@Override
|
||||
public MixTaxonomyData mapRow(final ResultSet rs, @SuppressWarnings("unused") final int rowNum) throws SQLException {
|
||||
final long id = rs.getLong("id");
|
||||
final String name = rs.getString("name");
|
||||
final String namespace = rs.getString("prefix");
|
||||
|
||||
final String dimension = rs.getString("dimension");
|
||||
final Integer type = rs.getInt("type");
|
||||
final String desc = rs.getString("description");
|
||||
return new MixTaxonomyData().setId(id).setName(name).setNamespace(namespace).setDimension(dimension).setType(type)
|
||||
.setDescription(desc);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<MixTaxonomyData> retrieveAll() {
|
||||
final String sql = "select " + this.mixTaxonomyMapper.schema() + " order by id";
|
||||
return this.jdbcTemplate.query(sql, this.mixTaxonomyMapper); // NOSONAR
|
||||
}
|
||||
|
||||
@Override
|
||||
public MixTaxonomyData retrieveOne(final Long id) {
|
||||
final String sql = "select " + this.mixTaxonomyMapper.schema() + " where tx.id = ? ";
|
||||
return this.jdbcTemplate.queryForObject(sql, this.mixTaxonomyMapper, new Object[] { id }); // NOSONAR
|
||||
}
|
||||
}
|
||||
-28
@@ -1,28 +0,0 @@
|
||||
/**
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you 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 org.apache.fineract.mix.service;
|
||||
|
||||
import org.apache.fineract.mix.data.NamespaceData;
|
||||
|
||||
public interface NamespaceReadPlatformService {
|
||||
|
||||
NamespaceData retrieveNamespaceById(Long id);
|
||||
|
||||
NamespaceData retrieveNamespaceByPrefix(String prefix);
|
||||
}
|
||||
-66
@@ -1,66 +0,0 @@
|
||||
/**
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you 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 org.apache.fineract.mix.service;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import org.apache.fineract.mix.data.NamespaceData;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.jdbc.core.RowMapper;
|
||||
|
||||
public class NamespaceReadPlatformServiceImpl implements NamespaceReadPlatformService {
|
||||
|
||||
private final JdbcTemplate jdbcTemplate;
|
||||
private final NamespaceMapper namespaceMapper;
|
||||
|
||||
public NamespaceReadPlatformServiceImpl(final JdbcTemplate jdbcTemplate) {
|
||||
this.jdbcTemplate = jdbcTemplate;
|
||||
this.namespaceMapper = new NamespaceMapper();
|
||||
}
|
||||
|
||||
private static final class NamespaceMapper implements RowMapper<NamespaceData> {
|
||||
|
||||
public String schema() {
|
||||
return "select id, prefix, url " + "from mix_xbrl_namespace";
|
||||
}
|
||||
|
||||
@Override
|
||||
public NamespaceData mapRow(final ResultSet rs, @SuppressWarnings("unused") final int rowNum) throws SQLException {
|
||||
final long id = rs.getLong("id");
|
||||
final String prefix = rs.getString("prefix");
|
||||
final String url = rs.getString("url");
|
||||
return new NamespaceData().setId(id).setPrefix(prefix).setUrl(url);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public NamespaceData retrieveNamespaceById(final Long id) {
|
||||
final String sql = this.namespaceMapper.schema() + " where id= ? ";
|
||||
|
||||
return this.jdbcTemplate.queryForObject(sql, this.namespaceMapper, new Object[] { id }); // NOSONAR
|
||||
}
|
||||
|
||||
@Override
|
||||
public NamespaceData retrieveNamespaceByPrefix(final String prefix) {
|
||||
final String sql = this.namespaceMapper.schema() + " where prefix = ? ";
|
||||
|
||||
return this.jdbcTemplate.queryForObject(sql, this.namespaceMapper, new Object[] { prefix }); // NOSONAR
|
||||
}
|
||||
}
|
||||
@@ -1,203 +0,0 @@
|
||||
/**
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you 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 org.apache.fineract.mix.service;
|
||||
|
||||
import com.google.common.base.Splitter;
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.Date;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import org.apache.fineract.mix.data.ContextData;
|
||||
import org.apache.fineract.mix.data.MixTaxonomyData;
|
||||
import org.apache.fineract.mix.data.NamespaceData;
|
||||
import org.apache.fineract.mix.data.XBRLData;
|
||||
import org.apache.fineract.mix.exception.XBRLMappingInvalidException;
|
||||
import org.dom4j.Document;
|
||||
import org.dom4j.DocumentHelper;
|
||||
import org.dom4j.Element;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class XBRLBuilder {
|
||||
|
||||
private static final String SCHEME_URL = "http://www.themix.org";
|
||||
private static final String IDENTIFIER = "000000";
|
||||
private static final String UNITID_PURE = "Unit1";
|
||||
private static final String UNITID_CUR = "Unit2";
|
||||
|
||||
@Autowired
|
||||
private NamespaceReadPlatformService readNamespaceService;
|
||||
|
||||
public String build(final XBRLData xbrlData) {
|
||||
return this.build(xbrlData.getResultMap(), xbrlData.getStartDate(), xbrlData.getEndDate(), xbrlData.getCurrency());
|
||||
}
|
||||
|
||||
public String build(final Map<MixTaxonomyData, BigDecimal> map, final Date startDate, final Date endDate, final String currency) {
|
||||
Integer instantScenarioCounter = 0;
|
||||
Integer durationScenarioCounter = 0;
|
||||
Map<ContextData, String> contextMap = new HashMap<>();
|
||||
final Document doc = DocumentHelper.createDocument();
|
||||
Element root = doc.addElement("xbrl");
|
||||
|
||||
root.addElement("schemaRef").addNamespace("link",
|
||||
"http://www.themix.org/sites/default/files/Taxonomy2010/dct/dc-all_2010-08-31.xsd");
|
||||
|
||||
for (final Map.Entry<MixTaxonomyData, BigDecimal> entry : map.entrySet()) {
|
||||
final MixTaxonomyData taxonomy = entry.getKey();
|
||||
final BigDecimal value = entry.getValue();
|
||||
addTaxonomy(root, taxonomy, value, startDate, endDate, instantScenarioCounter, durationScenarioCounter, contextMap);
|
||||
|
||||
}
|
||||
|
||||
addContexts(root, startDate, endDate, contextMap);
|
||||
addCurrencyUnit(root, currency);
|
||||
addNumberUnit(root);
|
||||
|
||||
doc.setXMLEncoding("UTF-8");
|
||||
|
||||
return doc.asXML();
|
||||
}
|
||||
|
||||
private Element addTaxonomy(final Element rootElement, final MixTaxonomyData taxonomy, final BigDecimal value, final Date startDate,
|
||||
final Date endDate, Integer instantScenarioCounter, Integer durationScenarioCounter,
|
||||
final Map<ContextData, String> contextMap) {
|
||||
|
||||
// throw an error is start / endate is null
|
||||
if (startDate == null || endDate == null) {
|
||||
throw new XBRLMappingInvalidException("start date and end date should not be null");
|
||||
}
|
||||
|
||||
final String prefix = taxonomy.getNamespace();
|
||||
String qname = taxonomy.getName();
|
||||
if (prefix != null && !prefix.isEmpty()) {
|
||||
final NamespaceData ns = this.readNamespaceService.retrieveNamespaceByPrefix(prefix);
|
||||
if (ns != null) {
|
||||
|
||||
rootElement.addNamespace(prefix, ns.getUrl());
|
||||
}
|
||||
qname = prefix + ":" + taxonomy.getName();
|
||||
|
||||
}
|
||||
final Element xmlElement = rootElement.addElement(qname);
|
||||
|
||||
final String dimension = taxonomy.getDimension();
|
||||
final SimpleDateFormat timeFormat = new SimpleDateFormat("MM_dd_yyyy");
|
||||
|
||||
ContextData context = null;
|
||||
if (dimension != null) {
|
||||
final List<String> dims = Splitter.on(':').splitToList(dimension);
|
||||
|
||||
if (dims.size() == 2) {
|
||||
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) {
|
||||
context = new ContextData().setPeriodType(
|
||||
taxonomy.getType().equals(MixTaxonomyData.BALANCESHEET) || taxonomy.getType().equals(MixTaxonomyData.PORTFOLIO) ? 0
|
||||
: 1);
|
||||
}
|
||||
|
||||
if (!contextMap.containsKey(context)) {
|
||||
|
||||
final String startDateStr = timeFormat.format(startDate);
|
||||
final String endDateStr = timeFormat.format(endDate);
|
||||
instantScenarioCounter += 1;
|
||||
durationScenarioCounter += 1;
|
||||
final String contextRefID = context.getPeriodType() == 0 ? "As_Of_" + endDateStr + instantScenarioCounter
|
||||
: "Duration_" + startDateStr + "_To_" + endDateStr + durationScenarioCounter;
|
||||
|
||||
contextMap.put(context, contextRefID);
|
||||
}
|
||||
|
||||
xmlElement.addAttribute("contextRef", contextMap.get(context));
|
||||
xmlElement.addAttribute("unitRef", getUnitRef(taxonomy));
|
||||
xmlElement.addAttribute("decimals", getNumberOfDecimalPlaces(value).toString());
|
||||
|
||||
// add the child
|
||||
xmlElement.addText(value.toPlainString());
|
||||
|
||||
return xmlElement;
|
||||
}
|
||||
|
||||
private String getUnitRef(final MixTaxonomyData tx) {
|
||||
return tx.isPortfolio() ? UNITID_PURE : UNITID_CUR;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the generic number unit
|
||||
*/
|
||||
private void addNumberUnit(final Element root) {
|
||||
final Element numerUnit = root.addElement("unit");
|
||||
numerUnit.addAttribute("id", UNITID_PURE);
|
||||
final Element measure = numerUnit.addElement("measure");
|
||||
measure.addText("xbrli:pure");
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the currency unit to the document
|
||||
*
|
||||
* @param currencyCode
|
||||
*/
|
||||
private void addCurrencyUnit(final Element root, final String currencyCode) {
|
||||
final Element currencyUnitElement = root.addElement("unit");
|
||||
currencyUnitElement.addAttribute("id", UNITID_CUR);
|
||||
final Element measure = currencyUnitElement.addElement("measure");
|
||||
measure.addText("iso4217:" + currencyCode);
|
||||
|
||||
}
|
||||
|
||||
private void addContexts(final Element root, final Date startDate, final Date endDate, final Map<ContextData, String> contextMap) {
|
||||
final SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
|
||||
for (final Map.Entry<ContextData, String> entry : contextMap.entrySet()) {
|
||||
final ContextData context = entry.getKey();
|
||||
final Element contextElement = root.addElement("context");
|
||||
contextElement.addAttribute("id", entry.getValue());
|
||||
contextElement.addElement("entity").addElement("identifier").addAttribute("scheme", SCHEME_URL).addText(IDENTIFIER);
|
||||
|
||||
final Element periodElement = contextElement.addElement("period");
|
||||
|
||||
if (context.getPeriodType() == 0) {
|
||||
periodElement.addElement("instant").addText(format.format(endDate));
|
||||
} else {
|
||||
periodElement.addElement("startDate").addText(format.format(startDate));
|
||||
periodElement.addElement("endDate").addText(format.format(endDate));
|
||||
}
|
||||
|
||||
final String dimension = context.getDimension();
|
||||
final String dimType = context.getDimensionType();
|
||||
if (dimType != null && dimension != null) {
|
||||
contextElement.addElement("scenario").addElement("explicitMember").addAttribute("dimension", dimType).addText(dimension);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private Integer getNumberOfDecimalPlaces(final BigDecimal bigDecimal) {
|
||||
final String string = bigDecimal.stripTrailingZeros().toPlainString();
|
||||
final int index = string.indexOf(".");
|
||||
return index < 0 ? 0 : string.length() - index - 1;
|
||||
}
|
||||
}
|
||||
-28
@@ -1,28 +0,0 @@
|
||||
/**
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you 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 org.apache.fineract.mix.service;
|
||||
|
||||
import java.sql.Date;
|
||||
import org.apache.fineract.mix.data.XBRLData;
|
||||
|
||||
public interface XBRLResultService {
|
||||
|
||||
XBRLData getXBRLResult(Date startDate, Date endDate, String currency);
|
||||
|
||||
}
|
||||
-189
@@ -1,189 +0,0 @@
|
||||
/**
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you 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 org.apache.fineract.mix.service;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.Date;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import javax.script.ScriptEngine;
|
||||
import javax.script.ScriptEngineManager;
|
||||
import javax.script.ScriptException;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.fineract.mix.data.MixTaxonomyData;
|
||||
import org.apache.fineract.mix.data.MixTaxonomyMappingData;
|
||||
import org.apache.fineract.mix.data.XBRLData;
|
||||
import org.apache.fineract.mix.exception.XBRLMappingInvalidException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.jdbc.support.rowset.SqlRowSet;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
@Slf4j
|
||||
public class XBRLResultServiceImpl implements XBRLResultService {
|
||||
|
||||
private static final ScriptEngine SCRIPT_ENGINE = new ScriptEngineManager().getEngineByName("JavaScript");
|
||||
|
||||
private final MixTaxonomyMappingReadPlatformService readTaxonomyMappingService;
|
||||
private final MixTaxonomyReadPlatformService readTaxonomyService;
|
||||
private final JdbcTemplate jdbcTemplate;
|
||||
|
||||
@Autowired
|
||||
public XBRLResultServiceImpl(final JdbcTemplate jdbcTemplate, final MixTaxonomyMappingReadPlatformService readTaxonomyMappingService,
|
||||
final MixTaxonomyReadPlatformService readTaxonomyService) {
|
||||
this.readTaxonomyMappingService = readTaxonomyMappingService;
|
||||
this.readTaxonomyService = readTaxonomyService;
|
||||
this.jdbcTemplate = jdbcTemplate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public XBRLData getXBRLResult(final Date startDate, final Date endDate, final String currency) {
|
||||
|
||||
final HashMap<MixTaxonomyData, BigDecimal> config = retrieveTaxonomyConfig(startDate, endDate);
|
||||
if (config == null || config.size() == 0) {
|
||||
throw new XBRLMappingInvalidException("Mapping is empty");
|
||||
}
|
||||
return new XBRLData().setResultMap(config).setStartDate(startDate).setEndDate(endDate).setCurrency(currency);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private HashMap<MixTaxonomyData, BigDecimal> retrieveTaxonomyConfig(final Date startDate, final Date endDate) {
|
||||
final MixTaxonomyMappingData taxonomyMapping = this.readTaxonomyMappingService.retrieveTaxonomyMapping();
|
||||
if (taxonomyMapping == null) {
|
||||
return null;
|
||||
}
|
||||
final String config = taxonomyMapping.getConfig();
|
||||
if (config != null) {
|
||||
// <taxonomyId, mapping>
|
||||
HashMap<String, String> configMap = new HashMap<>();
|
||||
configMap = new Gson().fromJson(config, configMap.getClass());
|
||||
if (configMap == null) {
|
||||
return null;
|
||||
}
|
||||
// <taxonomyId, value>
|
||||
final HashMap<MixTaxonomyData, BigDecimal> resultMap = new HashMap<>();
|
||||
Map<String, BigDecimal> accountBalanceMap = setupBalanceMap(getAccountSql(startDate, endDate));
|
||||
for (final Map.Entry<String, String> entry : configMap.entrySet()) {
|
||||
final BigDecimal value = processMappingString(accountBalanceMap, entry.getValue());
|
||||
final MixTaxonomyData taxonomy = this.readTaxonomyService.retrieveOne(Long.parseLong(entry.getKey()));
|
||||
resultMap.put(taxonomy, value);
|
||||
|
||||
}
|
||||
return resultMap;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private String getAccountSql(final Date startDate, final Date endDate) {
|
||||
return "select debits.glcode as 'glcode', debits.name as 'name', coalesce(debits.debitamount,0)-coalesce(credits.creditamount,0)) as 'balance' "
|
||||
+ "from (select acc_gl_account.gl_code as 'glcode',name,sum(amount) as 'debitamount' "
|
||||
+ "from acc_gl_journal_entry,acc_gl_account " + "where acc_gl_account.id = acc_gl_journal_entry.account_id "
|
||||
+ "and acc_gl_journal_entry.type_enum=2 " + "and acc_gl_journal_entry.entry_date <= " + endDate
|
||||
+ " and acc_gl_journal_entry.entry_date > " + startDate
|
||||
// "and (acc_gl_journal_entry.office_id=${branch} or
|
||||
// ${branch}=1) "
|
||||
// +
|
||||
+ " group by glcode " + "order by glcode) debits " + "LEFT OUTER JOIN "
|
||||
+ "(select acc_gl_account.gl_code as 'glcode',name,sum(amount) as 'creditamount' "
|
||||
+ "from acc_gl_journal_entry,acc_gl_account " + "where acc_gl_account.id = acc_gl_journal_entry.account_id "
|
||||
+ "and acc_gl_journal_entry.type_enum=1 " + "and acc_gl_journal_entry.entry_date <= " + endDate
|
||||
+ " and acc_gl_journal_entry.entry_date > " + startDate
|
||||
// "and (acc_gl_journal_entry.office_id=${branch} or
|
||||
// ${branch}=1) "
|
||||
// +
|
||||
+ " group by glcode " + "order by glcode) credits " + "on debits.glcode=credits.glcode " + "union "
|
||||
+ "select credits.glcode as 'glcode', credits.name as 'name', coalesce(debits.debitamount,0)-coalesce(credits.creditamount,0)) as 'balance' "
|
||||
+ "from (select acc_gl_account.gl_code as 'glcode',name,sum(amount) as 'debitamount' "
|
||||
+ "from acc_gl_journal_entry,acc_gl_account " + "where acc_gl_account.id = acc_gl_journal_entry.account_id "
|
||||
+ "and acc_gl_journal_entry.type_enum=2 " + "and acc_gl_journal_entry.entry_date <= " + endDate
|
||||
+ " and acc_gl_journal_entry.entry_date > " + startDate
|
||||
// "and (acc_gl_journal_entry.office_id=${branch} or
|
||||
// ${branch}=1) "
|
||||
// +
|
||||
+ " group by glcode " + "order by glcode) debits " + "RIGHT OUTER JOIN "
|
||||
+ "(select acc_gl_account.gl_code as 'glcode',name,sum(amount) as 'creditamount' "
|
||||
+ "from acc_gl_journal_entry,acc_gl_account " + "where acc_gl_account.id = acc_gl_journal_entry.account_id "
|
||||
+ "and acc_gl_journal_entry.type_enum=1 " + "and acc_gl_journal_entry.entry_date <= " + endDate
|
||||
+ " and acc_gl_journal_entry.entry_date > " + startDate
|
||||
// "and (acc_gl_journal_entry.office_id=${branch} or
|
||||
// ${branch}=1) "
|
||||
// +
|
||||
+ " group by name, glcode " + "order by glcode) credits " + "on debits.glcode=credits.glcode;";
|
||||
}
|
||||
|
||||
private Map<String, BigDecimal> setupBalanceMap(final String sql) {
|
||||
Map<String, BigDecimal> accountBalanceMap = new HashMap<>();
|
||||
|
||||
final SqlRowSet rs = this.jdbcTemplate.queryForRowSet(sql);
|
||||
while (rs.next()) {
|
||||
accountBalanceMap.put(rs.getString("glcode"), rs.getBigDecimal("balance"));
|
||||
}
|
||||
|
||||
return accountBalanceMap;
|
||||
}
|
||||
|
||||
// Calculate Taxonomy value from expression
|
||||
private BigDecimal processMappingString(Map<String, BigDecimal> accountBalanceMap, String mappingString) {
|
||||
final List<String> glCodes = getGLCodes(mappingString);
|
||||
for (final String glcode : glCodes) {
|
||||
|
||||
final BigDecimal balance = accountBalanceMap.get(glcode);
|
||||
mappingString = mappingString.replaceAll("\\{" + glcode + "\\}", balance != null ? balance.toString() : "0");
|
||||
}
|
||||
|
||||
// evaluate the expression
|
||||
float eval = 0f;
|
||||
try {
|
||||
final Number value = (Number) SCRIPT_ENGINE.eval(mappingString);
|
||||
if (value != null) {
|
||||
eval = value.floatValue();
|
||||
}
|
||||
} catch (final ScriptException e) {
|
||||
log.error("Problem occurred in processMappingString function", e);
|
||||
throw new IllegalArgumentException(e.getMessage(), e);
|
||||
}
|
||||
|
||||
return BigDecimal.valueOf(eval);
|
||||
}
|
||||
|
||||
public List<String> getGLCodes(final String template) {
|
||||
|
||||
final ArrayList<String> placeholders = new ArrayList<>();
|
||||
|
||||
if (template != null) {
|
||||
|
||||
final Pattern p = Pattern.compile("\\{(.*?)\\}");
|
||||
final Matcher m = p.matcher(template);
|
||||
|
||||
while (m.find()) { // find next match
|
||||
final String match = m.group();
|
||||
final String code = match.substring(1, match.length() - 1);
|
||||
placeholders.add(code);
|
||||
}
|
||||
|
||||
}
|
||||
return placeholders;
|
||||
}
|
||||
}
|
||||
@@ -1,62 +0,0 @@
|
||||
/**
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you 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 org.apache.fineract.mix.starter;
|
||||
|
||||
import org.apache.fineract.mix.domain.MixTaxonomyMappingRepository;
|
||||
import org.apache.fineract.mix.service.MixTaxonomyMappingReadPlatformService;
|
||||
import org.apache.fineract.mix.service.MixTaxonomyMappingReadPlatformServiceImpl;
|
||||
import org.apache.fineract.mix.service.MixTaxonomyMappingWritePlatformService;
|
||||
import org.apache.fineract.mix.service.MixTaxonomyMappingWritePlatformServiceImpl;
|
||||
import org.apache.fineract.mix.service.MixTaxonomyReadPlatformService;
|
||||
import org.apache.fineract.mix.service.MixTaxonomyReadPlatformServiceImpl;
|
||||
import org.apache.fineract.mix.service.NamespaceReadPlatformService;
|
||||
import org.apache.fineract.mix.service.NamespaceReadPlatformServiceImpl;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
|
||||
@Configuration
|
||||
public class MixConfiguration {
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean(MixTaxonomyMappingReadPlatformService.class)
|
||||
public MixTaxonomyMappingReadPlatformService mixTaxonomyMappingReadPlatformService(JdbcTemplate jdbcTemplate) {
|
||||
return new MixTaxonomyMappingReadPlatformServiceImpl(jdbcTemplate);
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean(MixTaxonomyMappingWritePlatformService.class)
|
||||
public MixTaxonomyMappingWritePlatformService mixTaxonomyMappingWritePlatformService(MixTaxonomyMappingRepository mappingRepository) {
|
||||
return new MixTaxonomyMappingWritePlatformServiceImpl(mappingRepository);
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean(MixTaxonomyReadPlatformService.class)
|
||||
public MixTaxonomyReadPlatformService mixTaxonomyReadPlatformService(JdbcTemplate jdbcTemplate) {
|
||||
return new MixTaxonomyReadPlatformServiceImpl(jdbcTemplate);
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean(NamespaceReadPlatformService.class)
|
||||
public NamespaceReadPlatformService namespaceReadPlatformService(JdbcTemplate jdbcTemplate) {
|
||||
return new NamespaceReadPlatformServiceImpl(jdbcTemplate);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -597,6 +597,14 @@ resilience4j.retry.instances.commandPaymentTypeDelete.enable-exponential-backoff
|
||||
resilience4j.retry.instances.commandPaymentTypeDelete.exponential-backoff-multiplier=${FINERACT_COMMAND_PAYMENT_TYPE_DELETE_RETRY_EXPONENTIAL_BACKOFF_MULTIPLIER:2}
|
||||
resilience4j.retry.instances.commandPaymentTypeDelete.retryExceptions=${FINERACT_COMMAND_PAYMENT_TYPE_DELETE_RETRY_EXCEPTIONS:org.springframework.dao.ConcurrencyFailureException,org.eclipse.persistence.exceptions.OptimisticLockException,jakarta.persistence.OptimisticLockException,org.springframework.orm.jpa.JpaOptimisticLockingFailureException}
|
||||
|
||||
# mix taxonomy
|
||||
|
||||
resilience4j.retry.instances.commandMixTaxonomyMappingUpdate.max-attempts=${FINERACT_COMMAND_MIX_TAXONOMY_MAPPING_UPDATE_RETRY_MAX_ATTEMPTS:3}
|
||||
resilience4j.retry.instances.commandMixTaxonomyMappingUpdate.wait-duration=${FINERACT_COMMAND_MIX_TAXONOMY_MAPPING_UPDATE_RETRY_WAIT_DURATION:1s}
|
||||
resilience4j.retry.instances.commandMixTaxonomyMappingUpdate.enable-exponential-backoff=${FINERACT_COMMAND_MIX_TAXONOMY_MAPPING_UPDATE_RETRY_ENABLE_EXPONENTIAL_BACKOFF:true}
|
||||
resilience4j.retry.instances.commandMixTaxonomyMappingUpdate.exponential-backoff-multiplier=${FINERACT_COMMAND_MIX_TAXONOMY_MAPPING_UPDATE_RETRY_EXPONENTIAL_BACKOFF_MULTIPLIER:2}
|
||||
resilience4j.retry.instances.commandMixTaxonomyMappingUpdate.retryExceptions=${FINERACT_COMMAND_MIX_TAXONOMY_MAPPING_UPDATE_RETRY_EXCEPTIONS:org.springframework.dao.ConcurrencyFailureException,org.eclipse.persistence.exceptions.OptimisticLockException,jakarta.persistence.OptimisticLockException,org.springframework.orm.jpa.JpaOptimisticLockingFailureException}
|
||||
|
||||
# command
|
||||
|
||||
fineract.command.enabled=true
|
||||
|
||||
-3
@@ -279,9 +279,6 @@
|
||||
<!-- AdHocQuery -->
|
||||
<class>org.apache.fineract.adhocquery.domain.AdHoc</class>
|
||||
|
||||
<!-- Mix -->
|
||||
<class>org.apache.fineract.mix.domain.MixTaxonomyMapping</class>
|
||||
|
||||
<!-- COB (Chunk of Business) -->
|
||||
<class>org.apache.fineract.cob.domain.LoanAccountLock</class>
|
||||
<class>org.apache.fineract.cob.domain.BatchBusinessStep</class>
|
||||
|
||||
+9
-7
@@ -29,18 +29,18 @@ import java.nio.charset.StandardCharsets;
|
||||
import java.sql.Date;
|
||||
import java.util.HashMap;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.fineract.mix.data.MixReportXBRLNamespaceData;
|
||||
import org.apache.fineract.mix.data.MixTaxonomyData;
|
||||
import org.apache.fineract.mix.data.NamespaceData;
|
||||
import org.apache.fineract.mix.service.NamespaceReadPlatformServiceImpl;
|
||||
import org.apache.fineract.mix.service.XBRLBuilder;
|
||||
import org.apache.fineract.mix.service.MixReportXBRLBuilder;
|
||||
import org.apache.fineract.mix.service.MixReportXBRLNamespaceReadServiceImpl;
|
||||
import org.apache.fineract.template.service.TemplateServiceStepDefinitions;
|
||||
import org.mockito.ArgumentMatchers;
|
||||
|
||||
public class MixXbrlBuilderStepDefinitions implements En {
|
||||
|
||||
private NamespaceReadPlatformServiceImpl readNamespaceService;
|
||||
private MixReportXBRLNamespaceReadServiceImpl readNamespaceService;
|
||||
|
||||
private final XBRLBuilder xbrlBuilder = new XBRLBuilder();
|
||||
private MixReportXBRLBuilder xbrlBuilder;
|
||||
|
||||
private Date start;
|
||||
|
||||
@@ -55,9 +55,11 @@ public class MixXbrlBuilderStepDefinitions implements En {
|
||||
public MixXbrlBuilderStepDefinitions() {
|
||||
Given("/^The XBRL input parameters start date (.*), end date (.*), currency (.*), taxonomy (.*) and sample (.*)$/",
|
||||
(String start, String end, String currency, String taxonomy, String sample) -> {
|
||||
readNamespaceService = mock(NamespaceReadPlatformServiceImpl.class);
|
||||
readNamespaceService = mock(MixReportXBRLNamespaceReadServiceImpl.class);
|
||||
lenient().when(this.readNamespaceService.retrieveNamespaceByPrefix(ArgumentMatchers.anyString()))
|
||||
.thenReturn(new NamespaceData().setId(1L).setPrefix("mockedprefix").setUrl("mockedurl"));
|
||||
.thenReturn(new MixReportXBRLNamespaceData().setId(1L).setPrefix("mockedprefix").setUrl("mockedurl"));
|
||||
|
||||
xbrlBuilder = new MixReportXBRLBuilder(readNamespaceService);
|
||||
|
||||
this.start = Date.valueOf(start);
|
||||
this.end = Date.valueOf(end);
|
||||
|
||||
+3
-3
@@ -23,13 +23,13 @@ import static org.mockito.Mockito.mock;
|
||||
|
||||
import io.cucumber.java8.En;
|
||||
import java.util.List;
|
||||
import org.apache.fineract.mix.service.XBRLResultServiceImpl;
|
||||
import org.apache.fineract.mix.service.MixReportXBRLResultServiceImpl;
|
||||
import org.assertj.core.util.Arrays;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
|
||||
public class MixXbrlTaxonomyStepDefinitions implements En {
|
||||
|
||||
private XBRLResultServiceImpl readService;
|
||||
private MixReportXBRLResultServiceImpl readService;
|
||||
|
||||
private String template;
|
||||
|
||||
@@ -37,7 +37,7 @@ public class MixXbrlTaxonomyStepDefinitions implements En {
|
||||
|
||||
public MixXbrlTaxonomyStepDefinitions() {
|
||||
Given("/^A XBRL template (.*)$/", (String template) -> {
|
||||
this.readService = new XBRLResultServiceImpl(mock(JdbcTemplate.class), null, null);
|
||||
this.readService = new MixReportXBRLResultServiceImpl(mock(JdbcTemplate.class), null, null);
|
||||
this.template = template;
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user