* getUse(useName, useTable, id, forSubscription, period = defaultDate()) {
     logger.debug('Obtaining use with id %s', id);
     let periods = period.split(',');
     let params = {
         useTable: useTable,
         pid: id,
         begin: periods[0],
         end: periods[1]
     };
     let query = USE;
     if (forSubscription) {
         query = this.getURLForSubscrition(USE);
     }
     const geostore = yield GeostoreService.getGeostoreByUse(useName, id);
     let data = yield executeThunk(this.client, query, params);
     if (geostore) {
         if (forSubscription && data.rows) {
             return data.rows;
         }
         if (data.rows && data.rows.length > 0) {
             let result = data.rows[0];
             result.area_ha = geostore.areaHa;
             result.downloadUrls = this.getDownloadUrls(USE, params);
             return result;
         } else {
             return {
                 area_ha: geostore.areaHa   
             };
         }
     }
     return null;
 }
Exemplo n.º 2
0
 * getUse(useName, useTable, id, alertQuery, period = defaultDate()) {
     logger.debug('Obtaining use with id %s', id);
     let periods = period.split(',');
     let params = {
         useTable: useTable,
         pid: id,
         begin: periods[0],
         end: periods[1]
     };
     const geostore = yield GeostoreService.getGeostoreByUse(useName, id);
     let data = yield executeThunk(this.client, USE, params);
     if (geostore){
         if (data.rows && data.rows.length > 0) {
             let result = data.rows[0];
             result.area_ha = geostore.areaHa;
             result.period = this.getPeriodText(period);
             result.downloadUrls = this.getDownloadUrls(USE, params);
             return result;
         } else {
             return {
                 area_ha: geostore.areaHa
             };
         }
     }
     return null;
 }
    * getUse(useTable, id, period = defaultDate()) {
        logger.debug('Obtaining use with id %s', id);
        let periods = period.split(',');
        let params = {
            useTable: useTable,
            pid: id,
            begin: periods[0],
            end: periods[1]
        };

        let data = yield executeThunk(this.client, USE, params);
        if (data.rows && data.rows.length > 0) {
            let result = data.rows[0];
            result.id = id;
            result.period = this.getPeriodText(period);
            result.downloadUrls = this.getDownloadUrls(USE, params);
            return result;
        }
        let areas = yield executeThunk(this.client, USEAREA, params);
        if (areas.rows && areas.rows.length > 0) {
            let result = areas.rows[0];
            result.id = id;
            result.value = 0;
            return result;
        }
        const geostore = yield GeostoreService.getGeostoreByUse(useTable, id);
        if(geostore){
            return {
                id: id,
                value: 0,
                area_ha: geostore.area_ha
            };
        }
        return null;
    }
 * getUse(useName, id, forSubscription, period = defaultDate(), group = false) {
     logger.debug('Obtaining use with id %s', id);
     let periods = period.split(',');
     let params = {
         useTable: useName,
         pid: id,
         begin: periods[0],
         end: periods[1]
     };
     let query = USE;
     if (forSubscription) {
         query = this.getURLForSubscrition(USE);
     }
     if (group) {
         query = this.getQueryForGroup(USE);
     }
     let data = yield executeThunk(this.client, query, params);
     if (forSubscription && data.rows) {
         return data.rows;
     }
     if (group && data.rows) {
         if (data.rows.length > 0 && data.rows[0].day === null) {
             return [];
         }
         return data.rows;
     }
     if (data.rows && data.rows.length > 0) {
         let result = data.rows[0];
         result.id = id;
         result.period = this.getPeriodText(period);
         result.downloadUrls = this.getDownloadUrls(USE, params);
         return result;
     }
     let areas = yield executeThunk(this.client, USEAREA, params);
     if (areas.rows && areas.rows.length > 0) {
         let result = areas.rows[0];
         result.id = id;
         result.value = 0;
         return result;
     }
     const geostore = yield GeostoreService.getGeostoreByUse(useName, id);
     if(geostore){
         return {
             id: id,
             value: 0,
             area_ha: geostore.area_ha
         };
     }
     return null;
 }