Skip to content
Permalink
Browse files

Merge branch 'dev' of https://github.com/MPDL/imeji.git into dev

  • Loading branch information...
helkv committed Apr 12, 2019
2 parents 248ca5e + a4078c7 commit ae772d249572f10a66e2ace558c812d790796224
Showing with 588 additions and 21 deletions.
  1. +1 −1 pom.xml
  2. +46 −1 src/main/java/de/mpg/imeji/logic/config/ImejiConfiguration.java
  3. +10 −0 src/main/java/de/mpg/imeji/logic/model/CollectionImeji.java
  4. +29 −2 src/main/java/de/mpg/imeji/logic/validation/impl/CollectionValidator.java
  5. +34 −1 src/main/java/de/mpg/imeji/presentation/admin/ConfigurationBean.java
  6. +29 −0 src/main/java/de/mpg/imeji/presentation/beans/UtilBean.java
  7. +14 −0 src/main/java/de/mpg/imeji/presentation/collection/CollectionBean.java
  8. +11 −0 src/main/java/de/mpg/imeji/presentation/collection/CreateCollectionBean.java
  9. +19 −0 src/main/java/de/mpg/imeji/presentation/collection/EditCollectionBean.java
  10. +8 −2 src/main/resources/labels_de.properties
  11. +8 −2 src/main/resources/labels_en.properties
  12. +9 −1 src/main/resources/labels_es.properties
  13. +8 −0 src/main/resources/labels_ja.properties
  14. +2 −0 src/main/resources/messages_de.properties
  15. +2 −0 src/main/resources/messages_en.properties
  16. +2 −0 src/main/resources/messages_es.properties
  17. +2 −0 src/main/resources/messages_ja.properties
  18. +141 −0 src/main/webapp/AdminConfigCollections.xhtml
  19. +4 −0 src/main/webapp/AdminOverview.xhtml
  20. +4 −0 src/main/webapp/WEB-INF/pretty-config.xml
  21. +44 −11 src/main/webapp/resources/components/collection/editForm.xhtml
  22. +131 −0 src/main/webapp/resources/js/combobox.js
  23. +27 −0 src/main/webapp/resources/js/default.js
  24. +1 −0 src/main/webapp/templates/component/footer/footer_imports.xhtml
  25. +2 −0 src/main/webapp/templates/sub_template/template_metadata_mediaContainer.xhtml
@@ -254,7 +254,7 @@
<artifactId>formatter-maven-plugin</artifactId>
<version>2.8.1</version>
<configuration>
<lineEnding>LF</lineEnding>
<!-- <lineEnding>LF</lineEnding>-->
<encoding>UTF-8</encoding>
<configFile>java-google-style-custom.xml</configFile>
</configuration>
@@ -10,6 +10,7 @@
import java.util.LinkedList;
import java.util.List;
import java.util.Properties;
import java.util.stream.Collectors;

import javax.faces.event.ValueChangeEvent;

@@ -21,6 +22,7 @@
import org.apache.http.util.EntityUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.lucene.queryparser.flexible.standard.CommonQueryParserConfiguration;
import org.codehaus.jettison.json.JSONArray;
import org.codehaus.jettison.json.JSONException;

@@ -94,7 +96,10 @@
DOI_PUBLISHER,
FACET_DISPLAYED,
PRIVACY_POLICY,
PRIVACY_POLICY_URL;
PRIVACY_POLICY_URL,
COLLECTION_TYPES,
COLLECTION_METADATA_SUGGESTIONS,
COLLECTION_METADATA_SELECTIONS_PRESELECT;
}

private static Properties config;
@@ -1019,6 +1024,45 @@ public void setFacetDisplayed(String str) {
setProperty(CONFIGURATION.FACET_DISPLAYED.name(), str);
}


public String getCollectionTypes() {
return getPropertyAsNonNullString(CONFIGURATION.COLLECTION_TYPES.name());
}

public List<String> getCollectionTypesAsList() {
return Arrays.stream(getCollectionTypes().split("\\n")).filter(i -> !i.isBlank()).map(i -> i.trim()).collect(Collectors.toList());
}

public void setCollectionTypes(String str) {
setProperty(CONFIGURATION.COLLECTION_TYPES.name(), str);
}

public String getCollectionMetadataSuggestions() {
return getPropertyAsNonNullString(CONFIGURATION.COLLECTION_METADATA_SUGGESTIONS.name());
}

public List<String> getCollectionMetadataSuggestionsAsList() {
return Arrays.stream(getCollectionMetadataSuggestions().split("\\n")).filter(i -> !i.isBlank()).map(i -> i.trim())
.collect(Collectors.toList());
}

public void setCollectionMetadataSuggestions(String str) {
setProperty(CONFIGURATION.COLLECTION_METADATA_SUGGESTIONS.name(), str);
}

public String getCollectionMetadataSuggestionsPreselect() {
return getPropertyAsNonNullString(CONFIGURATION.COLLECTION_METADATA_SELECTIONS_PRESELECT.name());
}

public List<String> getCollectionMetadataSuggestionsPreselectAsList() {
return Arrays.stream(getCollectionMetadataSuggestionsPreselect().split("\\n")).filter(i -> !i.isBlank()).map(i -> i.trim())
.collect(Collectors.toList());
}

public void setCollectionMetadataSuggestionsPreselect(String str) {
setProperty(CONFIGURATION.COLLECTION_METADATA_SELECTIONS_PRESELECT.name(), str);
}

// ------------------------------------------------------------------------
// Utility classes
// ------------------------------------------------------------------------
@@ -1136,4 +1180,5 @@ public void setInternalPassword() {
setDoiPassword(this.password);
}
}

}
@@ -39,6 +39,8 @@
private String doi;
@j2jResource("http://imeji.org/terms/logoUrl")
private URI logoUrl;
@j2jList("http://purl.org/dc/terms/type")
private List<String> types = new ArrayList<>();
private Collection<URI> images = new ArrayList<URI>();

public String getTitle() {
@@ -136,4 +138,12 @@ public String getUri() {
public ObjectType getType() {
return ObjectType.COLLECTION;
}

public List<String> getTypes() {
return types;
}

public void setTypes(List<String> types) {
this.types = types;
}
}
@@ -9,6 +9,7 @@
import java.util.regex.Pattern;

import de.mpg.imeji.exceptions.UnprocessableError;
import de.mpg.imeji.logic.config.Imeji;
import de.mpg.imeji.logic.model.CollectionImeji;
import de.mpg.imeji.logic.model.ContainerAdditionalInfo;
import de.mpg.imeji.logic.model.Organization;
@@ -35,6 +36,8 @@ public void validate(CollectionImeji collection, Method m) throws UnprocessableE
if (exception.hasMessages()) {
throw exception;
}

cleanUp(collection);
}

protected void validateContainerMetadata(CollectionImeji c) {
@@ -47,17 +50,29 @@ protected void validateContainerMetadata(CollectionImeji c) {
if (isNullOrEmpty(c.getTitle())) {
setException(new UnprocessableError("error_collection_need_title", getException()));
}
if (Imeji.CONFIG.getCollectionTypes() != null && !Imeji.CONFIG.getCollectionTypes().isBlank()
&& (c.getTypes() == null || c.getTypes().isEmpty())) {
setException(new UnprocessableError("error_collection_need_types", getException()));
}
validateAdditionalInfos(c);
}

private void validateAdditionalInfos(CollectionImeji c) {

for (final ContainerAdditionalInfo info : c.getAdditionalInformations()) {
if (isNullOrEmpty(info.getLabel())) {
if (isNullOrEmpty(info.getLabel()) && !isNullOrEmpty(info.getText())) {
setException(new UnprocessableError("error_additionalinfo_need_label", getException()));
}

if (info.getLabel().equals("Article DOI") && !isNullOrEmpty(info.getText())) {
validateDOI(info.getText());
}
/*
if (isNullOrEmpty(info.getText()) && isNullOrEmpty(info.getUrl())) {
setException(new UnprocessableError("error_additionalinfo_need_value", getException()));
//setException(new UnprocessableError("error_additionalinfo_need_value", getException()));
}
*/
}
}

@@ -180,4 +195,16 @@ private void setException(UnprocessableError e) {
private UnprocessableError getException() {
return exception;
}

private void cleanUp(CollectionImeji c) {
List<ContainerAdditionalInfo> toBeRemoved = new ArrayList<>();

for (final ContainerAdditionalInfo info : c.getAdditionalInformations()) {

if (isNullOrEmpty(info.getText()) && isNullOrEmpty(info.getUrl())) {
toBeRemoved.add(info);
}
}
c.getAdditionalInformations().removeAll(toBeRemoved);
}
}
@@ -15,8 +15,8 @@
import de.mpg.imeji.logic.config.Imeji;
import de.mpg.imeji.logic.config.ImejiConfiguration.HtmlSnippet;
import de.mpg.imeji.logic.config.ImejiConfiguration.ProtectedPassword;
import de.mpg.imeji.logic.config.emailcontent.contentxml.EmailContentXML;
import de.mpg.imeji.logic.config.ImejiFileTypes;
import de.mpg.imeji.logic.config.emailcontent.contentxml.EmailContentXML;
import de.mpg.imeji.logic.model.ImejiLicenses;
import de.mpg.imeji.logic.storage.util.ImageMagickUtils;
import de.mpg.imeji.presentation.beans.SuperBean;
@@ -665,4 +665,37 @@ public String getGUILabel(String identifier) {
return Imeji.RESOURCE_BUNDLE.getLabel(identifier, getLocale());
}


public String getCollectionTypes() {
return Imeji.CONFIG.getCollectionTypes();
}

public void setCollectionTypes(String str) {
Imeji.CONFIG.setCollectionTypes(str);
}

public String getCollectionMetadataSuggestions() {
return Imeji.CONFIG.getCollectionMetadataSuggestions();
}

public List<String> getCollectionMetadataSuggestionsAsList() {
return Imeji.CONFIG.getCollectionMetadataSuggestionsAsList();
}

public void setCollectionMetadataSuggestions(String str) {
Imeji.CONFIG.setCollectionMetadataSuggestions(str);
}

public String getCollectionMetadataSuggestionsPreselect() {
return Imeji.CONFIG.getCollectionMetadataSuggestionsPreselect();
}

public List<String> getCollectionMetadataSuggestionsPreselectAsList() {
return Imeji.CONFIG.getCollectionMetadataSuggestionsPreselectAsList();
}

public void setCollectionMetadataSuggestionsPreselect(String str) {
Imeji.CONFIG.setCollectionMetadataSuggestionsPreselect(str);;
}

}
@@ -0,0 +1,29 @@
package de.mpg.imeji.presentation.beans;

import java.util.List;

import javax.enterprise.context.RequestScoped;
import javax.faces.bean.ManagedBean;

@ManagedBean(name = "UtilBean")
@RequestScoped
public class UtilBean {


public String toJavascriptArray(List<?> arr) {
if (arr != null) {
StringBuffer sb = new StringBuffer();
sb.append("[");
for (int i = 0; i < arr.size(); i++) {
sb.append("\"").append(arr.get(i)).append("\"");
if (i + 1 < arr.size()) {
sb.append(",");
}
}
sb.append("]");
return sb.toString();
} else
return "Null";
}

}
@@ -1,8 +1,12 @@
package de.mpg.imeji.presentation.collection;

import java.net.URI;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import javax.faces.model.SelectItem;

import de.mpg.imeji.logic.config.Imeji;
import de.mpg.imeji.logic.model.CollectionImeji;
import de.mpg.imeji.logic.model.ContainerAdditionalInfo;
@@ -184,4 +188,14 @@ public String removeContainerLogo() {
collection.setLogoUrl(null);
return "";
}


public List<SelectItem> getCollectionTypesSelectItems() {
List<SelectItem> selectItemList = new ArrayList<SelectItem>();
for (String entry : Imeji.CONFIG.getCollectionTypesAsList()) {
selectItemList.add(new SelectItem(entry, entry));
}

return selectItemList;
}
}
@@ -19,6 +19,7 @@
import de.mpg.imeji.logic.config.Imeji;
import de.mpg.imeji.logic.core.collection.CollectionService;
import de.mpg.imeji.logic.model.CollectionImeji;
import de.mpg.imeji.logic.model.ContainerAdditionalInfo;
import de.mpg.imeji.logic.model.Organization;
import de.mpg.imeji.logic.model.Person;
import de.mpg.imeji.logic.model.factory.ImejiFactory;
@@ -50,6 +51,16 @@
public void init() {
showUpload = UrlHelper.getParameterBoolean("showUpload");
setCollection(ImejiFactory.newCollection().setPerson(getSessionUser().getPerson().clone()).build());

List<String> preselectedMetadataLabels = Imeji.CONFIG.getCollectionMetadataSuggestionsPreselectAsList();

if (preselectedMetadataLabels != null && !preselectedMetadataLabels.isEmpty()) {
for (String s : preselectedMetadataLabels) {
getCollection().getAdditionalInformations().add(new ContainerAdditionalInfo(s, "", null));
}
}
//Add one more
getCollection().getAdditionalInformations().add(new ContainerAdditionalInfo());
containerEditorSession.setUploadedLogoPath(null);
}

@@ -5,8 +5,10 @@
import java.net.URI;
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import java.util.stream.Collectors;

import javax.annotation.PostConstruct;
import javax.faces.bean.ManagedBean;
@@ -21,6 +23,7 @@
import de.mpg.imeji.logic.config.Imeji;
import de.mpg.imeji.logic.core.collection.CollectionService;
import de.mpg.imeji.logic.model.CollectionImeji;
import de.mpg.imeji.logic.model.ContainerAdditionalInfo;
import de.mpg.imeji.logic.model.Organization;
import de.mpg.imeji.logic.model.Person;
import de.mpg.imeji.logic.model.User;
@@ -57,6 +60,22 @@ public void init() {
persons.add(p);
}
getCollection().setPersons(persons);

List<String> preselectedMetadata = Imeji.CONFIG.getCollectionMetadataSuggestionsPreselectAsList();
if (preselectedMetadata != null && !preselectedMetadata.isEmpty()) {
List<String> labels = getCollection().getAdditionalInformations().stream().map(i -> i.getLabel()).collect(Collectors.toList());
int pos = 0;
for (String mdLabel : preselectedMetadata) {
if (!labels.contains(mdLabel)) {
getCollection().getAdditionalInformations().add(pos, new ContainerAdditionalInfo(mdLabel, "", ""));
} else {
pos++;
}
}
}
//Always add empty additional info at the end
getCollection().getAdditionalInformations().add(new ContainerAdditionalInfo());

} catch (final ImejiException e) {
BeanHelper.error("Error initiatilzing page: " + e.getMessage());
LOGGER.error("Error init edit collection page", e);
@@ -251,7 +251,7 @@ colCreator = Die Sammlung wurde erstellt von

colNumItems = Anzahl der Inhalte in dieser Sammlung

colUtil = Zus\u00E4tzliche Informationen
colUtil = Sammlungsmetadaten

collection = Sammlung

@@ -277,6 +277,10 @@ collection_list_default = Alle Inhalte

collection_metadata = Sammlungs-Metadaten

collection_metadata_autosuggest = Sammlungs-Metadaten Autosuggest Felder

collection_metadata_preselect = Sammlungs-Metadatenfelder (sichtbar beim Erstellen/Bearbeiten von Sammlungen)

collection_release = Sammlung ver\u00F6ffentlichen

collection_share = Sammlung teilen
@@ -287,6 +291,8 @@ collection_share_collection_edit = Bearbeiten

collection_share_read = Lesen

collection_types = Typ(en)

collection_view_all_images = Alle Inhalte der Sammlung anzeigen

collection_view_images = Inhalte anzeigen
@@ -974,7 +980,7 @@ pending_invitations = Noch nicht angenommen Einladungen

permalink = Permalink

placeholder_additional_info_label = e.g. Website, Publication.
placeholder_additional_info_label = tippen oder ausw\u00E4hlen...

placeholder_date = 2000-01-01 oder 2000-01 oder 2000

Oops, something went wrong.

0 comments on commit ae772d2

Please sign in to comment.
You can’t perform that action at this time.