Commit badc9df4 authored by Matija Obreza's avatar Matija Obreza

CMS: Constant ENTITY_BLURB_SLUG

parent 264f5b2b
......@@ -141,7 +141,7 @@ public class InstituteController {
InstituteDetails details = new InstituteDetails();
details.details = faoInstitute;
details.blurb = contentService.getArticle(faoInstitute, "blurp", getLocale());
details.blurb = contentService.getArticle(faoInstitute, ContentService.ENTITY_BLURB_SLUG, getLocale());
details.pdciStats = faoInstitute.getStatisticsPDCI();
details.lastUpdates = genesysService.getLastUpdatedStatistics(faoInstitute);
details.overview = getOverviewData(byInstituteFilter);
......
......@@ -91,7 +91,7 @@ public class CountryController extends BaseController {
model.addAttribute("region", geoRegionService.getRegion(country));
model.addAttribute("itpgrfa", geoService.getITPGRFAStatus(country));
model.addAttribute("blurp", contentService.getArticle(country, "blurp", getLocale()));
model.addAttribute("blurp", contentService.getArticle(country, ContentService.ENTITY_BLURB_SLUG, getLocale()));
// All institutes
model.addAttribute("faoInstitutes", instituteService.listByCountry(country));
......
......@@ -136,7 +136,7 @@ public class CropController extends BaseController {
model.addAttribute("jsonFilter", appliedFilters.toString());
model.addAttribute("cropRules", cropService.getCropRules(crop));
model.addAttribute("cropTaxonomies", cropService.getCropTaxonomies(crop, new PageRequest(0, 21, new Sort("taxonomy.genus", "taxonomy.species"))));
model.addAttribute("blurp", contentService.getArticle(crop, "blurp", getLocale()));
model.addAttribute("blurp", contentService.getArticle(crop, ContentService.ENTITY_BLURB_SLUG, getLocale()));
// model.addAttribute("statsGenus",
// elasticService.termStatisticsAuto(appliedFilters,
......
......@@ -46,7 +46,7 @@ public class GeoRegionController extends BaseController {
Country.sort(countryList, getLocale());
model.addAttribute("region", geoRegion);
model.addAttribute("blurp", contentService.getArticle(geoRegion, "blurp", getLocale()));
model.addAttribute("blurp", contentService.getArticle(geoRegion, ContentService.ENTITY_BLURB_SLUG, getLocale()));
List<GeoRegion> subRegions = geoRegionService.getChildren(geoRegion.getIsoCode());
GeoRegion.sort(subRegions, getLocale());
model.addAttribute("subRegions", subRegions);
......@@ -77,7 +77,7 @@ public class GeoRegionController extends BaseController {
throw new NotFoundElement();
}
//isTemplate = false because it's region.
contentService.updateArticle(region, "blurp", null, body, summary, getLocale());
contentService.updateArticle(region, ContentService.ENTITY_BLURB_SLUG, null, body, summary, getLocale());
return "redirect:/geo/regions/" + code;
}
......
......@@ -93,7 +93,7 @@ public class OrganizationController extends BaseController {
model.addAttribute("organization", network);
model.addAttribute("members", members);
model.addAttribute("blurp", contentService.getArticle(network, "blurp", getLocale()));
model.addAttribute("blurp", contentService.getArticle(network, ContentService.ENTITY_BLURB_SLUG, getLocale()));
model.addAttribute("statisticsPDCI", statisticsService.statisticsPDCI(network));
return "/organization/details";
......
......@@ -108,7 +108,7 @@ public class ProjectController extends BaseController {
model.addAttribute("project", project);
List<AccessionList> accessionLists = accessionListService.getLists(project.getAccessionLists());
model.addAttribute("accessionLists", accessionLists);
model.addAttribute("blurp", contentService.getArticle(project, "blurp", getLocale()));
model.addAttribute("blurp", contentService.getArticle(project, ContentService.ENTITY_BLURB_SLUG, getLocale()));
// Statistics
int countByProject = accessionListService.distinctCount(accessionLists);
......
......@@ -67,7 +67,7 @@ public class TeamController extends BaseController {
}
model.addAttribute("team", team);
model.addAttribute("teammembers", teamService.getMembers(team));
model.addAttribute("blurp", contentService.getArticle(team, "blurp", getLocale()));
model.addAttribute("blurp", contentService.getArticle(team, ContentService.ENTITY_BLURB_SLUG, getLocale()));
return "/team/details";
}
......@@ -85,7 +85,7 @@ public class TeamController extends BaseController {
} catch (final UsernameNotFoundException e) {
model.addAttribute("team", team);
model.addAttribute("teammembers", teamService.getMembers(team));
model.addAttribute("blurp", contentService.getArticle(team, "blurp", getLocale()));
model.addAttribute("blurp", contentService.getArticle(team, ContentService.ENTITY_BLURB_SLUG, getLocale()));
model.addAttribute("error", "error");
return "/team/details";
}
......
......@@ -177,7 +177,7 @@ public class WiewsController extends BaseController {
model.addAttribute("faoInstitute", faoInstitute);
model.addAttribute("organizations", networkService.getNetworksFor(faoInstitute));
LOG.trace("organizations after {}ms", stopWatch.getTime());
model.addAttribute("blurp", contentService.getArticle(faoInstitute, "blurp", getLocale()));
model.addAttribute("blurp", contentService.getArticle(faoInstitute, ContentService.ENTITY_BLURB_SLUG, getLocale()));
LOG.trace("blurp after {}ms", stopWatch.getTime());
model.addAttribute("countByInstitute", faoInstitute.getAccessionCount());
......
......@@ -34,6 +34,7 @@ import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
public interface ContentService {
public final String ENTITY_BLURB_SLUG = "blurp";
public final String ABOUT = "about";
public final String WELCOME = "welcome";
......@@ -68,7 +69,7 @@ public interface ContentService {
public final String DELETE_ACCOUNT_SENT = "account-delete-requested";
public final String DELETE_ACCOUNT_CONFIRMED = "account-delete-confirmed";
public final String SMTP_DELETE_ACCOUNT_INPROGRESS = "smtp-delete-account-inprogress";
List<ActivityPost> lastNews();
Page<ActivityPost> allNews(int page);
......
......@@ -162,7 +162,7 @@ public class CropServiceImpl implements CropService {
StopWatch stopWatch = StopWatch.createStarted();
Crop crop = getCrop(shortName);
LOG.trace("got crop after {}ms", stopWatch.getTime());
Article article = contentService.getArticle(crop, "blurp", locale);
Article article = contentService.getArticle(crop, ContentService.ENTITY_BLURB_SLUG, locale);
LOG.trace("got article after {}ms", stopWatch.getTime());
AccessionFilter byCrop = new AccessionFilter();
byCrop.crop = Sets.newHashSet(crop.getShortName());
......@@ -194,7 +194,7 @@ public class CropServiceImpl implements CropService {
@Transactional(readOnly = false)
public void updateBlurp(Crop crop, String textBody, String summary, Locale locale) throws CRMException {
//isTemplate = false because it's crop
contentService.updateArticle(crop, "blurp", null, textBody, summary, locale);
contentService.updateArticle(crop, ContentService.ENTITY_BLURB_SLUG, null, textBody, summary, locale);
}
@Override
......
......@@ -444,7 +444,7 @@ public class GeoServiceImpl implements GeoService {
@Transactional(readOnly = false)
public void updateBlurp(Country country, String blurp, Locale locale) throws CRMException {
// TODO Should we provide summary?
contentService.updateArticle(country, "blurp", null, blurp, null, locale);
contentService.updateArticle(country, ContentService.ENTITY_BLURB_SLUG, null, blurp, null, locale);
}
@Override
......
......@@ -201,7 +201,7 @@ public class InstituteServiceImpl implements InstituteService {
@PreAuthorize("hasRole('ADMINISTRATOR') or hasPermission(#faoInstitute, 'ADMINISTRATION')")
@Transactional(readOnly = false)
public void updateAbout(FaoInstitute faoInstitute, String body, String summary, Locale locale) throws CRMException {
contentService.updateArticle(faoInstitute, "blurp", null, body, summary, locale);
contentService.updateArticle(faoInstitute, ContentService.ENTITY_BLURB_SLUG, null, body, summary, locale);
}
@Override
......
......@@ -87,14 +87,14 @@ public class PGRFANetworkServiceImpl implements PGRFANetworkService {
@Override
public Article getBlurb(PGRFANetwork network, Locale locale) {
return contentService.getArticle(network, "blurp", locale);
return contentService.getArticle(network, ContentService.ENTITY_BLURB_SLUG, locale);
}
@Override
@PreAuthorize("hasRole('ADMINISTRATOR') || hasPermission(network, 'write')")
@Transactional(readOnly = false)
public Article updateAbout(@Valid PGRFANetwork network, String body, String summary, Locale locale) throws CRMException {
return contentService.updateArticle(network, "blurp", null, body, summary, locale);
return contentService.updateArticle(network, ContentService.ENTITY_BLURB_SLUG, null, body, summary, locale);
}
@Override
......
......@@ -87,6 +87,6 @@ public class ProjectServiceImpl implements ProjectService {
@Transactional
public void updateBlurp(Project project, String textBody, String summary, Locale locale) throws CRMException {
//isTemplate = false because it's project.
contentService.updateArticle(project, "blurp", null, textBody, summary, locale);
contentService.updateArticle(project, ContentService.ENTITY_BLURB_SLUG, null, textBody, summary, locale);
}
}
......@@ -427,7 +427,7 @@ public class CropsControllerTest extends AbstractApiTest {
}
private Article setupBlurb() throws CRMException {
return contentService.updateArticle(crop, "blurp", "Test title", "Test descr", "test Summar", Locale.ENGLISH);
return contentService.updateArticle(crop, ContentService.ENTITY_BLURB_SLUG, "Test title", "Test descr", "test Summar", Locale.ENGLISH);
}
private Accession setupAccession() {
......
......@@ -16,12 +16,13 @@
package org.genesys.test.server.api.v1;
import static org.hamcrest.Matchers.*;
import static org.junit.Assert.*;
import static org.junit.Assert.assertEquals;
import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.*;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.collect.Lists;
import java.util.Locale;
import org.apache.commons.lang3.StringUtils;
import org.genesys.test.base.AbstractApiTest;
import org.genesys2.server.api.v1.NetworkController;
import org.genesys2.server.model.impl.Article;
......@@ -40,12 +41,11 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.security.test.context.support.WithMockUser;
import org.springframework.transaction.annotation.Transactional;
import org.apache.commons.lang3.StringUtils;
import java.util.Locale;
import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.*;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.collect.Lists;
public class NetworkControllerTest extends AbstractApiTest {
......@@ -245,7 +245,7 @@ public class NetworkControllerTest extends AbstractApiTest {
}
private Article setupBlurb(PGRFANetwork network) throws CRMException {
return contentService.updateArticle(network, "blurp", BLURB_TITLE_1, BLURB_BODY_1, BLURB_SUMMARY_1, Locale.ENGLISH);
return contentService.updateArticle(network, ContentService.ENTITY_BLURB_SLUG, BLURB_TITLE_1, BLURB_BODY_1, BLURB_SUMMARY_1, Locale.ENGLISH);
}
}
......@@ -153,6 +153,7 @@ public class PGRFANetworkServiceTest extends AbstractServicesTest {
setupBlurb(network);
Article article = articleRepository.findAll().get(0);
assertEquals(article.getTargetId(), network.getId());
assertEquals(ContentService.ENTITY_BLURB_SLUG, article.getSlug());
assertEquals(BLURB_BODY_1, article.getBody());
assertEquals(BLURB_SUMMARY_1, article.getSummary());
assertEquals(BLURB_TITLE_1, article.getTitle());
......@@ -205,7 +206,7 @@ public class PGRFANetworkServiceTest extends AbstractServicesTest {
}
private Article setupBlurb(PGRFANetwork network) throws CRMException {
return contentService.updateArticle(network, "blurb", BLURB_TITLE_1, BLURB_BODY_1, BLURB_SUMMARY_1, Locale.ENGLISH);
return contentService.updateArticle(network, ContentService.ENTITY_BLURB_SLUG, BLURB_TITLE_1, BLURB_BODY_1, BLURB_SUMMARY_1, Locale.ENGLISH);
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment