You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@fineract.apache.org by nikpawar89 <gi...@git.apache.org> on 2016/08/11 03:20:07 UTC

[GitHub] incubator-fineract pull request #202: address_module

GitHub user nikpawar89 opened a pull request:

    https://github.com/apache/incubator-fineract/pull/202

    address_module

    

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/nikpawar89/incubator-fineract addressModulefinal

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/incubator-fineract/pull/202.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #202
    
----
commit 29672df043f733e644f9c5fd1286202dead182d8
Author: nikpawar89 <ni...@yahoo.in>
Date:   2016-07-19T06:08:06Z

    address_module

----


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-fineract pull request #202: address_module

Posted by nazeer1100126 <gi...@git.apache.org>.
Github user nazeer1100126 commented on a diff in the pull request:

    https://github.com/apache/incubator-fineract/pull/202#discussion_r74370875
  
    --- Diff: fineract-provider/src/main/java/org/apache/fineract/portfolio/address/service/AddressWritePlatformServiceImpl.java ---
    @@ -0,0 +1,279 @@
    +/**
    + * 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.portfolio.address.service;
    +
    +import java.math.BigDecimal;
    +
    +import org.apache.fineract.infrastructure.codes.domain.CodeValue;
    +import org.apache.fineract.infrastructure.codes.domain.CodeValueRepository;
    +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.infrastructure.security.service.PlatformSecurityContext;
    +import org.apache.fineract.portfolio.address.domain.Address;
    +import org.apache.fineract.portfolio.address.domain.AddressRepository;
    +import org.apache.fineract.portfolio.address.serialization.AddressCommandFromApiJsonDeserializer;
    +import org.apache.fineract.portfolio.client.domain.Client;
    +import org.apache.fineract.portfolio.client.domain.ClientAddress;
    +import org.apache.fineract.portfolio.client.domain.ClientAddressRepository;
    +import org.apache.fineract.portfolio.client.domain.ClientAddressRepositoryWrapper;
    +import org.apache.fineract.portfolio.client.domain.ClientRepository;
    +import org.springframework.beans.factory.annotation.Autowired;
    +import org.springframework.stereotype.Service;
    +
    +import com.google.gson.JsonArray;
    +import com.google.gson.JsonObject;
    +
    +@Service
    +public class AddressWritePlatformServiceImpl implements AddressWritePlatformService {
    +	private final PlatformSecurityContext context;
    +	private final CodeValueRepository codeValueRepository;
    +	private final ClientAddressRepository clientAddressRepository;
    +	private final ClientRepository clientRepository;
    +	private final AddressRepository addressRepository;
    +	private final ClientAddressRepositoryWrapper clientAddressRepositoryWrapper;
    +	private final AddressCommandFromApiJsonDeserializer fromApiJsonDeserializer;
    +
    +	@Autowired
    +	public AddressWritePlatformServiceImpl(final PlatformSecurityContext context,
    +			final CodeValueRepository codeValueRepository, final ClientAddressRepository clientAddressRepository,
    +			final ClientRepository clientRepository, final AddressRepository addressRepository,
    +			final ClientAddressRepositoryWrapper clientAddressRepositoryWrapper,
    +			final AddressCommandFromApiJsonDeserializer fromApiJsonDeserializer) {
    +		this.context = context;
    +		this.codeValueRepository = codeValueRepository;
    +		this.clientAddressRepository = clientAddressRepository;
    +		this.clientRepository = clientRepository;
    +		this.addressRepository = addressRepository;
    +		this.clientAddressRepositoryWrapper = clientAddressRepositoryWrapper;
    +		this.fromApiJsonDeserializer = fromApiJsonDeserializer;
    +
    +	}
    +
    +	@Override
    +	public CommandProcessingResult addClientAddress(final Long clientId, final Long addressTypeId,
    +			final JsonCommand command) {
    +		CodeValue stateIdobj = null;
    +		CodeValue countryIdObj = null;
    +		long stateId;
    +		long countryId;
    +
    +		this.context.authenticatedUser();
    +		this.fromApiJsonDeserializer.validateForCreate(command.json(), true);
    +		
    +		System.out.println("request "+command.json());
    +
    +		if (command.longValueOfParameterNamed("stateProvinceId") != null) {
    +			stateId = command.longValueOfParameterNamed("stateProvinceId");
    +			stateIdobj = this.codeValueRepository.getOne(stateId);
    +		}
    +
    +		if (command.longValueOfParameterNamed("countryId") != null) {
    +			countryId = command.longValueOfParameterNamed("countryId");
    +			countryIdObj = this.codeValueRepository.getOne(countryId);
    +		}
    +
    +		final CodeValue addressTypeIdObj = this.codeValueRepository.getOne(addressTypeId);
    +
    +		final Address add = Address.fromJson(command, stateIdobj, countryIdObj);
    +		this.addressRepository.save(add);
    +		final Long addressid = add.getId();
    +		final Address addobj = this.addressRepository.getOne(addressid);
    +
    +		final Client client = this.clientRepository.getOne(clientId);
    +		final boolean isActive = command.booleanPrimitiveValueOfParameterNamed("isActive");
    +
    +		final ClientAddress clientAddressobj = ClientAddress.fromJson(isActive, client, addobj, addressTypeIdObj);
    +		this.clientAddressRepository.save(clientAddressobj);
    +
    +		return new CommandProcessingResultBuilder().withCommandId(command.commandId())
    +				.withEntityId(clientAddressobj.getId()).build();
    +	}
    +
    +	// following method is used for adding multiple addresses while creating new
    +	// client
    +
    +	@Override
    +	public CommandProcessingResult addNewClientAddress(final Client client, final JsonCommand command) {
    +		CodeValue stateIdobj = null;
    +		CodeValue countryIdObj = null;
    +		long stateId;
    +		long countryId;
    +
    +		final JsonArray addressArray = command.arrayOfParameterNamed("address");
    +
    +		for (int i = 0; i < addressArray.size(); i++) {
    +			final JsonObject jsonObject = addressArray.get(i).getAsJsonObject();
    +
    +			// validate every address
    +			this.fromApiJsonDeserializer.validateForCreate(jsonObject.toString(), true);
    +
    +			if (jsonObject.get("stateProvinceId") != null) {
    +				stateId = jsonObject.get("stateProvinceId").getAsLong();
    +				stateIdobj = this.codeValueRepository.getOne(stateId);
    +			}
    +
    +			if (jsonObject.get("countryId") != null) {
    +				countryId = jsonObject.get("countryId").getAsLong();
    +				countryIdObj = this.codeValueRepository.getOne(countryId);
    +			}
    +
    +			final long addressTypeId = jsonObject.get("addressTypeId").getAsLong();
    +			final CodeValue addressTypeIdObj = this.codeValueRepository.getOne(addressTypeId);
    +
    +			final Address add = Address.fromJsonObject(jsonObject, stateIdobj, countryIdObj);
    +			this.addressRepository.save(add);
    +			final Long addressid = add.getId();
    +			final Address addobj = this.addressRepository.getOne(addressid);
    +
    +			final boolean isActive = jsonObject.get("isActive").getAsBoolean();
    +
    +			final ClientAddress clientAddressobj = ClientAddress.fromJson(isActive, client, addobj, addressTypeIdObj);
    +			this.clientAddressRepository.save(clientAddressobj);
    +
    +		}
    +		final long typ = 1;
    +		return new CommandProcessingResultBuilder().withCommandId(command.commandId()).withEntityId(typ).build();
    +	}
    +
    +	@Override
    +	public CommandProcessingResult updateClientAddress(final Long clientId, final JsonCommand command) {
    +		this.context.authenticatedUser();
    +
    +		long stateId;
    +
    +		long countryId;
    +
    +		CodeValue stateIdobj;
    +
    +		CodeValue countryIdObj;
    +
    +		boolean is_address_update = false;
    +
    +		this.fromApiJsonDeserializer.validateForUpdate(command.json());
    +
    +		final long addressId = command.longValueOfParameterNamed("addressId");
    +
    +		final ClientAddress clientAddressObj = this.clientAddressRepositoryWrapper
    +				.findOneByClientIdAndAddressId(clientId, addressId);
    +
    +		final Address addobj = this.addressRepository.getOne(addressId);
    +
    +		if (!(command.stringValueOfParameterNamed("street").isEmpty())) {
    --- End diff --
    
    If street is not passed in json, NullPointerException will thrown. This is same for all parameters in update json.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-fineract pull request #202: address_module

Posted by nazeer1100126 <gi...@git.apache.org>.
Github user nazeer1100126 commented on a diff in the pull request:

    https://github.com/apache/incubator-fineract/pull/202#discussion_r74383696
  
    --- Diff: fineract-provider/src/main/java/org/apache/fineract/portfolio/client/service/ClientWritePlatformServiceJpaRepositoryImpl.java ---
    @@ -90,734 +92,803 @@
     @Service
     public class ClientWritePlatformServiceJpaRepositoryImpl implements ClientWritePlatformService {
     
    -    private final static Logger logger = LoggerFactory.getLogger(ClientWritePlatformServiceJpaRepositoryImpl.class);
    -
    -    private final PlatformSecurityContext context;
    -    private final ClientRepositoryWrapper clientRepository;
    -    private final ClientNonPersonRepositoryWrapper clientNonPersonRepository;
    -    private final OfficeRepository officeRepository;
    -    private final NoteRepository noteRepository;
    -    private final GroupRepository groupRepository;
    -    private final ClientDataValidator fromApiJsonDeserializer;
    -    private final AccountNumberGenerator accountNumberGenerator;
    -    private final StaffRepositoryWrapper staffRepository;
    -    private final CodeValueRepositoryWrapper codeValueRepository;
    -    private final LoanRepository loanRepository;
    -    private final SavingsAccountRepository savingsRepository;
    -    private final SavingsProductRepository savingsProductRepository;
    -    private final SavingsApplicationProcessWritePlatformService savingsApplicationProcessWritePlatformService;
    -    private final CommandProcessingService commandProcessingService;
    -    private final ConfigurationDomainService configurationDomainService;
    -    private final AccountNumberFormatRepositoryWrapper accountNumberFormatRepository;
    +	private final static Logger logger = LoggerFactory.getLogger(ClientWritePlatformServiceJpaRepositoryImpl.class);
    +
    +	private final PlatformSecurityContext context;
    +	private final ClientRepositoryWrapper clientRepository;
    +	private final ClientNonPersonRepositoryWrapper clientNonPersonRepository;
    +	private final OfficeRepository officeRepository;
    +	private final NoteRepository noteRepository;
    +	private final GroupRepository groupRepository;
    +	private final ClientDataValidator fromApiJsonDeserializer;
    +	private final AccountNumberGenerator accountNumberGenerator;
    +	private final StaffRepositoryWrapper staffRepository;
    +	private final CodeValueRepositoryWrapper codeValueRepository;
    +	private final LoanRepository loanRepository;
    +	private final SavingsAccountRepository savingsRepository;
    +	private final SavingsProductRepository savingsProductRepository;
    +	private final SavingsApplicationProcessWritePlatformService savingsApplicationProcessWritePlatformService;
    +	private final CommandProcessingService commandProcessingService;
    +	private final ConfigurationDomainService configurationDomainService;
    +	private final AccountNumberFormatRepositoryWrapper accountNumberFormatRepository;
     	private final FromJsonHelper fromApiJsonHelper;
    +	private final ConfigurationReadPlatformService configurationReadPlatformService;
    +	private final AddressWritePlatformService addressWritePlatformService;
    +
    +	@Autowired
    --- End diff --
    
    This file is having formatting issue. Import mifosx preferences and format it


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-fineract pull request #202: address_module

Posted by nazeer1100126 <gi...@git.apache.org>.
Github user nazeer1100126 commented on a diff in the pull request:

    https://github.com/apache/incubator-fineract/pull/202#discussion_r74370723
  
    --- Diff: fineract-provider/src/main/java/org/apache/fineract/portfolio/address/service/AddressWritePlatformServiceImpl.java ---
    @@ -0,0 +1,279 @@
    +/**
    + * 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.portfolio.address.service;
    +
    +import java.math.BigDecimal;
    +
    +import org.apache.fineract.infrastructure.codes.domain.CodeValue;
    +import org.apache.fineract.infrastructure.codes.domain.CodeValueRepository;
    +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.infrastructure.security.service.PlatformSecurityContext;
    +import org.apache.fineract.portfolio.address.domain.Address;
    +import org.apache.fineract.portfolio.address.domain.AddressRepository;
    +import org.apache.fineract.portfolio.address.serialization.AddressCommandFromApiJsonDeserializer;
    +import org.apache.fineract.portfolio.client.domain.Client;
    +import org.apache.fineract.portfolio.client.domain.ClientAddress;
    +import org.apache.fineract.portfolio.client.domain.ClientAddressRepository;
    +import org.apache.fineract.portfolio.client.domain.ClientAddressRepositoryWrapper;
    +import org.apache.fineract.portfolio.client.domain.ClientRepository;
    +import org.springframework.beans.factory.annotation.Autowired;
    +import org.springframework.stereotype.Service;
    +
    +import com.google.gson.JsonArray;
    +import com.google.gson.JsonObject;
    +
    +@Service
    +public class AddressWritePlatformServiceImpl implements AddressWritePlatformService {
    +	private final PlatformSecurityContext context;
    +	private final CodeValueRepository codeValueRepository;
    +	private final ClientAddressRepository clientAddressRepository;
    +	private final ClientRepository clientRepository;
    +	private final AddressRepository addressRepository;
    +	private final ClientAddressRepositoryWrapper clientAddressRepositoryWrapper;
    +	private final AddressCommandFromApiJsonDeserializer fromApiJsonDeserializer;
    +
    +	@Autowired
    +	public AddressWritePlatformServiceImpl(final PlatformSecurityContext context,
    +			final CodeValueRepository codeValueRepository, final ClientAddressRepository clientAddressRepository,
    +			final ClientRepository clientRepository, final AddressRepository addressRepository,
    +			final ClientAddressRepositoryWrapper clientAddressRepositoryWrapper,
    +			final AddressCommandFromApiJsonDeserializer fromApiJsonDeserializer) {
    +		this.context = context;
    +		this.codeValueRepository = codeValueRepository;
    +		this.clientAddressRepository = clientAddressRepository;
    +		this.clientRepository = clientRepository;
    +		this.addressRepository = addressRepository;
    +		this.clientAddressRepositoryWrapper = clientAddressRepositoryWrapper;
    +		this.fromApiJsonDeserializer = fromApiJsonDeserializer;
    +
    +	}
    +
    +	@Override
    +	public CommandProcessingResult addClientAddress(final Long clientId, final Long addressTypeId,
    +			final JsonCommand command) {
    +		CodeValue stateIdobj = null;
    +		CodeValue countryIdObj = null;
    +		long stateId;
    +		long countryId;
    +
    +		this.context.authenticatedUser();
    +		this.fromApiJsonDeserializer.validateForCreate(command.json(), true);
    +		
    +		System.out.println("request "+command.json());
    +
    +		if (command.longValueOfParameterNamed("stateProvinceId") != null) {
    +			stateId = command.longValueOfParameterNamed("stateProvinceId");
    +			stateIdobj = this.codeValueRepository.getOne(stateId);
    +		}
    +
    +		if (command.longValueOfParameterNamed("countryId") != null) {
    +			countryId = command.longValueOfParameterNamed("countryId");
    +			countryIdObj = this.codeValueRepository.getOne(countryId);
    +		}
    +
    +		final CodeValue addressTypeIdObj = this.codeValueRepository.getOne(addressTypeId);
    +
    +		final Address add = Address.fromJson(command, stateIdobj, countryIdObj);
    +		this.addressRepository.save(add);
    +		final Long addressid = add.getId();
    +		final Address addobj = this.addressRepository.getOne(addressid);
    +
    +		final Client client = this.clientRepository.getOne(clientId);
    +		final boolean isActive = command.booleanPrimitiveValueOfParameterNamed("isActive");
    +
    +		final ClientAddress clientAddressobj = ClientAddress.fromJson(isActive, client, addobj, addressTypeIdObj);
    +		this.clientAddressRepository.save(clientAddressobj);
    +
    +		return new CommandProcessingResultBuilder().withCommandId(command.commandId())
    +				.withEntityId(clientAddressobj.getId()).build();
    +	}
    +
    +	// following method is used for adding multiple addresses while creating new
    +	// client
    +
    +	@Override
    +	public CommandProcessingResult addNewClientAddress(final Client client, final JsonCommand command) {
    +		CodeValue stateIdobj = null;
    +		CodeValue countryIdObj = null;
    +		long stateId;
    +		long countryId;
    +
    +		final JsonArray addressArray = command.arrayOfParameterNamed("address");
    +
    +		for (int i = 0; i < addressArray.size(); i++) {
    +			final JsonObject jsonObject = addressArray.get(i).getAsJsonObject();
    +
    +			// validate every address
    +			this.fromApiJsonDeserializer.validateForCreate(jsonObject.toString(), true);
    +
    +			if (jsonObject.get("stateProvinceId") != null) {
    +				stateId = jsonObject.get("stateProvinceId").getAsLong();
    +				stateIdobj = this.codeValueRepository.getOne(stateId);
    +			}
    +
    +			if (jsonObject.get("countryId") != null) {
    +				countryId = jsonObject.get("countryId").getAsLong();
    +				countryIdObj = this.codeValueRepository.getOne(countryId);
    +			}
    +
    +			final long addressTypeId = jsonObject.get("addressTypeId").getAsLong();
    +			final CodeValue addressTypeIdObj = this.codeValueRepository.getOne(addressTypeId);
    +
    +			final Address add = Address.fromJsonObject(jsonObject, stateIdobj, countryIdObj);
    +			this.addressRepository.save(add);
    +			final Long addressid = add.getId();
    +			final Address addobj = this.addressRepository.getOne(addressid);
    +
    +			final boolean isActive = jsonObject.get("isActive").getAsBoolean();
    +
    +			final ClientAddress clientAddressobj = ClientAddress.fromJson(isActive, client, addobj, addressTypeIdObj);
    +			this.clientAddressRepository.save(clientAddressobj);
    +
    +		}
    +		final long typ = 1;
    --- End diff --
    
    why typ is hard coded to 1 and why you are always returning entity id with 1 ?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-fineract pull request #202: address_module

Posted by nikpawar89 <gi...@git.apache.org>.
Github user nikpawar89 closed the pull request at:

    https://github.com/apache/incubator-fineract/pull/202


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---