Skip to content

Commit

Permalink
EA-3622 Sixth stage commit - fix JenaBAsedFormat Writer config and re…
Browse files Browse the repository at this point in the history
…fernces
  • Loading branch information
SrishtiSingh-eu committed Nov 17, 2023
1 parent 8e29c2c commit 753b90a
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ public class AppConfigConstants {
public static final String BEAN_NAMESPACE_RESOLVER= "namespaceResolver";
public static final String BEAN_DEFAULT_URI_RESOLVER= "defaultUriResolver";
public static final String BEAN_RECORD_TEMPLATE_LIBRARY = "recordApiTemplateLibrary";
public static final String BEAN_JENA_FORAMAT_WRITER_TURTLE = "jenaFormatWriterTurtle";
public static final String BEAN_JENA_FORAMAT_WRITER_N3 = "jenaFormatWriterN3";
public static final String BEAN_JENA_FORAMAT_WRITER_NT = "jenaFormatWriterNt";


// media config beans
public static final String BEAN_MEDIA_TYPES = "msMediaTypes";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
/**
*
*/
package eu.europeana.api.record.io;

import eu.europeana.api.config.AppConfigConstants;
import eu.europeana.api.format.FormatWriter;
import eu.europeana.api.format.RdfFormat;
import eu.europeana.api.record.io.json.JsonLdWriter;
import eu.europeana.api.record.io.xml.XmlRecordWriter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.HashMap;

/**
Expand All @@ -23,26 +22,24 @@ public class FormatHandlerRegistry extends HashMap<RdfFormat, FormatWriter> {
@Autowired
JsonLdWriter jsonLdWriter;

// @Autowired
// XmlRecordWriter xmlRecordWriter;
//
// @Resource(name = "ttl")
// JenaBasedFormatWriter Turtle_jenaBasedFormatWriter;
//
// @Resource(name = "N3")
// JenaBasedFormatWriter N3_jenaBasedFormatWriter;
//
// @Resource(name = "NT")
// JenaBasedFormatWriter NT_jenaBasedFormatWriter;
@Autowired
XmlRecordWriter xmlRecordWriter;

@Resource(name = AppConfigConstants.BEAN_JENA_FORAMAT_WRITER_TURTLE)
JenaBasedFormatWriter jenaBasedTurtleWriter;

@Resource(name = AppConfigConstants.BEAN_JENA_FORAMAT_WRITER_N3)
JenaBasedFormatWriter JenaBasedN3Writer;

@Resource(name = AppConfigConstants.BEAN_JENA_FORAMAT_WRITER_NT)
JenaBasedFormatWriter JenaBasedNTWriter;

public FormatHandlerRegistry() {
put(RdfFormat.JSONLD, jsonLdWriter);
put(RdfFormat.XML , new XmlRecordWriter());
put(RdfFormat.TURTLE, new JenaBasedFormatWriter("TURTLE"));
put(RdfFormat.N3 , new JenaBasedFormatWriter("N3"));
put(RdfFormat.NT , new JenaBasedFormatWriter("NT"));
put(RdfFormat.XML, xmlRecordWriter);
put(RdfFormat.TURTLE, jenaBasedTurtleWriter);
put(RdfFormat.N3, JenaBasedN3Writer);
put(RdfFormat.NT, JenaBasedNTWriter);
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import eu.europeana.jena.encoder.library.DefaultUriNormalizer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;

import java.text.SimpleDateFormat;

Expand Down Expand Up @@ -49,6 +50,7 @@ public DefaultUriNormalizer getDefaultUriNormalizer() {
}

// JsonLdWriter bean
@Primary
@Bean(AppConfigConstants.BEAN_JSON_MAPPER)
public ObjectMapper mapper() {
ObjectMapper mapper = new ObjectMapper();
Expand Down Expand Up @@ -85,5 +87,18 @@ public ObjectMapper mapper() {
}

// JenaBasedFormatWriter beans based on formats
@Bean(AppConfigConstants.BEAN_JENA_FORAMAT_WRITER_TURTLE)
public JenaBasedFormatWriter getJenaBasedTurtleWriter() {
return new JenaBasedFormatWriter("TURTLE");
}

@Bean(AppConfigConstants.BEAN_JENA_FORAMAT_WRITER_N3)
public JenaBasedFormatWriter getJenaBasedN3Writer() {
return new JenaBasedFormatWriter("N3");
}

@Bean(AppConfigConstants.BEAN_JENA_FORAMAT_WRITER_NT)
public JenaBasedFormatWriter getJenaBasedNTWriter() {
return new JenaBasedFormatWriter("NT");
}
}

0 comments on commit 753b90a

Please sign in to comment.