r225 - in trunk/chorem-webmotion/src/main: java/org/chorem/webmotion/actions resources webapp/WEB-INF/jsp
Author: bpoussin Date: 2012-08-03 17:12:53 +0200 (Fri, 03 Aug 2012) New Revision: 225 Url: http://chorem.org/repositories/revision/chorem/225 Log: Evolution #723: Be able to create linked objects from an object page remise a plat de la facon de faire d'ajout d'action specifique pour des extensions suppression des mapping ne servant plus et des actions associees Added: trunk/chorem-webmotion/src/main/webapp/WEB-INF/jsp/viewActionCompany.jsp trunk/chorem-webmotion/src/main/webapp/WEB-INF/jsp/viewActionEmployee.jsp trunk/chorem-webmotion/src/main/webapp/WEB-INF/jsp/viewActionPerson.jsp trunk/chorem-webmotion/src/main/webapp/WEB-INF/jsp/viewActionProject.jsp Removed: trunk/chorem-webmotion/src/main/java/org/chorem/webmotion/actions/LinkAction.java trunk/chorem-webmotion/src/main/webapp/WEB-INF/jsp/employee/ trunk/chorem-webmotion/src/main/webapp/WEB-INF/jsp/footerPerson.jsp trunk/chorem-webmotion/src/main/webapp/WEB-INF/jsp/person/ Modified: trunk/chorem-webmotion/src/main/java/org/chorem/webmotion/actions/GenericAction.java trunk/chorem-webmotion/src/main/resources/mapping trunk/chorem-webmotion/src/main/webapp/WEB-INF/jsp/view.jsp Modified: trunk/chorem-webmotion/src/main/java/org/chorem/webmotion/actions/GenericAction.java =================================================================== --- trunk/chorem-webmotion/src/main/java/org/chorem/webmotion/actions/GenericAction.java 2012-08-03 13:56:02 UTC (rev 224) +++ trunk/chorem-webmotion/src/main/java/org/chorem/webmotion/actions/GenericAction.java 2012-08-03 15:12:53 UTC (rev 225) @@ -46,15 +46,20 @@ import org.nuiton.wikitty.query.WikittyQueryResult; import java.io.ByteArrayInputStream; +import java.net.MalformedURLException; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.LinkedHashMap; import java.util.LinkedHashSet; +import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.Set; +import java.util.logging.Level; +import java.util.logging.Logger; +import javax.servlet.ServletContext; import org.debux.webmotion.server.mapping.Config; /** @@ -375,7 +380,8 @@ return map; } - public Render view(ChoremClient client, String id, String[] extension, Config config) { + public Render view(ChoremClient client, String id, String[] extension, + Config config, ServletContext servletContext) { log.debug("view: " + id); Wikitty w = client.restore(id, ".*"); @@ -393,11 +399,27 @@ // recherche de footer specifique aux extensions String pathView = config.getPackageViews(); + if (pathView == null) { + pathView = ""; + } + pathView = "/" + pathView + "/"; + pathView = StringUtils.replace(pathView, "\\", "/"); + pathView = StringUtils.replace(pathView, "//", "/"); + + // recherche des JSP d'action specifique pour les extensions + List<String> viewActions = new LinkedList<String>(); for (WikittyExtension e : exts) { - + String viewAction = pathView + "footer" + e.getName() + ".jsp"; + try { + if (servletContext.getResource(viewAction) != null) { + viewActions.add(viewAction); + } + } catch (MalformedURLException eee) { + log.warn(String.format("Bad url '%s'", viewAction), eee); + } } - return renderView("view.jsp", "wikitty", w, "extensions", exts); + return renderView("view.jsp", "wikitty", w, "extensions", exts, "viewActions", viewActions); } public Render extensionView(ChoremClient client, String id, String extension) { Deleted: trunk/chorem-webmotion/src/main/java/org/chorem/webmotion/actions/LinkAction.java =================================================================== --- trunk/chorem-webmotion/src/main/java/org/chorem/webmotion/actions/LinkAction.java 2012-08-03 13:56:02 UTC (rev 224) +++ trunk/chorem-webmotion/src/main/java/org/chorem/webmotion/actions/LinkAction.java 2012-08-03 15:12:53 UTC (rev 225) @@ -1,81 +0,0 @@ -package org.chorem.webmotion.actions; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.chorem.ChoremClient; -import org.chorem.entities.Attachment; -import org.chorem.entities.ContactDetails; -import org.debux.webmotion.server.WebMotionController; -import org.debux.webmotion.server.render.Render; -import org.nuiton.wikitty.entities.Wikitty; -import org.nuiton.wikitty.entities.WikittyExtension; -import org.nuiton.wikitty.entities.WikittyImpl; - -import java.util.Arrays; -import java.util.LinkedHashSet; -import java.util.List; - -/** - * Regroup the action that links an object with an other - * - * @author ymartel <martel@codelutin.com> - */ -public class LinkAction extends WebMotionController { - - static private Log log = LogFactory.getLog(LinkAction.class); - - public Render addAttachment(ChoremClient client, String wikittyId) { - if (log.isDebugEnabled()) { - log.debug("add attachment for : " + wikittyId); - } - - // Prepare attachment - Wikitty attachment = new WikittyImpl(); - - // Load Attachment extension, and potential dependencies - List<String> extensionNames = Arrays.asList(Attachment.EXT_ATTACHMENT); - List<WikittyExtension> newExts = - client.restoreExtensionAndDependenciesLastVesion(extensionNames); - attachment.addExtension(newExts); - - // As we want to edit a wikitty by its extensions, we should edit the required extensions too - // Add the extension and required ones in the list of extensions to display - LinkedHashSet<WikittyExtension> exts = new LinkedHashSet<WikittyExtension>(); - exts.addAll(newExts); - // Show all wikitty if no extension were mentioned - exts.addAll(attachment.getExtensions()); - - // Link target Wikitty - Wikitty linkedWikitty = client.restore(wikittyId, ".*"); - attachment.setField(Attachment.EXT_ATTACHMENT, Attachment.FIELD_ATTACHMENT_TARGET, linkedWikitty); - - return renderView("edit.jsp", "wikitty", attachment, "extensions", exts); - } - - public Render addContactDetails(ChoremClient client, String wikittyId) { - if (log.isDebugEnabled()) { - log.debug("add contact drtails for : " + wikittyId); - } - Wikitty w = client.restore(wikittyId, ".*"); - - Wikitty attachment = new WikittyImpl(); - - LinkedHashSet<WikittyExtension> exts = new LinkedHashSet<WikittyExtension>(); - - // Load Attachment extension, and potential dependencies - List<String> extensionNames = Arrays.asList(ContactDetails.EXT_CONTACTDETAILS); - List<WikittyExtension> newExts = - client.restoreExtensionAndDependenciesLastVesion(extensionNames); - attachment.addExtension(newExts); - - // As we want to edit a wikitty by its extensions, we should edit the required extensions too - // Add the extension and required ones in the list of extensions to display - exts.addAll(newExts); - // Show all wikitty if no extension were mentioned - exts.addAll(attachment.getExtensions()); - - attachment.setField(ContactDetails.EXT_CONTACTDETAILS, ContactDetails.FIELD_CONTACTDETAILS_TARGET, w); - return renderView("edit.jsp", "wikitty", attachment, "extensions", exts); - } - -} Modified: trunk/chorem-webmotion/src/main/resources/mapping =================================================================== --- trunk/chorem-webmotion/src/main/resources/mapping 2012-08-03 13:56:02 UTC (rev 224) +++ trunk/chorem-webmotion/src/main/resources/mapping 2012-08-03 15:12:53 UTC (rev 225) @@ -14,8 +14,6 @@ [actions] * / view:index.jsp * /wikitty/{extension}/search action:GenericAction.search -* /wikitty/Employee/view/{id} action:GenericAction.extensionView extension=Employee -* /wikitty/Person/view/{id} action:GenericAction.extensionView extension=Person * /wikitty/{extension}/view/{id} action:GenericAction.view * /wikitty/{extension}/edit/{id} action:GenericAction.edit * /wikitty/{extension}/delete/{id} action:GenericAction.delete Deleted: trunk/chorem-webmotion/src/main/webapp/WEB-INF/jsp/footerPerson.jsp =================================================================== --- trunk/chorem-webmotion/src/main/webapp/WEB-INF/jsp/footerPerson.jsp 2012-08-03 13:56:02 UTC (rev 224) +++ trunk/chorem-webmotion/src/main/webapp/WEB-INF/jsp/footerPerson.jsp 2012-08-03 15:12:53 UTC (rev 225) @@ -1,26 +0,0 @@ -<%-- - #%L - Chorem webmotion - $Id:$ - $HeadURL:$ - %% - Copyright (C) 2011 - 2012 CodeLutin - %% - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published by - the Free Software Foundation, either version 3 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 Affero General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. - #L% - --%> -<%@page contentType="text/html" pageEncoding="UTF-8"%> -<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> - -<jsp:include page="/wikitty/search?query=${wikitty.id} id!=${wikitty.id}"/> Modified: trunk/chorem-webmotion/src/main/webapp/WEB-INF/jsp/view.jsp =================================================================== --- trunk/chorem-webmotion/src/main/webapp/WEB-INF/jsp/view.jsp 2012-08-03 13:56:02 UTC (rev 224) +++ trunk/chorem-webmotion/src/main/webapp/WEB-INF/jsp/view.jsp 2012-08-03 15:12:53 UTC (rev 225) @@ -42,22 +42,17 @@ </dl> </c:forEach> -<p> +<div class="container"> <c:if test="${not empty wikitty}"> - <p> - <a class="btn btn-success" href="<c:url value="/wikitty/Attachment/edit/new?Attachment.target=${wikitty.id}"/>"><i class="icon-plus icon-white"></i> Add Attachment</a> - </p> - <p> - <a class="btn btn-success" href="<c:url value="/wikitty/Note/edit/new?Note.target=${wikitty.id}"/>"><i class="icon-plus icon-white"></i> Add Note</a> - </p> + <a class="btn btn-success" href="<c:url value="/wikitty/Attachment/edit/new?Attachment.target=${wikitty.id}"/>"><i class="icon-plus icon-white"></i> Add Attachment</a> + <a class="btn btn-success" href="<c:url value="/wikitty/Note/edit/new?Note.target=${wikitty.id}"/>"><i class="icon-plus icon-white"></i> Add Note</a> </c:if> -</p> + <c:forEach var="viewAction" items="${viewActions}"> + <jsp:include page="${viewAction}"/> + </c:forEach> +</div> + <div class="container"> <jsp:include page="/wikitty/searchRelated?id=${wikitty.id}"/> -<%-- - <c:forEach var="ext" items="${extensions}"> - <jsp:include page="footer${ext.name}.jsp"/> - </c:forEach> ---%> </div> Added: trunk/chorem-webmotion/src/main/webapp/WEB-INF/jsp/viewActionCompany.jsp =================================================================== --- trunk/chorem-webmotion/src/main/webapp/WEB-INF/jsp/viewActionCompany.jsp (rev 0) +++ trunk/chorem-webmotion/src/main/webapp/WEB-INF/jsp/viewActionCompany.jsp 2012-08-03 15:12:53 UTC (rev 225) @@ -0,0 +1,26 @@ +<%-- + #%L + Chorem webmotion + $Id:$ + $HeadURL:$ + %% + Copyright (C) 2011 - 2012 CodeLutin + %% + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 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 Affero General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. + #L% + --%> +<%@page contentType="text/html" pageEncoding="UTF-8"%> +<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> + +<a class="btn btn-success" href="<c:url value="/wikitty/ContactDetails/edit/new?ContactDetails.target=${wikitty.id}"/>"><i class="icon-plus icon-white"></i> Add Contact Details</a> Added: trunk/chorem-webmotion/src/main/webapp/WEB-INF/jsp/viewActionEmployee.jsp =================================================================== --- trunk/chorem-webmotion/src/main/webapp/WEB-INF/jsp/viewActionEmployee.jsp (rev 0) +++ trunk/chorem-webmotion/src/main/webapp/WEB-INF/jsp/viewActionEmployee.jsp 2012-08-03 15:12:53 UTC (rev 225) @@ -0,0 +1,26 @@ +<%-- + #%L + Chorem webmotion + $Id:$ + $HeadURL:$ + %% + Copyright (C) 2011 - 2012 CodeLutin + %% + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 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 Affero General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. + #L% + --%> +<%@page contentType="text/html" pageEncoding="UTF-8"%> +<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> + +<a class="btn btn-success" href="<c:url value="/wikitty/ContactDetails/edit/new?ContactDetails.target=${wikitty.id}"/>"><i class="icon-plus icon-white"></i> Add Contact Details</a> Added: trunk/chorem-webmotion/src/main/webapp/WEB-INF/jsp/viewActionPerson.jsp =================================================================== --- trunk/chorem-webmotion/src/main/webapp/WEB-INF/jsp/viewActionPerson.jsp (rev 0) +++ trunk/chorem-webmotion/src/main/webapp/WEB-INF/jsp/viewActionPerson.jsp 2012-08-03 15:12:53 UTC (rev 225) @@ -0,0 +1,26 @@ +<%-- + #%L + Chorem webmotion + $Id:$ + $HeadURL:$ + %% + Copyright (C) 2011 - 2012 CodeLutin + %% + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 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 Affero General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. + #L% + --%> +<%@page contentType="text/html" pageEncoding="UTF-8"%> +<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> + +<a class="btn btn-success" href="<c:url value="/wikitty/ContactDetails/edit/new?ContactDetails.target=${wikitty.id}"/>"><i class="icon-plus icon-white"></i> Add Contact Details</a> Added: trunk/chorem-webmotion/src/main/webapp/WEB-INF/jsp/viewActionProject.jsp =================================================================== --- trunk/chorem-webmotion/src/main/webapp/WEB-INF/jsp/viewActionProject.jsp (rev 0) +++ trunk/chorem-webmotion/src/main/webapp/WEB-INF/jsp/viewActionProject.jsp 2012-08-03 15:12:53 UTC (rev 225) @@ -0,0 +1,26 @@ +<%-- + #%L + Chorem webmotion + $Id:$ + $HeadURL:$ + %% + Copyright (C) 2011 - 2012 CodeLutin + %% + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 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 Affero General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. + #L% + --%> +<%@page contentType="text/html" pageEncoding="UTF-8"%> +<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> + +<a class="btn btn-success" href="<c:url value="/wikitty/Quotation/edit/new?Quotation.project=${wikitty.id}"/>"><i class="icon-plus icon-white"></i> Add Quotation</a>
participants (1)
-
bpoussin@users.chorem.org