From bbdb7f77e343c81111db267bf6aab2ef829e90ed Mon Sep 17 00:00:00 2001 From: jezekp Date: Fri, 30 Sep 2016 16:22:37 -0700 Subject: [PATCH] fixed bug in semantic factory. The BUG was: When Semantic factory was invoked repeatedly the list of object was not cleared. --- .../logic/semantic/SimpleSemanticFactory.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/main/java/cz/zcu/kiv/eegdatabase/logic/semantic/SimpleSemanticFactory.java b/src/main/java/cz/zcu/kiv/eegdatabase/logic/semantic/SimpleSemanticFactory.java index 9880b4b8..bd03ed57 100644 --- a/src/main/java/cz/zcu/kiv/eegdatabase/logic/semantic/SimpleSemanticFactory.java +++ b/src/main/java/cz/zcu/kiv/eegdatabase/logic/semantic/SimpleSemanticFactory.java @@ -62,7 +62,6 @@ public class SimpleSemanticFactory implements InitializingBean, ApplicationConte private Log log = LogFactory.getLog(getClass()); private ApplicationContext context; private List gDaoList = new ArrayList(); - private List dataList = new ArrayList(); private ReentrantReadWriteLock lock = new ReentrantReadWriteLock(true); private File ontologyFile; // temporary ontology document @@ -180,13 +179,15 @@ public InputStream getOntologyOwlApi(String syntax) throws IOException, /** * Loads date for transforms POJO object to resouces of semantic web. */ - private void loadData() { + private List loadData() { + List dataList = new ArrayList(); ElasticSynchronizationInterceptor elasticSynchronizationInterceptor = context.getBean(ElasticSynchronizationInterceptor.class); elasticSynchronizationInterceptor.setLoadSemantic(true); for (GenericDao gDao : gDaoList) { dataList.addAll(gDao.getAllRecords()); } elasticSynchronizationInterceptor.setLoadSemantic(false); + return dataList; } @@ -218,8 +219,8 @@ public void transformModel() { OutputStream out; try { - loadData(); - jbe = creatingJenaBean(); + List dataList = loadData(); + jbe = creatingJenaBean(dataList); lock.writeLock().lock(); out = new FileOutputStream(ontologyFile); jbe.writeOntologyDocument(out, Syntax.RDF_XML); @@ -241,7 +242,7 @@ public void transformModel() { * Creates an instance of JenaBeanExtension with loaded model. * @return instance of JenaBeanExtension */ - private JenaBeanExtension creatingJenaBean() { + private JenaBeanExtension creatingJenaBean(List dataList) { JenaBeanExtension jbe = new JenaBeanExtensionTool(); try { jbe.loadStatements(ontologyHeader.getInputStream(), Syntax.RDF_XML_ABBREV);