<commit_before>package edu.harvard.iq.dataverse.util.json;

import edu.harvard.iq.dataverse.DatasetVersion;
import edu.harvard.iq.dataverse.authorization.providers.builtin.BuiltinUser;
import edu.harvard.iq.dataverse.MetadataBlock;
import static edu.harvard.iq.dataverse.util.json.NullSafeJsonBuilder.jsonObjectBuilder;
import edu.harvard.iq.dataverse.workflow.Workflow;
import java.math.BigDecimal;
import javax.json.JsonObjectBuilder;

/**
 * A Json printer that prints minimal data on objects. Useful when embedding 
 * objects inside others.
 * 
 * @author michael
 */
public class BriefJsonPrinter {
	
	public JsonObjectBuilder json( BuiltinUser usr ) {
		return ( usr==null ) 
				? null
				: jsonObjectBuilder().add("id", usr.getId())
					.add("firstName", usr.getFirstName())
					.add("lastName", usr.getLastName())
					.add("affiliation", usr.getAffiliation())
					;
	}
	
	public JsonObjectBuilder json( DatasetVersion dsv ) {
		return ( dsv==null ) 
				? null<commit_msg>Tests for BriefJsonPrinter<commit_after>package edu.harvard.iq.dataverse.util.json;

import edu.harvard.iq.dataverse.DatasetVersion;
import edu.harvard.iq.dataverse.authorization.providers.builtin.BuiltinUser;
import edu.harvard.iq.dataverse.MetadataBlock;
import static edu.harvard.iq.dataverse.util.json.NullSafeJsonBuilder.jsonObjectBuilder;
import edu.harvard.iq.dataverse.workflow.Workflow;
import javax.json.JsonObjectBuilder;

/**
 * A Json printer that prints minimal data on objects. Useful when embedding 
 * objects inside others.
 * 
 * @author michael
 */
public class BriefJsonPrinter {
	
	public JsonObjectBuilder json( BuiltinUser usr ) {
		return ( usr==null ) 
				? null
				: jsonObjectBuilder().add("id", usr.getId())
					.add("firstName", usr.getFirstName())
					.add("lastName", usr.getLastName())
					.add("affiliation", usr.getAffiliation())
					;
	}
	
	public JsonObjectBuilder json( DatasetVersion dsv ) {
		return ( dsv==null ) 
				? null
{'fraction_non_alphanumeric': 0.11797752808988764, 'fraction_numerical': 0.0, 'mean_word_length': 4.396694214876033, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, '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': '6721757', 'n_tokens_mistral': 696, 'n_tokens_neox': 632, 'n_words': 121}