-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #326 from diging/develop
Prepare release
- Loading branch information
Showing
87 changed files
with
4,963 additions
and
672 deletions.
There are no files selected for viewing
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
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); | ||
} | ||
} | ||
|
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
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.