1 /* 2 * #%L 3 * Coser :: Web 4 * %% 5 * Copyright (C) 2011 Ifremer, Codelutin, Chatellier Eric 6 * %% 7 * This program is free software: you can redistribute it and/or modify 8 * it under the terms of the GNU Affero General Public License as published by 9 * the Free Software Foundation, either version 3 of the License, or 10 * (at your option) any later version. 11 * 12 * This program is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU Affero General Public License 18 * along with this program. If not, see <http://www.gnu.org/licenses/>. 19 * #L% 20 */ 21 22 package fr.ifremer.coser.web.actions.admin; 23 24 import fr.ifremer.coser.result.ResultType; 25 import fr.ifremer.coser.result.request.DeleteResultsRequest; 26 import fr.ifremer.coser.web.actions.common.AbstractCoserAction; 27 import org.apache.commons.logging.Log; 28 import org.apache.commons.logging.LogFactory; 29 import org.apache.struts2.convention.annotation.Result; 30 31 import java.util.List; 32 33 /** 34 * Project list action. 35 * <p/> 36 * Last update : $Date$ 37 * By : $Author$ 38 * 39 * @author chatellier 40 * @version $Revision$ 41 */ 42 @Result(type = "redirect", location = "list-projects") 43 public class DeleteProjectsAction extends AbstractCoserAction { 44 45 /** serialVersionUID. */ 46 private static final long serialVersionUID = 6024588562104111883L; 47 48 private static final Log log = LogFactory.getLog(DeleteProjectsAction.class); 49 50 /** 51 * Type of result repository. 52 */ 53 protected String repositoryType; 54 55 /** 56 * Type of result to delete. 57 */ 58 protected ResultType resultType; 59 60 /** 61 * List of result id to delete. 62 */ 63 protected List<String> zonesId; 64 65 public void setRepositoryType(String repositoryType) { 66 this.repositoryType = repositoryType; 67 } 68 69 public void setResultType(ResultType resultType) { 70 this.resultType = resultType; 71 } 72 73 public void setZonesId(List<String> zonesId) { 74 this.zonesId = zonesId; 75 } 76 77 @Override 78 public String execute() { 79 80 if (log.isInfoEnabled()) { 81 log.info(String.format("Delete zone (type %s) (repository type %s) : %s", 82 resultType, 83 repositoryType, 84 zonesId)); 85 } 86 87 DeleteResultsRequest request = requestBuilder(DeleteResultsRequest.class). 88 addRepositoryType(repositoryType). 89 addResultType(resultType). 90 addZoneList(zonesId). 91 toRequest(); 92 93 getService().deleteResults(request); 94 95 return SUCCESS; 96 } 97 98 // /** 99 // * Contient les identifiants des zones dont on souhaite supprimer le 100 // * resultat conrespondant dans le stockage indicateur. 101 // */ 102 // protected List<String> indicatorsZonesId; 103 // 104 // /** 105 // * Contient les identifiants des zones dont on souhaites supprimer le 106 // * resultat conrespondant dans le stockage cartes. 107 // */ 108 // protected List<String> mapsZonesId; 109 // 110 // public void setIndicatorsZonesId(List<String> indicatorsZonesId) { 111 // this.indicatorsZonesId = indicatorsZonesId; 112 // } 113 // 114 // public void setMapsZonesId(List<String> mapsZonesId) { 115 // this.mapsZonesId = mapsZonesId; 116 // } 117 // 118 // public String execute() { 119 // WebService webService = ServiceFactory.getWebService(); 120 // 121 // try { 122 // if (log.isDebugEnabled()) { 123 // log.debug("Delete indicators zone : " + indicatorsZonesId); 124 // } 125 // if (CollectionUtils.isNotEmpty(indicatorsZonesId)) { 126 // webService.deleteIndicatorsResult(indicatorsZonesId); 127 // } 128 // 129 // if (log.isDebugEnabled()) { 130 // log.debug("Delete maps zone : " + mapsZonesId); 131 // } 132 // if (CollectionUtils.isNotEmpty(mapsZonesId)) { 133 // webService.deleteMapsResult(mapsZonesId); 134 // } 135 // } catch (CoserBusinessException ex) { 136 // throw new CoserWebException("Can't get data from web service", ex); 137 // } 138 // 139 // return SUCCESS; 140 // } 141 142 }