Project

General

Profile

Revision 065f7e99

ID065f7e992252eed43eff712fdfae4615ed33bdaa
Parent 9622040d
Child 95a16223

Added by Patrick Plitzner about 1 year ago

ref #6794 Fix endless loop in OWL export

View differences:

cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/descriptive/owl/out/OwlExportUtil.java
14 14
import java.util.Set;
15 15

  
16 16
import com.hp.hpl.jena.rdf.model.Resource;
17
import com.hp.hpl.jena.rdf.model.ResourceFactory;
17 18

  
18 19
import eu.etaxonomy.cdm.api.application.ICdmRepository;
19 20
import eu.etaxonomy.cdm.common.CdmUtils;
......
47 48
public class OwlExportUtil {
48 49

  
49 50
    static Resource createVocabularyResource(TermVocabulary vocabulary, ICdmRepository repo, StructureTreeOwlExportState state) {
51
        String vocabularyResourceUri = getVocabularyResourceUri(vocabulary, state);
52
        //check if vocabulary exists
53
        if(state.getModel().containsResource(ResourceFactory.createResource(vocabularyResourceUri))){
54
            return state.getModel().createResource(vocabularyResourceUri);
55
        }
50 56
        // create vocabulary resource
51
        Resource vocabularyResource = getVocabularyResource(vocabulary, state)
57
        Resource vocabularyResource = state.getModel().createResource(vocabularyResourceUri)
52 58
                .addProperty(OwlUtil.propUuid, vocabulary.getUuid().toString())
53 59
                .addProperty(OwlUtil.propType, vocabulary.getTermType().getKey())
54 60
                .addProperty(OwlUtil.propIsA, OwlUtil.VOCABULARY)
......
266 272
    }
267 273

  
268 274
    static Resource createFeatureTreeResource(TermTree featureTree, ICdmRepository repo, StructureTreeOwlExportState state) {
269
        Resource featureTreeResource = getFeatureTreeResource(featureTree, state)
275
        String featureTreeResourceUri = getFeatureTreeResourceUri(featureTree, state);
276
        //check if tree exists
277
        if(state.getModel().containsResource(ResourceFactory.createResource(featureTreeResourceUri))){
278
            return state.getModel().createResource(featureTreeResourceUri);
279
        }
280
        Resource featureTreeResource = state.getModel().createResource(featureTreeResourceUri)
270 281
                .addProperty(OwlUtil.propUuid, featureTree.getUuid().toString())
271 282
                .addProperty(OwlUtil.propLabel, featureTree.getTitleCache())
272 283
                .addProperty(OwlUtil.propIsA, OwlUtil.TREE)
......
314 325
        return nodeResource;
315 326
    }
316 327

  
317
    private static Resource getVocabularyResource(TermVocabulary vocabulary, StructureTreeOwlExportState state) {
318
        return state.getModel().createResource(OwlUtil.RESOURCE_TERM_VOCABULARY+vocabulary.getUuid());
328
    private static String getVocabularyResourceUri(TermVocabulary vocabulary, StructureTreeOwlExportState state) {
329
        return OwlUtil.RESOURCE_TERM_VOCABULARY+vocabulary.getUuid();
319 330
    }
320 331

  
321 332
    private static Resource getSourceResource(IdentifiableSource source, StructureTreeOwlExportState state) {
......
343 354
        return state.getModel().createResource(OwlUtil.RESOURCE_NODE + node.getUuid().toString());
344 355
    }
345 356

  
346
    private static Resource getFeatureTreeResource(TermTree featureTree, StructureTreeOwlExportState state) {
347
        return state.getModel().createResource(OwlUtil.RESOURCE_FEATURE_TREE+featureTree.getUuid().toString());
357
    private static String getFeatureTreeResourceUri(TermTree featureTree, StructureTreeOwlExportState state) {
358
        return OwlUtil.RESOURCE_FEATURE_TREE+featureTree.getUuid().toString();
348 359
    }
349 360

  
350 361
}

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)