You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@fineract.apache.org by iamrupok <gi...@git.apache.org> on 2017/06/14 14:26:18 UTC

[GitHub] fineract pull request #369: Adhoc query API

GitHub user iamrupok opened a pull request:

    https://github.com/apache/fineract/pull/369

    Adhoc query API

    please review the change and marge

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

    $ git pull https://github.com/iamrupok/fineract develop

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

    https://github.com/apache/fineract/pull/369.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 #369
    
----
commit 6ecfe4dde96dd61ff2d8453c15e7a85a1036a5d3
Author: Kasem <ia...@gmail.com>
Date:   2017-06-14T14:24:08Z

    Adhoc query API

----


---
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] fineract pull request #369: Adhoc query API

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

    https://github.com/apache/fineract/pull/369#discussion_r122122388
  
    --- Diff: fineract-provider/src/main/java/org/apache/fineract/adhocquery/service/AdHocScheduledJobRunnerServiceImpl.java ---
    @@ -0,0 +1,80 @@
    +/**
    + * 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.adhocquery.service;
    +
    +import java.util.Collection;
    +
    +import org.apache.fineract.adhocquery.data.AdHocData;
    +import org.apache.fineract.adhocquery.service.AdHocReadPlatformService;
    +import org.apache.fineract.infrastructure.core.service.RoutingDataSourceServiceFactory;
    +import org.apache.fineract.infrastructure.core.service.ThreadLocalContextUtil;
    +import org.apache.fineract.infrastructure.jobs.annotation.CronTarget;
    +import org.apache.fineract.infrastructure.jobs.service.JobName;
    +import org.slf4j.Logger;
    +import org.slf4j.LoggerFactory;
    +import org.springframework.beans.factory.annotation.Autowired;
    +import org.springframework.jdbc.core.JdbcTemplate;
    +import org.springframework.stereotype.Service;
    +import org.springframework.transaction.annotation.Transactional;
    +
    +@Service(value = "adHocScheduledJobRunnerService")
    +public class AdHocScheduledJobRunnerServiceImpl implements AdHocScheduledJobRunnerService {
    +
    +    private final static Logger logger = LoggerFactory.getLogger(AdHocScheduledJobRunnerServiceImpl.class);
    +    private final RoutingDataSourceServiceFactory dataSourceServiceFactory;
    +    private final AdHocReadPlatformService adHocReadPlatformService;
    +    
    +    @Autowired
    +    public AdHocScheduledJobRunnerServiceImpl(final RoutingDataSourceServiceFactory dataSourceServiceFactory,
    --- End diff --
    
    Autowire final RoutingDataSource dataSource in this constructor and create JDBCTemplate with that data source.  this.jdbcTemplate = new JdbcTemplate(dataSource);


---
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] fineract pull request #369: Adhoc query API

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

    https://github.com/apache/fineract/pull/369#discussion_r122132244
  
    --- Diff: fineract-provider/src/main/resources/sql/migrations/core_db/V328__adhocquery.sql ---
    @@ -0,0 +1,51 @@
    +--
    +-- 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.
    +--
    +
    +CREATE TABLE `m_adhoc` (
    +	`id` BIGINT(20) NOT NULL AUTO_INCREMENT,
    +	`name` VARCHAR(100) NULL DEFAULT NULL,
    +	`query` VARCHAR(2000) NULL DEFAULT NULL,
    +	`table_name` VARCHAR(100) NULL DEFAULT NULL,
    +	`table_fields` VARCHAR(1000) NULL DEFAULT NULL,
    +	`email` VARCHAR(500) NOT NULL,
    +	`IsActive` TINYINT(1) NOT NULL DEFAULT '0',
    +	`created_date` DATETIME NULL DEFAULT NULL,
    +	`createdby_id` BIGINT NOT NULL,
    +	`lastmodifiedby_id` BIGINT(20) NOT NULL,
    +	`lastmodified_date` DATETIME NULL DEFAULT NULL,
    +	PRIMARY KEY (`id`),
    +	CONSTRAINT `createdby_id` FOREIGN KEY (`createdby_id`) REFERENCES `m_appuser` (`id`),
    +	CONSTRAINT `lastmodifiedby_id` FOREIGN KEY (`lastmodifiedby_id`) REFERENCES `m_appuser` (`id`)
    +)
    +COLLATE='latin1_swedish_ci'
    +ENGINE=InnoDB
    +;
    +
    +INSERT INTO `m_permission`
    +(`grouping`,`code`,`entity_name`,`action_name`,`can_maker_checker`) VALUES
    +('authorisation','UPDATE_ADHOC','ADHOC','UPDATE',1),
    +('authorisation','UPDATE_ADHOC_CHECKER','ADHOC','UPDATE',0),
    +('authorisation','DELETE_ADHOC','ADHOC','DELETE',1),
    +('authorisation','DELETE_ADHOC_CHECKER','ADHOC','DELETE',0),
    +('authorisation','CREATE_ADHOC','ADHOC','CREATE',1),
    +('authorisation','CREATE_ADHOC_CHECKER','ADHOC','CREATE',0)
    +
    +INSERT INTO `job` (`name`, `display_name`, `cron_expression`, `create_time`) VALUES ('Generate AdhocClient Schedule', 'Generate AdhocClient Schedule', '0 0 12 1/1 * ? *', now());
    +
    +commit;
    --- End diff --
    
    I am talking about commit; statement. Is this required?


---
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] fineract pull request #369: Adhoc query API

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

    https://github.com/apache/fineract/pull/369#discussion_r122164025
  
    --- Diff: fineract-provider/src/main/java/org/apache/fineract/adhocquery/domain/AdHoc.java ---
    @@ -0,0 +1,156 @@
    +/**
    + * 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.adhocquery.domain;
    +
    +import java.util.Date;
    +import java.util.LinkedHashMap;
    +import java.util.Map;
    +
    +import javax.persistence.Column;
    +import javax.persistence.Entity;
    +import javax.persistence.FetchType;
    +import javax.persistence.JoinColumn;
    +import javax.persistence.OneToOne;
    +import javax.persistence.Table;
    +import javax.persistence.Temporal;
    +import javax.persistence.TemporalType;
    +
    +import org.apache.commons.lang.BooleanUtils;
    +import org.apache.commons.lang.StringUtils;
    +import org.apache.fineract.adhocquery.api.AdHocJsonInputParams;
    +import org.apache.fineract.infrastructure.core.api.JsonCommand;
    +import org.apache.fineract.infrastructure.core.domain.AbstractAuditableCustom;
    +import org.apache.fineract.infrastructure.core.domain.JdbcSupport;
    +import org.apache.fineract.useradministration.domain.AppUser;
    +import org.joda.time.LocalDate;
    +
    +
    +@Entity
    +@Table(name = "m_adhoc")
    +public class AdHoc extends AbstractAuditableCustom<AppUser, Long> {
    +
    +  	@Column(name = "name", length = 100)
    +    private  String name;
    +    
    +    @Column(name = "query", length = 2000)
    +    private  String query;
    +   	
    +    @Column(name = "table_name", length = 100)
    +    private  String tableName;
    +    
    +    
    +    @Column(name = "table_fields", length = 2000)
    +    private  String tableFields;
    +   	
    +    @Column(name = "email", length = 500)
    +    private  String email;
    +    
    +   
    +	@Column(name = "IsActive", nullable = false)
    +    private boolean isActive = false;
    +   	
    +    private AdHoc(final String name, final String query,final String tableName,final String tableFields ,final String email,final boolean isActive) {
    +        this.name = StringUtils.defaultIfEmpty(name, null);
    +        this.query=StringUtils.defaultIfEmpty(query,null);
    +        this.tableName=StringUtils.defaultIfEmpty(tableName,null);
    +        this.tableFields=StringUtils.defaultIfEmpty(tableFields,null);
    +        this.email=StringUtils.defaultIfEmpty(email,null);
    +        this.isActive = BooleanUtils.toBooleanDefaultIfNull(isActive, false);
    +       
    +    }
    +    public static AdHoc fromJson(final JsonCommand command) {
    +        final String name = command.stringValueOfParameterNamed(AdHocJsonInputParams.NAME.getValue());
    +        final String query = command.stringValueOfParameterNamed(AdHocJsonInputParams.QUERY.getValue());
    --- End diff --
    
    user can enter anything but cron will not execute this if there is any syntax error.so does it require adding more validation?


---
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] fineract pull request #369: Adhoc query API

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

    https://github.com/apache/fineract/pull/369#discussion_r122134075
  
    --- Diff: fineract-provider/src/main/java/org/apache/fineract/adhocquery/service/AdHocScheduledJobRunnerServiceImpl.java ---
    @@ -0,0 +1,80 @@
    +/**
    + * 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.adhocquery.service;
    +
    +import java.util.Collection;
    +
    +import org.apache.fineract.adhocquery.data.AdHocData;
    +import org.apache.fineract.adhocquery.service.AdHocReadPlatformService;
    +import org.apache.fineract.infrastructure.core.service.RoutingDataSourceServiceFactory;
    +import org.apache.fineract.infrastructure.core.service.ThreadLocalContextUtil;
    +import org.apache.fineract.infrastructure.jobs.annotation.CronTarget;
    +import org.apache.fineract.infrastructure.jobs.service.JobName;
    +import org.slf4j.Logger;
    +import org.slf4j.LoggerFactory;
    +import org.springframework.beans.factory.annotation.Autowired;
    +import org.springframework.jdbc.core.JdbcTemplate;
    +import org.springframework.stereotype.Service;
    +import org.springframework.transaction.annotation.Transactional;
    +
    +@Service(value = "adHocScheduledJobRunnerService")
    +public class AdHocScheduledJobRunnerServiceImpl implements AdHocScheduledJobRunnerService {
    +
    +    private final static Logger logger = LoggerFactory.getLogger(AdHocScheduledJobRunnerServiceImpl.class);
    +    private final RoutingDataSourceServiceFactory dataSourceServiceFactory;
    +    private final AdHocReadPlatformService adHocReadPlatformService;
    +    
    +    @Autowired
    +    public AdHocScheduledJobRunnerServiceImpl(final RoutingDataSourceServiceFactory dataSourceServiceFactory,
    +    		final AdHocReadPlatformService adHocReadPlatformService
    +            ) {
    +        this.dataSourceServiceFactory = dataSourceServiceFactory;
    +        this.adHocReadPlatformService = adHocReadPlatformService;
    +       
    +    }
    +
    +    @Transactional
    +    @Override
    +    @CronTarget(jobName = JobName.GENERATE_ADHOCCLIENT_SCEHDULE)
    +    public void generateClientSchedule() {
    +    	final JdbcTemplate jdbcTemplate = new JdbcTemplate(this.dataSourceServiceFactory.determineDataSourceService().retrieveDataSource());
    --- End diff --
    
      @Autowired
        public AdHocScheduledJobRunnerServiceImpl(final RoutingDataSource dataSource,
        		final AdHocReadPlatformService adHocReadPlatformService
                ) {
        	this.jdbcTemplate = new JdbcTemplate(dataSource);
            this.adHocReadPlatformService = adHocReadPlatformService;
           
        }
    
    like this


---
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] fineract pull request #369: Adhoc query API

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

    https://github.com/apache/fineract/pull/369#discussion_r122131974
  
    --- Diff: fineract-provider/src/main/java/org/apache/fineract/adhocquery/service/AdHocScheduledJobRunnerServiceImpl.java ---
    @@ -0,0 +1,80 @@
    +/**
    + * 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.adhocquery.service;
    +
    +import java.util.Collection;
    +
    +import org.apache.fineract.adhocquery.data.AdHocData;
    +import org.apache.fineract.adhocquery.service.AdHocReadPlatformService;
    +import org.apache.fineract.infrastructure.core.service.RoutingDataSourceServiceFactory;
    +import org.apache.fineract.infrastructure.core.service.ThreadLocalContextUtil;
    +import org.apache.fineract.infrastructure.jobs.annotation.CronTarget;
    +import org.apache.fineract.infrastructure.jobs.service.JobName;
    +import org.slf4j.Logger;
    +import org.slf4j.LoggerFactory;
    +import org.springframework.beans.factory.annotation.Autowired;
    +import org.springframework.jdbc.core.JdbcTemplate;
    +import org.springframework.stereotype.Service;
    +import org.springframework.transaction.annotation.Transactional;
    +
    +@Service(value = "adHocScheduledJobRunnerService")
    +public class AdHocScheduledJobRunnerServiceImpl implements AdHocScheduledJobRunnerService {
    +
    +    private final static Logger logger = LoggerFactory.getLogger(AdHocScheduledJobRunnerServiceImpl.class);
    +    private final RoutingDataSourceServiceFactory dataSourceServiceFactory;
    +    private final AdHocReadPlatformService adHocReadPlatformService;
    +    
    +    @Autowired
    +    public AdHocScheduledJobRunnerServiceImpl(final RoutingDataSourceServiceFactory dataSourceServiceFactory,
    +    		final AdHocReadPlatformService adHocReadPlatformService
    +            ) {
    +        this.dataSourceServiceFactory = dataSourceServiceFactory;
    +        this.adHocReadPlatformService = adHocReadPlatformService;
    +       
    +    }
    +
    +    @Transactional
    +    @Override
    +    @CronTarget(jobName = JobName.GENERATE_ADHOCCLIENT_SCEHDULE)
    +    public void generateClientSchedule() {
    +    	final JdbcTemplate jdbcTemplate = new JdbcTemplate(this.dataSourceServiceFactory.determineDataSourceService().retrieveDataSource());
    --- End diff --
    
    ok


---
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] fineract pull request #369: Adhoc query API

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

    https://github.com/apache/fineract/pull/369#discussion_r122131945
  
    --- Diff: fineract-provider/src/main/java/org/apache/fineract/adhocquery/domain/AdHoc.java ---
    @@ -0,0 +1,156 @@
    +/**
    + * 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.adhocquery.domain;
    +
    +import java.util.Date;
    +import java.util.LinkedHashMap;
    +import java.util.Map;
    +
    +import javax.persistence.Column;
    +import javax.persistence.Entity;
    +import javax.persistence.FetchType;
    +import javax.persistence.JoinColumn;
    +import javax.persistence.OneToOne;
    +import javax.persistence.Table;
    +import javax.persistence.Temporal;
    +import javax.persistence.TemporalType;
    +
    +import org.apache.commons.lang.BooleanUtils;
    +import org.apache.commons.lang.StringUtils;
    +import org.apache.fineract.adhocquery.api.AdHocJsonInputParams;
    +import org.apache.fineract.infrastructure.core.api.JsonCommand;
    +import org.apache.fineract.infrastructure.core.domain.AbstractAuditableCustom;
    +import org.apache.fineract.infrastructure.core.domain.JdbcSupport;
    +import org.apache.fineract.useradministration.domain.AppUser;
    +import org.joda.time.LocalDate;
    +
    +
    +@Entity
    +@Table(name = "m_adhoc")
    +public class AdHoc extends AbstractAuditableCustom<AppUser, Long> {
    +
    +  	@Column(name = "name", length = 100)
    +    private  String name;
    +    
    +    @Column(name = "query", length = 2000)
    +    private  String query;
    +   	
    +    @Column(name = "table_name", length = 100)
    +    private  String tableName;
    +    
    +    
    +    @Column(name = "table_fields", length = 2000)
    +    private  String tableFields;
    +   	
    +    @Column(name = "email", length = 500)
    +    private  String email;
    +    
    +   
    +	@Column(name = "IsActive", nullable = false)
    +    private boolean isActive = false;
    +   	
    +    private AdHoc(final String name, final String query,final String tableName,final String tableFields ,final String email,final boolean isActive) {
    +        this.name = StringUtils.defaultIfEmpty(name, null);
    +        this.query=StringUtils.defaultIfEmpty(query,null);
    +        this.tableName=StringUtils.defaultIfEmpty(tableName,null);
    +        this.tableFields=StringUtils.defaultIfEmpty(tableFields,null);
    +        this.email=StringUtils.defaultIfEmpty(email,null);
    +        this.isActive = BooleanUtils.toBooleanDefaultIfNull(isActive, false);
    +       
    +    }
    +    public static AdHoc fromJson(final JsonCommand command) {
    +        final String name = command.stringValueOfParameterNamed(AdHocJsonInputParams.NAME.getValue());
    +        final String query = command.stringValueOfParameterNamed(AdHocJsonInputParams.QUERY.getValue());
    --- End diff --
    
    validation will be done in UI


---
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] fineract issue #369: Adhoc query API

Posted by iamrupok <gi...@git.apache.org>.
Github user iamrupok commented on the issue:

    https://github.com/apache/fineract/pull/369
  
    #370 created a new PR


---
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] fineract pull request #369: Adhoc query API

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

    https://github.com/apache/fineract/pull/369#discussion_r122134576
  
    --- Diff: fineract-provider/src/main/java/org/apache/fineract/adhocquery/domain/AdHoc.java ---
    @@ -0,0 +1,156 @@
    +/**
    + * 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.adhocquery.domain;
    +
    +import java.util.Date;
    +import java.util.LinkedHashMap;
    +import java.util.Map;
    +
    +import javax.persistence.Column;
    +import javax.persistence.Entity;
    +import javax.persistence.FetchType;
    +import javax.persistence.JoinColumn;
    +import javax.persistence.OneToOne;
    +import javax.persistence.Table;
    +import javax.persistence.Temporal;
    +import javax.persistence.TemporalType;
    +
    +import org.apache.commons.lang.BooleanUtils;
    +import org.apache.commons.lang.StringUtils;
    +import org.apache.fineract.adhocquery.api.AdHocJsonInputParams;
    +import org.apache.fineract.infrastructure.core.api.JsonCommand;
    +import org.apache.fineract.infrastructure.core.domain.AbstractAuditableCustom;
    +import org.apache.fineract.infrastructure.core.domain.JdbcSupport;
    +import org.apache.fineract.useradministration.domain.AppUser;
    +import org.joda.time.LocalDate;
    +
    +
    +@Entity
    +@Table(name = "m_adhoc")
    +public class AdHoc extends AbstractAuditableCustom<AppUser, Long> {
    +
    +  	@Column(name = "name", length = 100)
    +    private  String name;
    +    
    +    @Column(name = "query", length = 2000)
    +    private  String query;
    +   	
    +    @Column(name = "table_name", length = 100)
    +    private  String tableName;
    +    
    +    
    +    @Column(name = "table_fields", length = 2000)
    +    private  String tableFields;
    +   	
    +    @Column(name = "email", length = 500)
    +    private  String email;
    +    
    +   
    +	@Column(name = "IsActive", nullable = false)
    +    private boolean isActive = false;
    +   	
    +    private AdHoc(final String name, final String query,final String tableName,final String tableFields ,final String email,final boolean isActive) {
    +        this.name = StringUtils.defaultIfEmpty(name, null);
    +        this.query=StringUtils.defaultIfEmpty(query,null);
    +        this.tableName=StringUtils.defaultIfEmpty(tableName,null);
    +        this.tableFields=StringUtils.defaultIfEmpty(tableFields,null);
    +        this.email=StringUtils.defaultIfEmpty(email,null);
    +        this.isActive = BooleanUtils.toBooleanDefaultIfNull(isActive, false);
    +       
    +    }
    +    public static AdHoc fromJson(final JsonCommand command) {
    +        final String name = command.stringValueOfParameterNamed(AdHocJsonInputParams.NAME.getValue());
    +        final String query = command.stringValueOfParameterNamed(AdHocJsonInputParams.QUERY.getValue());
    --- End diff --
    
    We are considering  as it should not be null


---
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] fineract pull request #369: Adhoc query API

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

    https://github.com/apache/fineract/pull/369#discussion_r122164855
  
    --- Diff: fineract-provider/src/main/java/org/apache/fineract/adhocquery/domain/AdHoc.java ---
    @@ -0,0 +1,156 @@
    +/**
    + * 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.adhocquery.domain;
    +
    +import java.util.Date;
    +import java.util.LinkedHashMap;
    +import java.util.Map;
    +
    +import javax.persistence.Column;
    +import javax.persistence.Entity;
    +import javax.persistence.FetchType;
    +import javax.persistence.JoinColumn;
    +import javax.persistence.OneToOne;
    +import javax.persistence.Table;
    +import javax.persistence.Temporal;
    +import javax.persistence.TemporalType;
    +
    +import org.apache.commons.lang.BooleanUtils;
    +import org.apache.commons.lang.StringUtils;
    +import org.apache.fineract.adhocquery.api.AdHocJsonInputParams;
    +import org.apache.fineract.infrastructure.core.api.JsonCommand;
    +import org.apache.fineract.infrastructure.core.domain.AbstractAuditableCustom;
    +import org.apache.fineract.infrastructure.core.domain.JdbcSupport;
    +import org.apache.fineract.useradministration.domain.AppUser;
    +import org.joda.time.LocalDate;
    +
    +
    +@Entity
    +@Table(name = "m_adhoc")
    +public class AdHoc extends AbstractAuditableCustom<AppUser, Long> {
    +
    +  	@Column(name = "name", length = 100)
    +    private  String name;
    +    
    +    @Column(name = "query", length = 2000)
    +    private  String query;
    +   	
    +    @Column(name = "table_name", length = 100)
    +    private  String tableName;
    +    
    +    
    +    @Column(name = "table_fields", length = 2000)
    +    private  String tableFields;
    +   	
    +    @Column(name = "email", length = 500)
    +    private  String email;
    +    
    +   
    +	@Column(name = "IsActive", nullable = false)
    +    private boolean isActive = false;
    +   	
    +    private AdHoc(final String name, final String query,final String tableName,final String tableFields ,final String email,final boolean isActive) {
    +        this.name = StringUtils.defaultIfEmpty(name, null);
    +        this.query=StringUtils.defaultIfEmpty(query,null);
    +        this.tableName=StringUtils.defaultIfEmpty(tableName,null);
    +        this.tableFields=StringUtils.defaultIfEmpty(tableFields,null);
    +        this.email=StringUtils.defaultIfEmpty(email,null);
    +        this.isActive = BooleanUtils.toBooleanDefaultIfNull(isActive, false);
    +       
    +    }
    +    public static AdHoc fromJson(final JsonCommand command) {
    +        final String name = command.stringValueOfParameterNamed(AdHocJsonInputParams.NAME.getValue());
    +        final String query = command.stringValueOfParameterNamed(AdHocJsonInputParams.QUERY.getValue());
    --- End diff --
    
    For example if user creates a SQL query drop database {databasename} or drop table {tableName}, it will drop the table or database right? 


---
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] fineract pull request #369: Adhoc query API

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

    https://github.com/apache/fineract/pull/369#discussion_r122122804
  
    --- Diff: fineract-provider/src/main/java/org/apache/fineract/adhocquery/domain/AdHoc.java ---
    @@ -0,0 +1,156 @@
    +/**
    + * 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.adhocquery.domain;
    +
    +import java.util.Date;
    +import java.util.LinkedHashMap;
    +import java.util.Map;
    +
    +import javax.persistence.Column;
    +import javax.persistence.Entity;
    +import javax.persistence.FetchType;
    +import javax.persistence.JoinColumn;
    +import javax.persistence.OneToOne;
    +import javax.persistence.Table;
    +import javax.persistence.Temporal;
    +import javax.persistence.TemporalType;
    +
    +import org.apache.commons.lang.BooleanUtils;
    +import org.apache.commons.lang.StringUtils;
    +import org.apache.fineract.adhocquery.api.AdHocJsonInputParams;
    +import org.apache.fineract.infrastructure.core.api.JsonCommand;
    +import org.apache.fineract.infrastructure.core.domain.AbstractAuditableCustom;
    +import org.apache.fineract.infrastructure.core.domain.JdbcSupport;
    +import org.apache.fineract.useradministration.domain.AppUser;
    +import org.joda.time.LocalDate;
    +
    +
    +@Entity
    +@Table(name = "m_adhoc")
    +public class AdHoc extends AbstractAuditableCustom<AppUser, Long> {
    +
    +  	@Column(name = "name", length = 100)
    +    private  String name;
    +    
    +    @Column(name = "query", length = 2000)
    +    private  String query;
    +   	
    +    @Column(name = "table_name", length = 100)
    +    private  String tableName;
    +    
    +    
    +    @Column(name = "table_fields", length = 2000)
    +    private  String tableFields;
    +   	
    +    @Column(name = "email", length = 500)
    +    private  String email;
    +    
    +   
    +	@Column(name = "IsActive", nullable = false)
    +    private boolean isActive = false;
    +   	
    +    private AdHoc(final String name, final String query,final String tableName,final String tableFields ,final String email,final boolean isActive) {
    +        this.name = StringUtils.defaultIfEmpty(name, null);
    +        this.query=StringUtils.defaultIfEmpty(query,null);
    +        this.tableName=StringUtils.defaultIfEmpty(tableName,null);
    +        this.tableFields=StringUtils.defaultIfEmpty(tableFields,null);
    +        this.email=StringUtils.defaultIfEmpty(email,null);
    +        this.isActive = BooleanUtils.toBooleanDefaultIfNull(isActive, false);
    +       
    +    }
    +    public static AdHoc fromJson(final JsonCommand command) {
    +        final String name = command.stringValueOfParameterNamed(AdHocJsonInputParams.NAME.getValue());
    +        final String query = command.stringValueOfParameterNamed(AdHocJsonInputParams.QUERY.getValue());
    --- End diff --
    
    Do we need to check whether is there any malicious SQL script in this? 


---
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] fineract pull request #369: Adhoc query API

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

    https://github.com/apache/fineract/pull/369#discussion_r122132172
  
    --- Diff: fineract-provider/src/main/java/org/apache/fineract/adhocquery/domain/AdHoc.java ---
    @@ -0,0 +1,156 @@
    +/**
    + * 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.adhocquery.domain;
    +
    +import java.util.Date;
    +import java.util.LinkedHashMap;
    +import java.util.Map;
    +
    +import javax.persistence.Column;
    +import javax.persistence.Entity;
    +import javax.persistence.FetchType;
    +import javax.persistence.JoinColumn;
    +import javax.persistence.OneToOne;
    +import javax.persistence.Table;
    +import javax.persistence.Temporal;
    +import javax.persistence.TemporalType;
    +
    +import org.apache.commons.lang.BooleanUtils;
    +import org.apache.commons.lang.StringUtils;
    +import org.apache.fineract.adhocquery.api.AdHocJsonInputParams;
    +import org.apache.fineract.infrastructure.core.api.JsonCommand;
    +import org.apache.fineract.infrastructure.core.domain.AbstractAuditableCustom;
    +import org.apache.fineract.infrastructure.core.domain.JdbcSupport;
    +import org.apache.fineract.useradministration.domain.AppUser;
    +import org.joda.time.LocalDate;
    +
    +
    +@Entity
    +@Table(name = "m_adhoc")
    +public class AdHoc extends AbstractAuditableCustom<AppUser, Long> {
    +
    +  	@Column(name = "name", length = 100)
    +    private  String name;
    +    
    +    @Column(name = "query", length = 2000)
    +    private  String query;
    +   	
    +    @Column(name = "table_name", length = 100)
    +    private  String tableName;
    +    
    +    
    +    @Column(name = "table_fields", length = 2000)
    +    private  String tableFields;
    +   	
    +    @Column(name = "email", length = 500)
    +    private  String email;
    +    
    +   
    +	@Column(name = "IsActive", nullable = false)
    +    private boolean isActive = false;
    +   	
    +    private AdHoc(final String name, final String query,final String tableName,final String tableFields ,final String email,final boolean isActive) {
    +        this.name = StringUtils.defaultIfEmpty(name, null);
    +        this.query=StringUtils.defaultIfEmpty(query,null);
    +        this.tableName=StringUtils.defaultIfEmpty(tableName,null);
    +        this.tableFields=StringUtils.defaultIfEmpty(tableFields,null);
    +        this.email=StringUtils.defaultIfEmpty(email,null);
    +        this.isActive = BooleanUtils.toBooleanDefaultIfNull(isActive, false);
    +       
    +    }
    +    public static AdHoc fromJson(final JsonCommand command) {
    +        final String name = command.stringValueOfParameterNamed(AdHocJsonInputParams.NAME.getValue());
    +        final String query = command.stringValueOfParameterNamed(AdHocJsonInputParams.QUERY.getValue());
    --- End diff --
    
    But validations should be done at platform side. 


---
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] fineract pull request #369: Adhoc query API

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

    https://github.com/apache/fineract/pull/369#discussion_r122131690
  
    --- Diff: fineract-provider/src/main/resources/sql/migrations/core_db/V328__adhocquery.sql ---
    @@ -0,0 +1,51 @@
    +--
    +-- 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.
    +--
    +
    +CREATE TABLE `m_adhoc` (
    +	`id` BIGINT(20) NOT NULL AUTO_INCREMENT,
    +	`name` VARCHAR(100) NULL DEFAULT NULL,
    +	`query` VARCHAR(2000) NULL DEFAULT NULL,
    +	`table_name` VARCHAR(100) NULL DEFAULT NULL,
    +	`table_fields` VARCHAR(1000) NULL DEFAULT NULL,
    +	`email` VARCHAR(500) NOT NULL,
    +	`IsActive` TINYINT(1) NOT NULL DEFAULT '0',
    +	`created_date` DATETIME NULL DEFAULT NULL,
    +	`createdby_id` BIGINT NOT NULL,
    +	`lastmodifiedby_id` BIGINT(20) NOT NULL,
    +	`lastmodified_date` DATETIME NULL DEFAULT NULL,
    +	PRIMARY KEY (`id`),
    +	CONSTRAINT `createdby_id` FOREIGN KEY (`createdby_id`) REFERENCES `m_appuser` (`id`),
    +	CONSTRAINT `lastmodifiedby_id` FOREIGN KEY (`lastmodifiedby_id`) REFERENCES `m_appuser` (`id`)
    +)
    +COLLATE='latin1_swedish_ci'
    +ENGINE=InnoDB
    +;
    +
    +INSERT INTO `m_permission`
    +(`grouping`,`code`,`entity_name`,`action_name`,`can_maker_checker`) VALUES
    +('authorisation','UPDATE_ADHOC','ADHOC','UPDATE',1),
    +('authorisation','UPDATE_ADHOC_CHECKER','ADHOC','UPDATE',0),
    +('authorisation','DELETE_ADHOC','ADHOC','DELETE',1),
    +('authorisation','DELETE_ADHOC_CHECKER','ADHOC','DELETE',0),
    +('authorisation','CREATE_ADHOC','ADHOC','CREATE',1),
    +('authorisation','CREATE_ADHOC_CHECKER','ADHOC','CREATE',0)
    +
    +INSERT INTO `job` (`name`, `display_name`, `cron_expression`, `create_time`) VALUES ('Generate AdhocClient Schedule', 'Generate AdhocClient Schedule', '0 0 12 1/1 * ? *', now());
    +
    +commit;
    --- End diff --
    
    This is required to create new cron job for our adhocquery.which will fire every day pull data from m_adhoc table and insert into the table specified in m_adhoc tablename column and fields that are specified in the table.


---
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] fineract pull request #369: Adhoc query API

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

    https://github.com/apache/fineract/pull/369#discussion_r122122469
  
    --- Diff: fineract-provider/src/main/java/org/apache/fineract/adhocquery/service/AdHocScheduledJobRunnerServiceImpl.java ---
    @@ -0,0 +1,80 @@
    +/**
    + * 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.adhocquery.service;
    +
    +import java.util.Collection;
    +
    +import org.apache.fineract.adhocquery.data.AdHocData;
    +import org.apache.fineract.adhocquery.service.AdHocReadPlatformService;
    +import org.apache.fineract.infrastructure.core.service.RoutingDataSourceServiceFactory;
    +import org.apache.fineract.infrastructure.core.service.ThreadLocalContextUtil;
    +import org.apache.fineract.infrastructure.jobs.annotation.CronTarget;
    +import org.apache.fineract.infrastructure.jobs.service.JobName;
    +import org.slf4j.Logger;
    +import org.slf4j.LoggerFactory;
    +import org.springframework.beans.factory.annotation.Autowired;
    +import org.springframework.jdbc.core.JdbcTemplate;
    +import org.springframework.stereotype.Service;
    +import org.springframework.transaction.annotation.Transactional;
    +
    +@Service(value = "adHocScheduledJobRunnerService")
    +public class AdHocScheduledJobRunnerServiceImpl implements AdHocScheduledJobRunnerService {
    +
    +    private final static Logger logger = LoggerFactory.getLogger(AdHocScheduledJobRunnerServiceImpl.class);
    +    private final RoutingDataSourceServiceFactory dataSourceServiceFactory;
    +    private final AdHocReadPlatformService adHocReadPlatformService;
    +    
    +    @Autowired
    +    public AdHocScheduledJobRunnerServiceImpl(final RoutingDataSourceServiceFactory dataSourceServiceFactory,
    +    		final AdHocReadPlatformService adHocReadPlatformService
    +            ) {
    +        this.dataSourceServiceFactory = dataSourceServiceFactory;
    +        this.adHocReadPlatformService = adHocReadPlatformService;
    +       
    +    }
    +
    +    @Transactional
    +    @Override
    +    @CronTarget(jobName = JobName.GENERATE_ADHOCCLIENT_SCEHDULE)
    +    public void generateClientSchedule() {
    +    	final JdbcTemplate jdbcTemplate = new JdbcTemplate(this.dataSourceServiceFactory.determineDataSourceService().retrieveDataSource());
    --- End diff --
    
    I suggest to create JdbcTemplate object in constructor of this class by autowiring RoutingDataSource


---
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] fineract pull request #369: Adhoc query API

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

    https://github.com/apache/fineract/pull/369#discussion_r122121501
  
    --- Diff: fineract-provider/src/main/resources/sql/migrations/core_db/V328__adhocquery.sql ---
    @@ -0,0 +1,51 @@
    +--
    +-- 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.
    +--
    +
    +CREATE TABLE `m_adhoc` (
    +	`id` BIGINT(20) NOT NULL AUTO_INCREMENT,
    +	`name` VARCHAR(100) NULL DEFAULT NULL,
    +	`query` VARCHAR(2000) NULL DEFAULT NULL,
    +	`table_name` VARCHAR(100) NULL DEFAULT NULL,
    +	`table_fields` VARCHAR(1000) NULL DEFAULT NULL,
    +	`email` VARCHAR(500) NOT NULL,
    +	`IsActive` TINYINT(1) NOT NULL DEFAULT '0',
    +	`created_date` DATETIME NULL DEFAULT NULL,
    +	`createdby_id` BIGINT NOT NULL,
    +	`lastmodifiedby_id` BIGINT(20) NOT NULL,
    +	`lastmodified_date` DATETIME NULL DEFAULT NULL,
    +	PRIMARY KEY (`id`),
    +	CONSTRAINT `createdby_id` FOREIGN KEY (`createdby_id`) REFERENCES `m_appuser` (`id`),
    +	CONSTRAINT `lastmodifiedby_id` FOREIGN KEY (`lastmodifiedby_id`) REFERENCES `m_appuser` (`id`)
    +)
    +COLLATE='latin1_swedish_ci'
    +ENGINE=InnoDB
    +;
    +
    +INSERT INTO `m_permission`
    +(`grouping`,`code`,`entity_name`,`action_name`,`can_maker_checker`) VALUES
    +('authorisation','UPDATE_ADHOC','ADHOC','UPDATE',1),
    +('authorisation','UPDATE_ADHOC_CHECKER','ADHOC','UPDATE',0),
    +('authorisation','DELETE_ADHOC','ADHOC','DELETE',1),
    +('authorisation','DELETE_ADHOC_CHECKER','ADHOC','DELETE',0),
    +('authorisation','CREATE_ADHOC','ADHOC','CREATE',1),
    +('authorisation','CREATE_ADHOC_CHECKER','ADHOC','CREATE',0)
    +
    +INSERT INTO `job` (`name`, `display_name`, `cron_expression`, `create_time`) VALUES ('Generate AdhocClient Schedule', 'Generate AdhocClient Schedule', '0 0 12 1/1 * ? *', now());
    +
    +commit;
    --- End diff --
    
    Why this is required?


---
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] fineract pull request #369: Adhoc query API

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

    https://github.com/apache/fineract/pull/369


---
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] fineract pull request #369: Adhoc query API

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

    https://github.com/apache/fineract/pull/369#discussion_r122171016
  
    --- Diff: fineract-provider/src/main/java/org/apache/fineract/adhocquery/domain/AdHoc.java ---
    @@ -0,0 +1,156 @@
    +/**
    + * 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.adhocquery.domain;
    +
    +import java.util.Date;
    +import java.util.LinkedHashMap;
    +import java.util.Map;
    +
    +import javax.persistence.Column;
    +import javax.persistence.Entity;
    +import javax.persistence.FetchType;
    +import javax.persistence.JoinColumn;
    +import javax.persistence.OneToOne;
    +import javax.persistence.Table;
    +import javax.persistence.Temporal;
    +import javax.persistence.TemporalType;
    +
    +import org.apache.commons.lang.BooleanUtils;
    +import org.apache.commons.lang.StringUtils;
    +import org.apache.fineract.adhocquery.api.AdHocJsonInputParams;
    +import org.apache.fineract.infrastructure.core.api.JsonCommand;
    +import org.apache.fineract.infrastructure.core.domain.AbstractAuditableCustom;
    +import org.apache.fineract.infrastructure.core.domain.JdbcSupport;
    +import org.apache.fineract.useradministration.domain.AppUser;
    +import org.joda.time.LocalDate;
    +
    +
    +@Entity
    +@Table(name = "m_adhoc")
    +public class AdHoc extends AbstractAuditableCustom<AppUser, Long> {
    +
    +  	@Column(name = "name", length = 100)
    +    private  String name;
    +    
    +    @Column(name = "query", length = 2000)
    +    private  String query;
    +   	
    +    @Column(name = "table_name", length = 100)
    +    private  String tableName;
    +    
    +    
    +    @Column(name = "table_fields", length = 2000)
    +    private  String tableFields;
    +   	
    +    @Column(name = "email", length = 500)
    +    private  String email;
    +    
    +   
    +	@Column(name = "IsActive", nullable = false)
    +    private boolean isActive = false;
    +   	
    +    private AdHoc(final String name, final String query,final String tableName,final String tableFields ,final String email,final boolean isActive) {
    +        this.name = StringUtils.defaultIfEmpty(name, null);
    +        this.query=StringUtils.defaultIfEmpty(query,null);
    +        this.tableName=StringUtils.defaultIfEmpty(tableName,null);
    +        this.tableFields=StringUtils.defaultIfEmpty(tableFields,null);
    +        this.email=StringUtils.defaultIfEmpty(email,null);
    +        this.isActive = BooleanUtils.toBooleanDefaultIfNull(isActive, false);
    +       
    +    }
    +    public static AdHoc fromJson(final JsonCommand command) {
    +        final String name = command.stringValueOfParameterNamed(AdHocJsonInputParams.NAME.getValue());
    +        final String query = command.stringValueOfParameterNamed(AdHocJsonInputParams.QUERY.getValue());
    --- End diff --
    
      String commandQuery=command.stringValueOfParameterNamed(AdHocJsonInputParams.QUERY.getValue());
            if(commandQuery.toLowerCase().contains("drop")||commandQuery.toLowerCase().contains("delete")){
            	commandQuery=null;
            }
          
    
    do you thinks this will be ok


---
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] fineract pull request #369: Adhoc query API

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

    https://github.com/apache/fineract/pull/369#discussion_r122134182
  
    --- Diff: fineract-provider/src/main/resources/sql/migrations/core_db/V328__adhocquery.sql ---
    @@ -0,0 +1,51 @@
    +--
    +-- 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.
    +--
    +
    +CREATE TABLE `m_adhoc` (
    +	`id` BIGINT(20) NOT NULL AUTO_INCREMENT,
    +	`name` VARCHAR(100) NULL DEFAULT NULL,
    +	`query` VARCHAR(2000) NULL DEFAULT NULL,
    +	`table_name` VARCHAR(100) NULL DEFAULT NULL,
    +	`table_fields` VARCHAR(1000) NULL DEFAULT NULL,
    +	`email` VARCHAR(500) NOT NULL,
    +	`IsActive` TINYINT(1) NOT NULL DEFAULT '0',
    +	`created_date` DATETIME NULL DEFAULT NULL,
    +	`createdby_id` BIGINT NOT NULL,
    +	`lastmodifiedby_id` BIGINT(20) NOT NULL,
    +	`lastmodified_date` DATETIME NULL DEFAULT NULL,
    +	PRIMARY KEY (`id`),
    +	CONSTRAINT `createdby_id` FOREIGN KEY (`createdby_id`) REFERENCES `m_appuser` (`id`),
    +	CONSTRAINT `lastmodifiedby_id` FOREIGN KEY (`lastmodifiedby_id`) REFERENCES `m_appuser` (`id`)
    +)
    +COLLATE='latin1_swedish_ci'
    +ENGINE=InnoDB
    +;
    +
    +INSERT INTO `m_permission`
    +(`grouping`,`code`,`entity_name`,`action_name`,`can_maker_checker`) VALUES
    +('authorisation','UPDATE_ADHOC','ADHOC','UPDATE',1),
    +('authorisation','UPDATE_ADHOC_CHECKER','ADHOC','UPDATE',0),
    +('authorisation','DELETE_ADHOC','ADHOC','DELETE',1),
    +('authorisation','DELETE_ADHOC_CHECKER','ADHOC','DELETE',0),
    +('authorisation','CREATE_ADHOC','ADHOC','CREATE',1),
    +('authorisation','CREATE_ADHOC_CHECKER','ADHOC','CREATE',0)
    +
    +INSERT INTO `job` (`name`, `display_name`, `cron_expression`, `create_time`) VALUES ('Generate AdhocClient Schedule', 'Generate AdhocClient Schedule', '0 0 12 1/1 * ? *', now());
    +
    +commit;
    --- End diff --
    
    no i will remove 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.
---