Skip to content

Commit

Permalink
Merge pull request #5144 from metasfresh/gh5143
Browse files Browse the repository at this point in the history
#5143 Product Specification process only for selected Product
  • Loading branch information
metas-ts committed Apr 18, 2019
2 parents c9c167b + 6ea32c8 commit ba84f4e
Showing 1 changed file with 26 additions and 4 deletions.
@@ -1,5 +1,5 @@
/**
*
*
*/
package de.metas.fresh.product.process;

Expand All @@ -10,12 +10,18 @@
import org.apache.poi.ss.usermodel.Font;
import org.compiere.Adempiere;
import org.compiere.Adempiere.RunMode;
import org.compiere.model.I_M_Product;
import org.compiere.util.Env;
import org.compiere.util.Ini;

import de.metas.impexp.excel.ArrayExcelExporter;
import de.metas.impexp.excel.service.ExcelExporterService;
import de.metas.process.IProcessPrecondition;
import de.metas.process.IProcessPreconditionsContext;
import de.metas.process.JavaProcess;
import de.metas.process.ProcessPreconditionsResolution;
import de.metas.product.IProductDAO;
import de.metas.util.Services;

/*
* #%L
Expand All @@ -27,12 +33,12 @@
* it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of the
* License, or (at your option) any later version.
*
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*
* You should have received a copy of the GNU General Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/gpl-2.0.html>.
Expand All @@ -43,7 +49,7 @@
* @author metas-dev <dev@metasfresh.com>
*
*/
public class ExportProductSpecifications extends JavaProcess
public class ExportProductSpecifications extends JavaProcess implements IProcessPrecondition
{

private final static String tableName = "\"de.metas.fresh\".product_specifications_v";
Expand Down Expand Up @@ -78,11 +84,16 @@ protected String doIt() throws Exception

private String getSql()
{

final I_M_Product product = Services.get(IProductDAO.class).getById(getRecord_ID());

final StringBuffer sb = new StringBuffer();
sb.append("SELECT productName, CustomerLabelName, additional_produktinfos, productValue, UPC, weight, country, piName, piQty, ")
.append("guaranteedaysmin, warehouse_temperature, productDecription, componentName, componentIngredients, qtybatch, ")
.append("allergen, nutritionName, nutritionqty FROM ")
.append(tableName)
.append(" WHERE ")
.append(tableName).append(".productValue = '").append(product.getValue()).append("'")
.append(" ORDER BY productValue ");

return sb.toString();
Expand Down Expand Up @@ -112,4 +123,15 @@ private List<String> getColumnHeaders()

return columnHeaders;
}

@Override
public ProcessPreconditionsResolution checkPreconditionsApplicable(final IProcessPreconditionsContext context)
{
if(!context.isSingleSelection())
{
return ProcessPreconditionsResolution.rejectBecauseNotSingleSelection();
}

return ProcessPreconditionsResolution.accept();
}
}

0 comments on commit ba84f4e

Please sign in to comment.