<commit_before>package owltools.gaf.lego.server.handler;

import javax.ws.rs.Consumes;
import javax.ws.rs.FormParam;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.QueryParam;

import com.google.gson.annotations.SerializedName;

import owltools.gaf.lego.json.JsonAnnotation;
import owltools.gaf.lego.json.JsonEvidenceInfo;
import owltools.gaf.lego.json.JsonOwlFact;
import owltools.gaf.lego.json.JsonOwlIndividual;
import owltools.gaf.lego.json.JsonOwlObject;
import owltools.gaf.lego.json.JsonRelationInfo;

@Path("/")
public interface M3BatchHandler {

	public static class M3Request {
		String entity;
		String operation;
		M3Argument arguments;
	}
	
	public static enum Entity {
		individual,
		edge,
		model,
		relations,
		evidence;
		
		public static boolean match(Entity e, String s) {
			return e.name().equals(s);
		}
		
		public static Entity get(String s) {
			if (s != null) {
				for(Entity e : Entity.values()) {
					if (e.name().equals(s)) {
						return e;
					}
				}
			}
			return null;
		}
	}
	
	public static enum Operation {
		get("get"),
		addType("add-type"),
		removeType("remove-type"),
		add("add"),
		remove("remove"),
		addAnnotation("add-annotation"),
		removeAnnotation("remove-annotation"),
		generate("generate"),
		generateBlank("generate-blank"),
		exportModel("export"),
		exportModelLegacy("export-legacy"),
		importModel("import"),
		storeModel("store"),
		allModelIds("all-model-ids"),
		allModelMeta("all-model-meta"),
		updateImports("update-imports"),
		
		// undo operations for models
		undo("undo"), // undo the latest op
		redo("redo"), // redo the latest undo
		getUndoRedo("get-undo-redo"); // get a list of all currently available undo and redo for a model
		
		private final String lbl;
		
		private Operation(String lbl) {
			this.lbl = lbl;
		}
		
		public String getLbl() {
			return lbl;
		}
		
		public static boolean match(Operation op, String s) {
			return op.lbl.equals(s);
		}
		
		public static Operation get(String s) {
			if (s != null) {
				for(Operation op : Operation.values()) {
					if (op.lbl.equals(s)) {
						return op;
					}
				}
			}
			return null;
		}
	}
	
	public static class M3Argument {
		
		 @SerializedName("model-id")
		String modelId;
		String subject;
		String object;
		String predicate;
		String individual;
		String db; // TODO deprecate db, should use taxonId instead
		
		@SerializedName("taxon-id")
		String taxonId;
		<commit_msg>make db field obsolete<commit_after>package owltools.gaf.lego.server.handler;

import javax.ws.rs.Consumes;
import javax.ws.rs.FormParam;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.QueryParam;

import com.google.gson.annotations.SerializedName;

import owltools.gaf.lego.json.JsonAnnotation;
import owltools.gaf.lego.json.JsonEvidenceInfo;
import owltools.gaf.lego.json.JsonOwlFact;
import owltools.gaf.lego.json.JsonOwlIndividual;
import owltools.gaf.lego.json.JsonOwlObject;
import owltools.gaf.lego.json.JsonRelationInfo;

@Path("/")
public interface M3BatchHandler {

	public static class M3Request {
		String entity;
		String operation;
		M3Argument arguments;
	}
	
	public static enum Entity {
		individual,
		edge,
		model,
		relations,
		evidence;
		
		public static boolean match(Entity e, String s) {
			return e.name().equals(s);
		}
		
		public static Entity get(String s) {
			if (s != null) {
				for(Entity e : Entity.values()) {
					if (e.name().equals(s)) {
						return e;
					}
				}
			}
			return null;
		}
	}
	
	public static enum Operation {
		get("get"),
		addType("add-type"),
		removeType("remove-type"),
		add("add"),
		remove("remove"),
		addAnnotation("add-annotation"),
		removeAnnotation("remove-annotation"),
		generate("generate"),
		generateBlank("generate-blank"),
		exportModel("export"),
		exportModelLegacy("export-legacy"),
		importModel("import"),
		storeModel("store"),
		allModelIds("all-model-ids"),
		allModelMeta("all-model-meta"),
		updateImports("update-imports"),
		
		// undo operations for models
		undo("undo"), // undo the latest op
		redo("redo"), // redo the latest undo
		getUndoRedo("get-undo-redo"); // get a list of all currently available undo and redo for a model
		
		private final String lbl;
		
		private Operation(String lbl) {
			this.lbl = lbl;
		}
		
		public String getLbl() {
			return lbl;
		}
		
		public static boolean match(Operation op, String s) {
			return op.lbl.equals(s);
		}
		
		public static Operation get(String s) {
			if (s != null) {
				for(Operation op : Operation.values()) {
					if (op.lbl.equals(s)) {
						return op;
					}
				}
			}
			return null;
		}
	}
	
	public static class M3Argument {
		
		 @SerializedName("model-id")
		String modelId;
		String subject;
		String object;
		String predicate;
		String individual;
		
		@Deprecated
		String db; // TODO deprecate db, should use taxonId instead
		
		@SerializedName("taxon-id")
		String taxonId;
		
{'fraction_non_alphanumeric': 0.1288701246481705, 'fraction_numerical': 0.0016083634901487736, 'mean_word_length': 3.481981981981982, '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': '6820554', 'n_tokens_mistral': 1972, 'n_tokens_neox': 1652, 'n_words': 388}