Skip to content
Snippets Groups Projects
Commit 519da8b4 authored by Tor-Einar Skog's avatar Tor-Einar Skog
Browse files

Added navigation features for crops and pests

parent 86de6c60
Branches
Tags
No related merge requests found
Showing with 99 additions and 5 deletions
......@@ -20,7 +20,6 @@
package no.nibio.vips.logic.controller.servlet;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import javax.persistence.EntityManager;
......@@ -29,12 +28,10 @@ import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import no.nibio.vips.logic.controller.session.UserBean;
import no.nibio.vips.logic.entity.CropPest;
import no.nibio.vips.logic.entity.Organism;
import no.nibio.vips.logic.entity.OrganismExternalResource;
import no.nibio.vips.logic.entity.OrganismExternalResourcePK;
import no.nibio.vips.logic.entity.VipsLogicUser;
import no.nibio.vips.logic.i18n.SessionLocaleUtil;
import no.nibio.vips.logic.util.SessionControllerGetter;
import no.nibio.vips.util.ExceptionUtil;
......@@ -113,6 +110,18 @@ public class OrganismController extends HttpServlet {
}
}
}
else if(action.equals("listCrops"))
{
request.setAttribute("allCrops", em.createNamedQuery("Organism.findAllCrops").getResultList());
request.setAttribute("hierarchyCategories", SessionControllerGetter.getOrganismBean().getHierarchyCategoryNames(SessionLocaleUtil.getCurrentLocale(request)));
request.getRequestDispatcher("/cropList.ftl").forward(request, response);
}
else if(action.equals("listPests"))
{
request.setAttribute("allPests", em.createNamedQuery("Organism.findAllPests").getResultList());
request.setAttribute("hierarchyCategories", SessionControllerGetter.getOrganismBean().getHierarchyCategoryNames(SessionLocaleUtil.getCurrentLocale(request)));
request.getRequestDispatcher("/pestList.ftl").forward(request, response);
}
else if(action.equals("viewOrganism"))
{
try
......
......@@ -342,3 +342,6 @@ isPrivate=Is private
privateForecasts=Private forecasts
privateForecastsForOtherUser=Private forecasts for other user
noPrivateForecastsFoundForUser=No private forecasts found for user
listCrops=List all crops
listPests=List all pests
allPests=All pests
......@@ -342,3 +342,6 @@ isPrivate=Is private
privateForecasts=Private forecasts
privateForecastsForOtherUser=Private forecasts for other user
noPrivateForecastsFoundForUser=No private forecasts found for user
listCrops=List all crops
listPests=List all pests
allPests=All pests
......@@ -341,3 +341,6 @@ isPrivate=Is private
privateForecasts=Private forecasts
privateForecastsForOtherUser=Private forecasts for other user
noPrivateForecastsFoundForUser=No private forecasts found for user
listCrops=List all crops
listPests=List all pests
allPests=All pests
......@@ -342,3 +342,6 @@ isPrivate=Er privat
privateForecasts=Private varsler
privateForecastsForOtherUser=Private varsler for annen bruker
noPrivateForecastsFoundForUser=Fant ingen private varsler for brukeren
listCrops=Kulturliste
listPests=Skadegj\u00f8rerliste
allPests=Alle skadegj\u00f8rere
......@@ -342,3 +342,6 @@ isPrivate=Is private
privateForecasts=Private forecasts
privateForecastsForOtherUser=Private forecasts for other user
noPrivateForecastsFoundForUser=No private forecasts found for user
listCrops=List all crops
listPests=List all pests
allPests=All pests
<#--
Copyright (c) 2016 NIBIO <http://www.nibio.no/>.
This file is part of VIPSLogic.
VIPSLogic is free software: you can redistribute it and/or modify
it under the terms of the NIBIO Open Source License as published by
NIBIO, either version 1 of the License, or (at your option) any
later version.
VIPSLogic 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
NIBIO Open Source License for more details.
You should have received a copy of the NIBIO Open Source License
along with VIPSLogic. If not, see <http://www.nibio.no/licenses/>.
--><#include "master.ftl">
<#macro page_head>
<title>${i18nBundle.allCrops}</title>
</#macro>
<#macro page_contents>
<div class="singleBlockContainer">
<h1>${i18nBundle.allCrops}</h1>
<a href="/organism" class="btn btn-default" role="button">${i18nBundle.organisms}</a>
<a href="/organism?action=listPests" class="btn btn-default" role="button">${i18nBundle.listPests}</a>
<ul>
<#list allCrops as cropOrganism>
<li><a href="/organism?action=viewOrganism&organismId=${cropOrganism.organismId}">${cropOrganism.getLocalName(currentLocale.language)!""} (${cropOrganism.latinName!""}) ${hierarchyCategories.getName(cropOrganism.hierarchyCategoryId)?upper_case}</a></li>
</#list>
</ul>
</div>
</#macro>
<@page_html/>
......@@ -227,7 +227,7 @@
<#list allCrops?sort_by("latinName") as cropOrganism>
<option value="${cropOrganism.organismId}"
<#if (observation.cropOrganism?has_content && observation.cropOrganism.organismId == cropOrganism.organismId)>selected="selected"</#if>
>${cropOrganism.latinName!""}/${cropOrganism.getLocalName(currentLocale.language)!""} (${hierarchyCategories.getName(cropOrganism.hierarchyCategoryId)})</option>
>${cropOrganism.getLocalName(currentLocale.language)!""} (${cropOrganism.latinName!""}) ${hierarchyCategories.getName(cropOrganism.hierarchyCategoryId)?upper_case}</option>
</#list>
</select>
<span class="help-block" id="${formId}_cropOrganismId_validation"></span>
......@@ -243,7 +243,7 @@
<#list allPests?sort_by("latinName") as organism>
<option value="${organism.organismId}"
<#if (observation.organism?has_content && observation.organism.organismId == organism.organismId)>selected="selected"</#if>
>${organism.latinName!""}/${organism.getLocalName(currentLocale.language)!""} (${hierarchyCategories.getName(organism.hierarchyCategoryId)})</option>
>${organism.getLocalName(currentLocale.language)!""} (${organism.latinName!""}) ${hierarchyCategories.getName(organism.hierarchyCategoryId)?upper_case}</option>
</#list>
</select>
<span class="help-block" id="${formId}_organismId_validation"></span>
......
......@@ -31,6 +31,8 @@
<#if user.isSuperUser()>
<a href="/organism?action=newOrganismForm&parentOrganismId=${organism.organismId!""}" class="btn btn-default" role="button">${i18nBundle.addNew}</a>
</#if>
<a href="/organism?action=listCrops" class="btn btn-default" role="button">${i18nBundle.listCrops}</a>
<a href="/organism?action=listPests" class="btn btn-default" role="button">${i18nBundle.listPests}</a>
<#if organism.organismId?has_content>
<a href="/organism?action=listChildOrganisms&organismId=${organism.parentOrganismId!""}" class="btn btn-default" role="button">${i18nBundle.up}</a>
<a href="/organism" class="btn btn-default" role="button">${i18nBundle.toTheTop}</a>
......
<#--
Copyright (c) 2016 NIBIO <http://www.nibio.no/>.
This file is part of VIPSLogic.
VIPSLogic is free software: you can redistribute it and/or modify
it under the terms of the NIBIO Open Source License as published by
NIBIO, either version 1 of the License, or (at your option) any
later version.
VIPSLogic 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
NIBIO Open Source License for more details.
You should have received a copy of the NIBIO Open Source License
along with VIPSLogic. If not, see <http://www.nibio.no/licenses/>.
--><#include "master.ftl">
<#macro page_head>
<title>${i18nBundle.allPests}</title>
</#macro>
<#macro page_contents>
<div class="singleBlockContainer">
<h1>${i18nBundle.allPests}</h1>
<a href="/organism" class="btn btn-default" role="button">${i18nBundle.organisms}</a>
<a href="/organism?action=listCrops" class="btn btn-default" role="button">${i18nBundle.listCrops}</a>
<ul>
<#list allPests as pestOrganism>
<li><a href="/organism?action=viewOrganism&organismId=${pestOrganism.organismId}">${pestOrganism.getLocalName(currentLocale.language)!""} (${pestOrganism.latinName!""}) ${hierarchyCategories.getName(pestOrganism.hierarchyCategoryId)?upper_case}</a></li>
</#list>
</ul>
</div>
</#macro>
<@page_html/>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment