<commit_before>package org.datacite.conres.view;

import com.sun.jersey.api.view.Viewable;
import org.datacite.conres.model.Metadata;
import org.datacite.conres.service.CslFormatterService;
import org.datacite.conres.service.CslFormatterServiceFactory;

import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Variant;

public enum Representation {
    TEXT_HTML("text","html", new Transformer() {
        @Override public Object transform(Metadata mr) {
            return new Viewable("/doi_html", mr);
        }
    }),
    APPLICATION_DATACITE_XML ("application","x-datacite+xml", new Transformer() {
        @Override public Object transform(Metadata mr) {
            return mr.getXml();
        }
    }),
    DATACITE_TEXT ("application","x-datacite+text", new Transformer() {
        @Override
        public Object transform(Metadata mr) {
            return new Viewable("/doi_text", mr);
        }
    }),
    APPLICATION_RDF_XML ("application","rdf+xml", new Transformer() {
        @Override public Object transform(Metadata mr) {
            return RdfRepresentation.writeXML(mr);
        }
    }),
    RDF_TURTLE ("text","turtle", new Transformer() {
        @Override
        public Object transform(Metadata mr) {
            return RdfRepresentation.writeTurtle(mr);
        }
    }),
    BIBTEX ("application","x-bibtex", new Transformer() {
        @Override
        public Object transform(Metadata mr) {
            return new Viewable("/doi_bibtex", mr);
        }
    }),
    RIS ("application","x-research-info-systems", new Transformer() {
        @Override
        public Object transform(Metadata mr) {
            return new Viewable("/doi_ris", mr);
        }
    }),
    CITEPROC_JSON("application", "citeproc+json", new Transformer() {
        @Override
        public Object transform(Metadata mr) {
            return CslJsonRepresentation.writeJSON(mr);
        }
    }),
    CSL_JSON("application", "vnd.citationstyles.csl+json", new Transformer() {
        @Override
        public Object transform(Metadata mr) {
            return CslJsonRepresentation.writeJSON(mr);
        }
    }),
    TEXT_BIBLIOGRAPHY("text", "bibliography", new Transformer() {
        @Override
        public Object transform(Metadata mr) {
            return cslFormatterService.format(CslJsonRepresentation.writeJSON(mr),
                    mr.getCslStyle(),
                    mr.getCslLocale());
        }
    });

    private final String type;
    private final String subtype;
    private final MediaType mediaType;
    private final Transformer transformer;
    private static CslFormatterService cslFormatterService = CslFormatterServiceFactory.getInstance();

    Representation(String type, String subtype, Transformer mt) {
        this.type = type;
        this.subtype = subtype;
        this.mediaType = new MediaType(type, subtype);
        this.transformer = mt;
    }

    public Object render(Metadata mr){
        return transformer.transform(mr);<commit_msg>updating list of supported types<commit_after>package org.datacite.conres.view;

import com.sun.jersey.api.view.Viewable;
import org.datacite.conres.model.Metadata;
import org.datacite.conres.service.CslFormatterService;
import org.datacite.conres.service.CslFormatterServiceFactory;

import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Variant;

public enum Representation {
    TEXT_HTML("text","html", new Transformer() {
        @Override public Object transform(Metadata mr) {
            return new Viewable("/doi_html", mr);
        }
    }),
    APPLICATION_DATACITE_XML ("application","x-datacite+xml", new Transformer() {
        @Override public Object transform(Metadata mr) {
            return mr.getXml();
        }
    }),
    APPLICATION_VND_DATACITE_XML ("application","vnd.datacite.datacite+xml", new Transformer() {
        @Override public Object transform(Metadata mr) {
            return mr.getXml();
        }
    }),
    DATACITE_TEXT ("application","x-datacite+text", new Transformer() {
        @Override
        public Object transform(Metadata mr) {
            return new Viewable("/doi_text", mr);
        }
    }),
    DATACITE_VND_TEXT ("application","vnd.datacite.datacite+text", new Transformer() {
        @Override
        public Object transform(Metadata mr) {
            return new Viewable("/doi_text", mr);
        }
    }),
    APPLICATION_RDF_XML ("application","rdf+xml", new Transformer() {
        @Override public Object transform(Metadata mr) {
            return RdfRepresentation.writeXML(mr);
        }
    }),
    RDF_TURTLE ("text","turtle", new Transformer() {
        @Override
        public Object transform(Metadata mr) {
            return RdfRepresentation.writeTurtle(mr);
        }
    }),
    BIBTEX ("application","x-bibtex", new Transformer() {
        @Override
        public Object transform(Metadata mr) {
            return new Viewable("/doi_bibtex", mr);
        }
    }),
    RIS ("application","x-research-info-systems", new Transformer() {
        @Override
        public Object transform(Metadata mr) {
            return new Viewable("/doi_ris", mr);
        }
    }),
    CITEPROC_JSON("application", "citeproc+json", new Transformer() {
        @Override
        public Object transform(Metadata mr) {
            return CslJsonRepresentation.writeJSON(mr);
        }
    }),
    CSL_JSON("application", "vnd.citationstyles.csl+json", new Transformer() {
        @Override
        public Object transform(Metadata mr) {
            return CslJsonRepresentation.writeJSON(mr);
        }
    }),
    TEXT_BIBLIOGRAPHY("text", "x-bibliography", new Transformer() {
        @Override
        public Object transform(Metadata mr) {
            return cslFormatterService.format(CslJsonRepresentation.writeJSON(mr),
                    mr.getCslStyle(),
                    mr.getCslLocale());
        }
    });

    private final String type;
    private final String subtype;
    private final MediaType mediaType;
    private final Transformer transformer;
    private static CslFormatterService cslFormatterService = CslFormatterServiceFactory.getInstance();

    Representation(String type, String subtype, Transformer mt) {
        this.type = type;
        this.subtype = subtype;
        this.mediaType = new MediaType(type, subtype);
        this.transformer = mt;
    }

    public Object render(Metadata mr){
        return transformer.transform(mr);
{'fraction_non_alphanumeric': 0.11143877075896322, 'fraction_numerical': 0.0, 'mean_word_length': 2.6738882554161916, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 5}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2558141', 'n_tokens_mistral': 1855, 'n_tokens_neox': 1795, 'n_words': 385}