Skip to content

Commit c3e58e0

Browse files
authored
Merge pull request #109 from onc-healthit/develop
Develop
2 parents 3d92db4 + 64b8926 commit c3e58e0

File tree

4 files changed

+218
-188
lines changed

4 files changed

+218
-188
lines changed

pom.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
<dependency>
3131
<groupId>org.springframework.data</groupId>
3232
<artifactId>spring-data-jpa</artifactId>
33-
<version>1.9.2.RELEASE</version>
33+
<version>1.11.23.RELEASE</version>
3434
</dependency>
3535
<dependency>
3636
<groupId>org.springframework</groupId>
@@ -86,12 +86,12 @@
8686
<dependency>
8787
<groupId>org.apache.poi</groupId>
8888
<artifactId>poi</artifactId>
89-
<version>3.15</version>
89+
<version>3.17</version>
9090
</dependency>
9191
<dependency>
9292
<groupId>org.apache.poi</groupId>
9393
<artifactId>poi-ooxml</artifactId>
94-
<version>3.15</version>
94+
<version>3.17</version>
9595
</dependency>
9696
<dependency>
9797
<groupId>com.monitorjbl</groupId>
Lines changed: 181 additions & 168 deletions
Original file line numberDiff line numberDiff line change
@@ -1,168 +1,181 @@
1-
package org.sitenv.vocabularies.configuration;
2-
3-
import org.sitenv.vocabularies.loader.VocabularyLoadRunner;
4-
import org.sitenv.vocabularies.loader.VocabularyLoaderFactory;
5-
import org.sitenv.vocabularies.validation.NodeValidatorFactory;
6-
import org.sitenv.vocabularies.validation.dto.GlobalCodeValidatorResults;
7-
import org.springframework.beans.factory.annotation.Autowired;
8-
import org.springframework.beans.factory.config.ServiceLocatorFactoryBean;
9-
import org.springframework.context.annotation.Bean;
10-
import org.springframework.context.annotation.ComponentScan;
11-
import org.springframework.context.annotation.Configuration;
12-
import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
13-
import org.springframework.core.env.Environment;
14-
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
15-
import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder;
16-
import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType;
17-
import org.springframework.orm.hibernate4.HibernateExceptionTranslator;
18-
import org.springframework.orm.jpa.JpaTransactionManager;
19-
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
20-
import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter;
21-
import org.springframework.oxm.jaxb.Jaxb2Marshaller;
22-
import org.springframework.transaction.PlatformTransactionManager;
23-
24-
import javax.persistence.EntityManagerFactory;
25-
import javax.sql.DataSource;
26-
import javax.xml.parsers.DocumentBuilder;
27-
import javax.xml.parsers.DocumentBuilderFactory;
28-
import javax.xml.parsers.ParserConfigurationException;
29-
import javax.xml.xpath.XPathFactory;
30-
import java.util.HashMap;
31-
import java.util.List;
32-
import java.util.Map;
33-
import java.util.Properties;
34-
35-
/**
36-
* Created by Brian on 2/5/2016.
37-
*/
38-
@Configuration
39-
@ComponentScan("org.sitenv.vocabularies")
40-
@EnableJpaRepositories("org.sitenv.vocabularies.validation.repositories")
41-
public class CodeValidatorApiConfiguration {
42-
43-
@Bean
44-
public EntityManagerFactory entityManagerFactory() {
45-
HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
46-
vendorAdapter.setGenerateDdl(false);
47-
vendorAdapter.setShowSql(true);
48-
LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean();
49-
factory.setJpaVendorAdapter(vendorAdapter);
50-
factory.setPackagesToScan("org.sitenv.vocabularies.validation.entities");
51-
Properties jpaProperties = new Properties();
52-
jpaProperties.put("hibernate.hbm2ddl.auto", "none");
53-
jpaProperties.put("hibernate.dialect", "org.hibernate.dialect.HSQLDialect");
54-
jpaProperties.put("hibernate.format_sql", "true");
55-
jpaProperties.put("hibernate.show_sql", "false");
56-
factory.setDataSource(dataSource());
57-
factory.setJpaProperties(jpaProperties);
58-
factory.afterPropertiesSet();
59-
return factory.getObject();
60-
}
61-
62-
@Bean
63-
public PlatformTransactionManager transactionManager() {
64-
JpaTransactionManager txManager = new JpaTransactionManager();
65-
txManager.setEntityManagerFactory(entityManagerFactory());
66-
return txManager;
67-
}
68-
69-
@Bean
70-
public HibernateExceptionTranslator hibernateExceptionTranslator() {
71-
return new HibernateExceptionTranslator();
72-
}
73-
74-
@Bean
75-
public DataSource dataSource() {
76-
return new EmbeddedDatabaseBuilder()
77-
.setType(EmbeddedDatabaseType.HSQL)
78-
.addScript("classpath:schema.sql")
79-
.build();
80-
}
81-
82-
@Bean
83-
public static PropertySourcesPlaceholderConfigurer propertyPlaceholderConfigurer() {
84-
PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer = new PropertySourcesPlaceholderConfigurer();
85-
propertySourcesPlaceholderConfigurer.setLocalOverride(true);
86-
return propertySourcesPlaceholderConfigurer;
87-
}
88-
89-
@Bean
90-
public ServiceLocatorFactoryBean vocabularyLoaderFactoryServiceLocatorFactoryBean() {
91-
ServiceLocatorFactoryBean bean = new ServiceLocatorFactoryBean();
92-
bean.setServiceLocatorInterface(VocabularyLoaderFactory.class);
93-
return bean;
94-
}
95-
96-
@Bean
97-
public VocabularyLoaderFactory vocabularyLoaderFactory() {
98-
return (VocabularyLoaderFactory) vocabularyLoaderFactoryServiceLocatorFactoryBean().getObject();
99-
}
100-
101-
@Bean
102-
public ServiceLocatorFactoryBean vocabularyValidatorFactoryServiceLocatorFactoryBean() {
103-
ServiceLocatorFactoryBean bean = new ServiceLocatorFactoryBean();
104-
bean.setServiceLocatorInterface(NodeValidatorFactory.class);
105-
return bean;
106-
}
107-
108-
@Bean
109-
public NodeValidatorFactory vocabularyValidatorFactory() {
110-
return (NodeValidatorFactory) vocabularyValidatorFactoryServiceLocatorFactoryBean().getObject();
111-
}
112-
113-
@Autowired
114-
@Bean
115-
VocabularyLoadRunner vocabularyLoadRunner(final Environment environment, final VocabularyLoaderFactory vocabularyLoaderFactory, final DataSource dataSource){
116-
VocabularyLoadRunner vocabularyLoadRunner = null;
117-
String localCodeRepositoryDir = environment.getProperty("vocabulary.localCodeRepositoryDir");
118-
String localValueSetRepositoryDir = environment.getProperty("vocabulary.localValueSetRepositoryDir");
119-
vocabularyLoadRunner = new VocabularyLoadRunner();
120-
System.out.println("LOADING VOCABULARY DATABASES FROM THE FOLLOWING RESOURCES: VALUESETS - " + localValueSetRepositoryDir + " CODES - " + localCodeRepositoryDir);
121-
vocabularyLoadRunner.setCodeDirectory(localCodeRepositoryDir);
122-
vocabularyLoadRunner.setValueSetDirectory(localValueSetRepositoryDir);
123-
vocabularyLoadRunner.setDataSource(dataSource);
124-
vocabularyLoadRunner.setVocabularyLoaderFactory(vocabularyLoaderFactory);
125-
return vocabularyLoadRunner;
126-
}
127-
128-
@Bean
129-
public static List<ConfiguredExpression> vocabularyValidationConfigurations(ValidationConfigurationLoader configurationLoader){
130-
return configurationLoader.getConfigurations().getExpressions();
131-
}
132-
133-
@Bean
134-
public DocumentBuilder documentBuilder() throws ParserConfigurationException {
135-
DocumentBuilderFactory domFactory = DocumentBuilderFactory.newInstance();
136-
domFactory.setNamespaceAware(true);
137-
return domFactory.newDocumentBuilder();
138-
}
139-
140-
@Bean
141-
public XPathFactory xPathFactory(){
142-
return XPathFactory.newInstance();
143-
}
144-
145-
@Autowired
146-
@Bean
147-
public ValidationConfigurationLoader validationConfigurationLoader(final Environment environment){
148-
ValidationConfigurationLoader validationConfigurationLoader = new ValidationConfigurationLoader();
149-
validationConfigurationLoader.setValidationConfigurationFilePath(environment.getProperty("referenceccda.configFile"));
150-
validationConfigurationLoader.setUnmarshaller(castorMarshaller());
151-
return validationConfigurationLoader;
152-
}
153-
154-
@Bean
155-
public static Jaxb2Marshaller castorMarshaller() {
156-
Jaxb2Marshaller jaxb2Marshaller = new Jaxb2Marshaller();
157-
jaxb2Marshaller.setPackagesToScan("org.sitenv.vocabularies.configuration");
158-
Map<String,Object> map = new HashMap<>();
159-
map.put("jaxb.formatted.output", true);
160-
jaxb2Marshaller.setMarshallerProperties(map);
161-
return jaxb2Marshaller;
162-
}
163-
164-
@Bean
165-
public static GlobalCodeValidatorResults globalCodeValidatorResults() {
166-
return new GlobalCodeValidatorResults();
167-
}
168-
}
1+
package org.sitenv.vocabularies.configuration;
2+
3+
import java.util.HashMap;
4+
import java.util.List;
5+
import java.util.Map;
6+
import java.util.Properties;
7+
8+
import javax.persistence.EntityManagerFactory;
9+
import javax.sql.DataSource;
10+
import javax.xml.XMLConstants;
11+
import javax.xml.parsers.DocumentBuilderFactory;
12+
import javax.xml.parsers.ParserConfigurationException;
13+
import javax.xml.xpath.XPathFactory;
14+
15+
import org.sitenv.vocabularies.loader.VocabularyLoadRunner;
16+
import org.sitenv.vocabularies.loader.VocabularyLoaderFactory;
17+
import org.sitenv.vocabularies.validation.NodeValidatorFactory;
18+
import org.sitenv.vocabularies.validation.dto.GlobalCodeValidatorResults;
19+
import org.springframework.beans.factory.annotation.Autowired;
20+
import org.springframework.beans.factory.config.ServiceLocatorFactoryBean;
21+
import org.springframework.context.annotation.Bean;
22+
import org.springframework.context.annotation.ComponentScan;
23+
import org.springframework.context.annotation.Configuration;
24+
import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
25+
import org.springframework.core.env.Environment;
26+
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
27+
import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder;
28+
import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType;
29+
import org.springframework.orm.hibernate4.HibernateExceptionTranslator;
30+
import org.springframework.orm.jpa.JpaTransactionManager;
31+
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
32+
import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter;
33+
import org.springframework.oxm.jaxb.Jaxb2Marshaller;
34+
import org.springframework.transaction.PlatformTransactionManager;
35+
36+
/**
37+
* Created by Brian on 2/5/2016.
38+
*/
39+
@Configuration
40+
@ComponentScan("org.sitenv.vocabularies")
41+
@EnableJpaRepositories("org.sitenv.vocabularies.validation.repositories")
42+
public class CodeValidatorApiConfiguration {
43+
44+
@Bean
45+
public EntityManagerFactory entityManagerFactory() {
46+
HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
47+
vendorAdapter.setGenerateDdl(false);
48+
vendorAdapter.setShowSql(true);
49+
LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean();
50+
factory.setJpaVendorAdapter(vendorAdapter);
51+
factory.setPackagesToScan("org.sitenv.vocabularies.validation.entities");
52+
Properties jpaProperties = new Properties();
53+
jpaProperties.put("hibernate.hbm2ddl.auto", "none");
54+
jpaProperties.put("hibernate.dialect", "org.hibernate.dialect.HSQLDialect");
55+
jpaProperties.put("hibernate.format_sql", "true");
56+
jpaProperties.put("hibernate.show_sql", "false");
57+
factory.setDataSource(dataSource());
58+
factory.setJpaProperties(jpaProperties);
59+
factory.afterPropertiesSet();
60+
return factory.getObject();
61+
}
62+
63+
@Bean
64+
public PlatformTransactionManager transactionManager() {
65+
JpaTransactionManager txManager = new JpaTransactionManager();
66+
txManager.setEntityManagerFactory(entityManagerFactory());
67+
return txManager;
68+
}
69+
70+
@Bean
71+
public HibernateExceptionTranslator hibernateExceptionTranslator() {
72+
return new HibernateExceptionTranslator();
73+
}
74+
75+
@Bean
76+
public DataSource dataSource() {
77+
return new EmbeddedDatabaseBuilder().setType(EmbeddedDatabaseType.HSQL).addScript("classpath:schema.sql")
78+
.build();
79+
}
80+
81+
@Bean
82+
public static PropertySourcesPlaceholderConfigurer propertyPlaceholderConfigurer() {
83+
PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer = new PropertySourcesPlaceholderConfigurer();
84+
propertySourcesPlaceholderConfigurer.setLocalOverride(true);
85+
return propertySourcesPlaceholderConfigurer;
86+
}
87+
88+
@Bean
89+
public ServiceLocatorFactoryBean vocabularyLoaderFactoryServiceLocatorFactoryBean() {
90+
ServiceLocatorFactoryBean bean = new ServiceLocatorFactoryBean();
91+
bean.setServiceLocatorInterface(VocabularyLoaderFactory.class);
92+
return bean;
93+
}
94+
95+
@Bean
96+
public VocabularyLoaderFactory vocabularyLoaderFactory() {
97+
return (VocabularyLoaderFactory) vocabularyLoaderFactoryServiceLocatorFactoryBean().getObject();
98+
}
99+
100+
@Bean
101+
public ServiceLocatorFactoryBean vocabularyValidatorFactoryServiceLocatorFactoryBean() {
102+
ServiceLocatorFactoryBean bean = new ServiceLocatorFactoryBean();
103+
bean.setServiceLocatorInterface(NodeValidatorFactory.class);
104+
return bean;
105+
}
106+
107+
@Bean
108+
public NodeValidatorFactory vocabularyValidatorFactory() {
109+
return (NodeValidatorFactory) vocabularyValidatorFactoryServiceLocatorFactoryBean().getObject();
110+
}
111+
112+
@Autowired
113+
@Bean
114+
VocabularyLoadRunner vocabularyLoadRunner(final Environment environment,
115+
final VocabularyLoaderFactory vocabularyLoaderFactory, final DataSource dataSource) {
116+
VocabularyLoadRunner vocabularyLoadRunner = null;
117+
String localCodeRepositoryDir = environment.getProperty("vocabulary.localCodeRepositoryDir");
118+
String localValueSetRepositoryDir = environment.getProperty("vocabulary.localValueSetRepositoryDir");
119+
vocabularyLoadRunner = new VocabularyLoadRunner();
120+
System.out.println("LOADING VOCABULARY DATABASES FROM THE FOLLOWING RESOURCES: VALUESETS - "
121+
+ localValueSetRepositoryDir + " CODES - " + localCodeRepositoryDir);
122+
vocabularyLoadRunner.setCodeDirectory(localCodeRepositoryDir);
123+
vocabularyLoadRunner.setValueSetDirectory(localValueSetRepositoryDir);
124+
vocabularyLoadRunner.setDataSource(dataSource);
125+
vocabularyLoadRunner.setVocabularyLoaderFactory(vocabularyLoaderFactory);
126+
return vocabularyLoadRunner;
127+
}
128+
129+
@Bean
130+
public static List<ConfiguredExpression> vocabularyValidationConfigurations(
131+
ValidationConfigurationLoader configurationLoader) {
132+
return configurationLoader.getConfigurations().getExpressions();
133+
}
134+
135+
@Bean
136+
public DocumentBuilderFactory documentBuilderFactory() throws ParserConfigurationException {
137+
DocumentBuilderFactory domFactory = DocumentBuilderFactory.newInstance(
138+
"com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl",
139+
ClassLoader.getSystemClassLoader());
140+
domFactory.setAttribute(XMLConstants.ACCESS_EXTERNAL_DTD, "");
141+
domFactory.setAttribute(XMLConstants.ACCESS_EXTERNAL_SCHEMA, "");
142+
domFactory.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true);
143+
domFactory.setFeature("http://xml.org/sax/features/external-general-entities", false);
144+
domFactory.setFeature("http://xml.org/sax/features/external-parameter-entities", false);
145+
domFactory.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false);
146+
domFactory.setXIncludeAware(false);
147+
domFactory.setExpandEntityReferences(false);
148+
domFactory.setNamespaceAware(true);
149+
return domFactory;
150+
}
151+
152+
@Bean
153+
public XPathFactory xPathFactory() {
154+
return XPathFactory.newInstance();
155+
}
156+
157+
@Autowired
158+
@Bean
159+
public ValidationConfigurationLoader validationConfigurationLoader(final Environment environment) {
160+
ValidationConfigurationLoader validationConfigurationLoader = new ValidationConfigurationLoader();
161+
validationConfigurationLoader
162+
.setValidationConfigurationFilePath(environment.getProperty("referenceccda.configFile"));
163+
validationConfigurationLoader.setUnmarshaller(castorMarshaller());
164+
return validationConfigurationLoader;
165+
}
166+
167+
@Bean
168+
public static Jaxb2Marshaller castorMarshaller() {
169+
Jaxb2Marshaller jaxb2Marshaller = new Jaxb2Marshaller();
170+
jaxb2Marshaller.setPackagesToScan("org.sitenv.vocabularies.configuration");
171+
Map<String, Object> map = new HashMap<>();
172+
map.put("jaxb.formatted.output", true);
173+
jaxb2Marshaller.setMarshallerProperties(map);
174+
return jaxb2Marshaller;
175+
}
176+
177+
@Bean
178+
public static GlobalCodeValidatorResults globalCodeValidatorResults() {
179+
return new GlobalCodeValidatorResults();
180+
}
181+
}

0 commit comments

Comments
 (0)