-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Story/vspc 213 #302
Merged
Merged
Story/vspc 213 #302
Changes from 19 commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
5b25410
[story/VSPC-213]added exhibitionlanguage codes
c3f1f8b
[story/VSPC-213] added configuration for language codes and labels
c770d63
[story/VSPC-213] added support for multiple exhibition languages
959b957
[story/VSPC-213] added test cases
bf91424
[story/VSPC-213] added code for default language
cbf9519
[VSPC-213] refactor
f3285d4
[story/VSPC-213] codefactor
7ac5aed
[story/VSPC-213] refactor
ff7a491
[story/VSPC-213] revert unwanted file changes
1e883bd
[story/VSPC-213] review comments
e313921
[story/VSPC-213] modified prefix of exhibition language
52e2fd5
[story/VSPC-213] added exceptions. modified exhibition language config
4575ca4
[story/VSPC-213] added check for only one default language per exhibi…
f57fa0a
[story/VSPC-213] code factor
7a8e502
[story/VSPC-213] code factor
0784a7b
[story/VSPC-213] refactor
5382226
[story/VSPC-213] refactor
00cc39f
[story/VSPC-213] added interface for Exhibition language
98a3eb8
[story/VSPC-213] code factor
07f65c6
[story/VSPC-213] Merged develop into story/VSPC-213
00d8754
[story/VSPC-213] langauge list config not found added to exception ha…
1c566b7
[story/VSPC-213] refactor
39b9f8b
[story/VSPC-213] modified language list config not found exception
bcd81b6
[story/VSPC-213] refactor
72f033b
[story/VSPC-213] review comments
dcac0ab
[story/VSPC-213] removed LanguageListConfigException declaration
33712c2
[story/VSPC-213] refactor
550a4ee
[story/VSPC-213] remove exhibitionlanguage if unselected
4cea3c2
[story/VSPC-213] added test case
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
12 changes: 12 additions & 0 deletions
12
vspace/src/main/java/edu/asu/diging/vspace/config/ConfigConstants.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package edu.asu.diging.vspace.config; | ||
|
||
public interface ConfigConstants { | ||
public final static String EXHIBITION_LANGUAGE_LIST_PROPERTY= "exhibition-language-list"; | ||
|
||
public final static String LABEL= "label"; | ||
|
||
public final static String CODE= "code"; | ||
|
||
public final static String LANGUAGES= "languages"; | ||
|
||
} |
57 changes: 57 additions & 0 deletions
57
vspace/src/main/java/edu/asu/diging/vspace/config/ExhibitionLanguageConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package edu.asu.diging.vspace.config; | ||
|
||
import java.io.Serializable; | ||
import java.util.ArrayList; | ||
import java.util.Iterator; | ||
import java.util.LinkedHashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.stream.Collectors; | ||
|
||
import javax.annotation.PostConstruct; | ||
|
||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.context.annotation.PropertySource; | ||
import org.springframework.core.env.AbstractEnvironment; | ||
import org.springframework.core.env.Environment; | ||
import org.springframework.core.env.MapPropertySource; | ||
import org.springframework.stereotype.Component; | ||
|
||
import edu.asu.diging.vspace.core.model.impl.ExhibitionLanguage; | ||
import org.springframework.core.env.MutablePropertySources; | ||
|
||
|
||
@Component | ||
@PropertySource(value= "classpath:exhibitionLanguages.properties" , factory=JsonPropertySourceFactory.class) | ||
@Configuration | ||
public class ExhibitionLanguageConfig { | ||
|
||
@Autowired | ||
private Environment environment; | ||
|
||
private List<Map> exhibitionLanguageList = new ArrayList<Map>(); | ||
|
||
/** | ||
* Fetches the configured language list from environment property source and stores in exhibitionLanguageList | ||
* | ||
*/ | ||
@PostConstruct | ||
public void init() { | ||
|
||
org.springframework.core.env.PropertySource<?> propertySource = ((AbstractEnvironment) environment).getPropertySources().get(ConfigConstants.EXHIBITION_LANGUAGE_LIST_PROPERTY); | ||
if( propertySource != null ) { | ||
Map<String, Object> languageMap = (Map<String, Object>) propertySource.getSource(); | ||
exhibitionLanguageList = (List<Map>) languageMap.get(ConfigConstants.LANGUAGES); | ||
} | ||
|
||
} | ||
|
||
public List<Map> getExhibitionLanguageList() { | ||
return exhibitionLanguageList; | ||
} | ||
public void setExhibitionLanguageList(List<Map> exhibitionLanguageList) { | ||
this.exhibitionLanguageList = exhibitionLanguageList; | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
vspace/src/main/java/edu/asu/diging/vspace/config/JsonPropertySourceFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package edu.asu.diging.vspace.config; | ||
|
||
import java.io.IOException; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.core.env.MapPropertySource; | ||
import org.springframework.core.io.support.EncodedResource; | ||
import org.springframework.core.io.support.PropertySourceFactory; | ||
|
||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
|
||
public class JsonPropertySourceFactory implements PropertySourceFactory { | ||
|
||
|
||
/** | ||
* Converts language json read from properties file to a map and stores in property source. | ||
* | ||
*/ | ||
@Override | ||
public org.springframework.core.env.PropertySource<?> createPropertySource(String name, EncodedResource resource) | ||
throws IOException { | ||
Map<String, Object> readValue = new ObjectMapper() | ||
.readValue(resource.getInputStream(), Map.class); | ||
return new MapPropertySource(ConfigConstants.EXHIBITION_LANGUAGE_LIST_PROPERTY, readValue); | ||
} | ||
} | ||
|
27 changes: 27 additions & 0 deletions
27
...src/main/java/edu/asu/diging/vspace/core/exception/LanguageListConfigurationNotFound.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package edu.asu.diging.vspace.core.exception; | ||
|
||
public class LanguageListConfigurationNotFound extends Exception { | ||
|
||
private static final long serialVersionUID = 1L; | ||
|
||
public LanguageListConfigurationNotFound() { | ||
super(); | ||
} | ||
|
||
public LanguageListConfigurationNotFound(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { | ||
super(message, cause, enableSuppression, writableStackTrace); | ||
} | ||
|
||
public LanguageListConfigurationNotFound(String message, Throwable cause) { | ||
super(message, cause); | ||
} | ||
|
||
public LanguageListConfigurationNotFound(String message) { | ||
super(message); | ||
} | ||
|
||
public LanguageListConfigurationNotFound(Throwable cause) { | ||
super(cause); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
vspace/src/main/java/edu/asu/diging/vspace/core/model/IExhibitionLanguage.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package edu.asu.diging.vspace.core.model; | ||
|
||
public interface IExhibitionLanguage extends IVSpaceElement { | ||
|
||
String getCode(); | ||
|
||
String getLabel(); | ||
|
||
boolean isDefault(); | ||
|
||
void setDefault(boolean isDefault); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,25 @@ | ||
package edu.asu.diging.vspace.core.model.impl; | ||
|
||
import java.util.ArrayList; | ||
import java.util.HashSet; | ||
import java.util.List; | ||
import java.util.Objects; | ||
import java.util.Set; | ||
|
||
import javax.persistence.CascadeType; | ||
import javax.persistence.Entity; | ||
import javax.persistence.EnumType; | ||
import javax.persistence.Enumerated; | ||
import javax.persistence.GeneratedValue; | ||
import javax.persistence.Id; | ||
import javax.persistence.OneToMany; | ||
import javax.persistence.OneToOne; | ||
import org.hibernate.annotations.GenericGenerator; | ||
import org.hibernate.annotations.Parameter; | ||
import edu.asu.diging.vspace.core.model.ExhibitionModes; | ||
import edu.asu.diging.vspace.core.model.IContentBlock; | ||
import edu.asu.diging.vspace.core.model.IExhibition; | ||
import edu.asu.diging.vspace.core.model.IExhibitionLanguage; | ||
import edu.asu.diging.vspace.core.model.ISpace; | ||
|
||
/** | ||
|
@@ -37,6 +47,9 @@ public class Exhibition extends VSpaceElement implements IExhibition { | |
private String customMessage; | ||
|
||
private boolean aboutPageConfigured; | ||
|
||
@OneToMany(targetEntity = ExhibitionLanguage.class, mappedBy = "exhibition", cascade = CascadeType.ALL) | ||
private List<IExhibitionLanguage> languages = new ArrayList<IExhibitionLanguage>(); | ||
|
||
/* | ||
* (non-Javadoc) | ||
|
@@ -116,4 +129,31 @@ public void setAboutPageConfigured(boolean aboutPageConfigured) { | |
this.aboutPageConfigured = aboutPageConfigured; | ||
} | ||
|
||
public List<IExhibitionLanguage> getLanguages() { | ||
return languages; | ||
} | ||
|
||
public void setLanguages(List<IExhibitionLanguage> languages) { | ||
this.languages = languages; | ||
} | ||
|
||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(id); | ||
} | ||
|
||
@Override | ||
public boolean equals(Object obj) { | ||
if (this == obj) | ||
return true; | ||
if (obj == null) | ||
return false; | ||
if (getClass() != obj.getClass()) | ||
return false; | ||
Exhibition other = (Exhibition) obj; | ||
return Objects.equals(id, other.id); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. merge with line 154 |
||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. sorry, I didn't see this before but first all getters/setters then hashcode/equals methods. |
||
|
||
|
||
} |
103 changes: 103 additions & 0 deletions
103
vspace/src/main/java/edu/asu/diging/vspace/core/model/impl/ExhibitionLanguage.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
package edu.asu.diging.vspace.core.model.impl; | ||
|
||
import java.util.Objects; | ||
import javax.persistence.Entity; | ||
import javax.persistence.GeneratedValue; | ||
import javax.persistence.Id; | ||
import javax.persistence.ManyToOne; | ||
import org.hibernate.annotations.GenericGenerator; | ||
import org.hibernate.annotations.Parameter; | ||
import edu.asu.diging.vspace.core.model.IExhibitionLanguage; | ||
|
||
@Entity | ||
public class ExhibitionLanguage extends VSpaceElement implements IExhibitionLanguage { | ||
|
||
@Id | ||
@GeneratedValue(generator = "exhibit_language_id_generator") | ||
@GenericGenerator(name = "exhibit_language_id_generator", parameters = @Parameter(name = "prefix", value = "LANG"), strategy = "edu.asu.diging.vspace.core.data.IdGenerator") | ||
private String id; | ||
|
||
private String label; | ||
|
||
@ManyToOne(targetEntity = Exhibition.class) | ||
private Exhibition exhibition; | ||
|
||
private String code; | ||
|
||
private boolean isDefault; | ||
|
||
public ExhibitionLanguage() { | ||
super(); | ||
} | ||
|
||
public ExhibitionLanguage(String label, String code, Exhibition exhibition) { | ||
this.label=label; | ||
this.code=code; | ||
this.exhibition=exhibition; | ||
} | ||
|
||
@Override | ||
public String getId() { | ||
return id; | ||
} | ||
|
||
@Override | ||
public void setId(String id) { | ||
this.setId(id); | ||
} | ||
|
||
public String getLabel() { | ||
return label; | ||
} | ||
|
||
public void setLabel(String label) { | ||
this.label = label; | ||
} | ||
|
||
public Exhibition getExhibition() { | ||
return exhibition; | ||
} | ||
|
||
public void setExhibition(Exhibition exhibition) { | ||
this.exhibition = exhibition; | ||
} | ||
|
||
@Override | ||
public String getCode() { | ||
return code; | ||
} | ||
|
||
public void setCode(String code) { | ||
this.code = code; | ||
} | ||
|
||
@Override | ||
public boolean isDefault() { | ||
return isDefault; | ||
} | ||
|
||
@Override | ||
public void setDefault(boolean isDefault) { | ||
this.isDefault = isDefault; | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(code, exhibition, label); | ||
} | ||
|
||
@Override | ||
public boolean equals(Object obj) { | ||
if (this == obj) | ||
return true; | ||
if (obj == null) | ||
return false; | ||
if (getClass() != obj.getClass()) | ||
return false; | ||
ExhibitionLanguage other = (ExhibitionLanguage) obj; | ||
return Objects.equals(code, other.code) && Objects.equals(exhibition, other.exhibition) | ||
&& Objects.equals(label, other.label); | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should be a runtime exception and exception class names should end in
Exception