id
int32
0
12.9k
code
sequencelengths
2
264k
8,700
[ "<s>", "package", "annis", ".", "model", ";", "import", "java", ".", "io", ".", "Serializable", ";", "import", "org", ".", "apache", ".", "commons", ".", "lang3", ".", "builder", ".", "EqualsBuilder", ";", "import", "org", ".", "apache", ".", "commons", ".", "lang3", ".", "builder", ".", "HashCodeBuilder", ";", "import", "annis", ".", "model", ".", "QueryNode", ".", "TextMatching", ";", "public", "class", "QueryAnnotation", "implements", "Comparable", "<", "QueryAnnotation", ">", ",", "Serializable", "{", "private", "String", "namespace", ";", "private", "String", "name", ";", "private", "String", "value", ";", "private", "String", "type", ";", "private", "String", "corpusName", ";", "private", "TextMatching", "textMatching", ";", "public", "QueryAnnotation", "(", "String", "namespace", ",", "String", "name", ")", "{", "this", "(", "namespace", ",", "name", ",", "null", ",", "null", ")", ";", "}", "public", "QueryAnnotation", "(", "String", "namespace", ",", "String", "name", ",", "String", "value", ")", "{", "this", "(", "namespace", ",", "name", ",", "value", ",", "TextMatching", ".", "EXACT_EQUAL", ")", ";", "}", "public", "QueryAnnotation", "(", "String", "namespace", ",", "String", "name", ",", "String", "value", ",", "TextMatching", "textMatching", ")", "{", "this", ".", "namespace", "=", "namespace", ";", "this", ".", "name", "=", "name", ";", "this", ".", "value", "=", "value", ";", "this", ".", "textMatching", "=", "textMatching", ";", "}", "public", "QueryAnnotation", "(", "String", "namespace", ",", "String", "name", ",", "String", "value", ",", "String", "type", ",", "String", "corpusName", ")", "{", "this", "(", "namespace", ",", "name", ",", "value", ")", ";", "this", ".", "type", "=", "type", ";", "this", ".", "corpusName", "=", "corpusName", ";", "}", "@", "Override", "public", "String", "toString", "(", ")", "{", "StringBuffer", "sb", "=", "new", "StringBuffer", "(", ")", ";", "sb", ".", "append", "(", "QueryNode", ".", "qName", "(", "namespace", ",", "name", ")", ")", ";", "if", "(", "value", "!=", "null", ")", "{", "sb", ".", "append", "(", "\"", "\"", ")", ";", "sb", ".", "append", "(", "textMatching", ")", ";", "sb", ".", "append", "(", "\"", "\"", ")", ";", "sb", ".", "append", "(", "value", ")", ";", "}", "return", "sb", ".", "toString", "(", ")", ";", "}", "public", "int", "compareTo", "(", "QueryAnnotation", "o", ")", "{", "String", "name1", "=", "getQualifiedName", "(", ")", ";", "String", "name2", "=", "o", ".", "getQualifiedName", "(", ")", ";", "return", "name1", ".", "compareTo", "(", "name2", ")", ";", "}", "@", "Override", "public", "boolean", "equals", "(", "Object", "obj", ")", "{", "if", "(", "obj", "==", "null", "||", "!", "(", "obj", "instanceof", "QueryAnnotation", ")", ")", "return", "false", ";", "QueryAnnotation", "other", "=", "(", "QueryAnnotation", ")", "obj", ";", "return", "new", "EqualsBuilder", "(", ")", ".", "append", "(", "this", ".", "namespace", ",", "other", ".", "namespace", ")", ".", "append", "(", "this", ".", "name", ",", "other", ".", "name", ")", ".", "append", "(", "this", ".", "value", ",", "other", ".", "value", ")", ".", "append", "(", "this", ".", "textMatching", ",", "other", ".", "textMatching", ")", ".", "isEquals", "(", ")", ";", "}", "@", "Override", "public", "int", "hashCode", "(", ")", "{", "return", "new", "HashCodeBuilder", "(", ")", ".", "append", "(", "namespace", ")", ".", "append", "(", "name", ")", ".", "append", "(", "value", ")", ".", "append", "(", "textMatching", ")", ".", "toHashCode", "(", ")", ";", "}", "public", "String", "getValue", "(", ")", "{", "return", "value", ";", "}", "public", "void", "setValue", "(", "String", "value", ")", "{", "this", ".", "value", "=", "value", ";", "}", "public", "TextMatching", "getTextMatching", "(", ")", "{", "return", "textMatching", ";", "}", "public", "void", "setTextMatching", "(", "TextMatching", "textMatching", ")", "{", "this", ".", "textMatching", "=", "textMatching", ";", "}", "public", "String", "getNamespace", "(", ")", "{", "return", "namespace", ";", "}", "public", "void", "setNamespace", "(", "String", "namespace", ")", "{", "this", ".", "namespace", "=", "namespace", ";", "}", "public", "String", "getName", "(", ")", "{", "return", "name", ";", "}", "public", "void", "setName", "(", "String", "name", ")", "{", "this", ".", "name", "=", "name", ";", "}", "public", "String", "getQualifiedName", "(", ")", "{", "return", "QueryNode", ".", "qName", "(", "namespace", ",", "name", ")", ";", "}", "public", "String", "getType", "(", ")", "{", "return", "type", ";", "}", "public", "String", "getCorpusName", "(", ")", "{", "return", "corpusName", ";", "}", "}", "</s>" ]
8,701
[ "<s>", "package", "annis", ".", "gui", ";", "import", "java", ".", "awt", ".", "Color", ";", "import", "java", ".", "util", ".", "Locale", ";", "import", "org", ".", "apache", ".", "commons", ".", "lang3", ".", "StringUtils", ";", "public", "enum", "MatchedNodeColors", "{", "Red", "(", "new", "Color", "(", "255", ",", "0", ",", "0", ")", ")", ",", "MediumVioletRed", "(", "new", "Color", "(", "199", ",", "21", ",", "133", ")", ")", ",", "LimeGreen", "(", "new", "Color", "(", "50", ",", "205", ",", "50", ")", ")", ",", "Peru", "(", "new", "Color", "(", "205", ",", "133", ",", "63", ")", ")", ",", "IndianRed", "(", "new", "Color", "(", "205", ",", "92", ",", "92", ")", ")", ",", "YellowGreen", "(", "new", "Color", "(", "173", ",", "255", ",", "47", ")", ")", ",", "DarkRed", "(", "new", "Color", "(", "139", ",", "0", ",", "0", ")", ")", ",", "OrangeRed", "(", "new", "Color", "(", "255", ",", "69", ",", "0", ")", ")", ";", "private", "final", "Color", "color", ";", "private", "MatchedNodeColors", "(", "Color", "color", ")", "{", "this", ".", "color", "=", "color", ";", "}", "public", "Color", "getColor", "(", ")", "{", "return", "color", ";", "}", "public", "String", "getHTMLColor", "(", ")", "{", "StringBuilder", "result", "=", "new", "StringBuilder", "(", "\"#\"", ")", ";", "result", ".", "append", "(", "twoDigitHex", "(", "color", ".", "getRed", "(", ")", ")", ")", ";", "result", ".", "append", "(", "twoDigitHex", "(", "color", ".", "getGreen", "(", ")", ")", ")", ";", "result", ".", "append", "(", "twoDigitHex", "(", "color", ".", "getBlue", "(", ")", ")", ")", ";", "return", "result", ".", "toString", "(", ")", ";", "}", "private", "String", "twoDigitHex", "(", "int", "i", ")", "{", "String", "result", "=", "Integer", ".", "toHexString", "(", "i", ")", ".", "toLowerCase", "(", "new", "Locale", "(", "\"en\"", ")", ")", ";", "if", "(", "result", ".", "length", "(", ")", ">", "2", ")", "{", "result", "=", "result", ".", "substring", "(", "0", ",", "2", ")", ";", "}", "else", "if", "(", "result", ".", "length", "(", ")", "<", "2", ")", "{", "result", "=", "StringUtils", ".", "leftPad", "(", "result", ",", "2", ",", "'0'", ")", ";", "}", "return", "result", ";", "}", "public", "static", "String", "colorClassByMatch", "(", "Long", "match", ")", "{", "if", "(", "match", "==", "null", ")", "{", "return", "null", ";", "}", "long", "m", "=", "match", ";", "m", "=", "Math", ".", "min", "(", "m", ",", "8", ")", ";", "return", "\"match_\"", "+", "m", ";", "}", "}", "</s>" ]
8,702
[ "<s>", "package", "annis", ".", "gui", ".", "media", ";", "import", "net", ".", "xeoh", ".", "plugins", ".", "base", ".", "Plugin", ";", "public", "interface", "MediaControllerFactory", "extends", "Plugin", "{", "public", "MediaController", "getOrCreate", "(", "MediaControllerHolder", "holder", ")", ";", "}", "</s>" ]
8,703
[ "<s>", "package", "annis", ".", "gui", ".", "media", ";", "public", "interface", "MimeTypeErrorListener", "{", "public", "void", "notifyCannotPlayMimeType", "(", "String", "mimeType", ")", ";", "}", "</s>" ]
8,704
[ "<s>", "package", "annis", ".", "gui", ".", "media", ";", "import", "annis", ".", "gui", ".", "VisualizationToggle", ";", "import", "net", ".", "xeoh", ".", "plugins", ".", "base", ".", "Plugin", ";", "public", "interface", "MediaController", "extends", "Plugin", "{", "public", "void", "play", "(", "String", "resultID", ",", "double", "startTime", ")", ";", "public", "void", "play", "(", "String", "resultID", ",", "double", "startTime", ",", "double", "endTime", ")", ";", "public", "void", "pauseAll", "(", ")", ";", "public", "void", "addMediaPlayer", "(", "MediaPlayer", "player", ",", "String", "resultID", ",", "VisualizationToggle", "toggle", ")", ";", "public", "void", "clearMediaPlayers", "(", ")", ";", "}", "</s>" ]
8,705
[ "<s>", "package", "annis", ".", "gui", ".", "media", ";", "public", "interface", "MediaPlayer", "{", "public", "void", "play", "(", "double", "start", ")", ";", "public", "void", "play", "(", "double", "start", ",", "double", "end", ")", ";", "public", "void", "pause", "(", ")", ";", "public", "void", "stop", "(", ")", ";", "}", "</s>" ]
8,706
[ "<s>", "package", "annis", ".", "gui", ".", "media", ";", "public", "interface", "MediaControllerHolder", "{", "public", "MediaController", "getMediaController", "(", ")", ";", "public", "void", "setMediaController", "(", "MediaController", "mediaController", ")", ";", "}", "</s>" ]
8,707
[ "<s>", "package", "annis", ".", "gui", ";", "import", "annis", ".", "visualizers", ".", "LoadableVisualizer", ";", "public", "interface", "VisualizationToggle", "{", "public", "void", "toggleVisualizer", "(", "boolean", "visible", ",", "LoadableVisualizer", ".", "Callback", "callback", ")", ";", "public", "boolean", "visualizerIsVisible", "(", ")", ";", "}", "</s>" ]
8,708
[ "<s>", "package", "annis", ".", "provider", ";", "import", "annis", ".", "exceptions", ".", "AnnisQLSyntaxException", ";", "import", "javax", ".", "ws", ".", "rs", ".", "core", ".", "Response", ";", "import", "javax", ".", "ws", ".", "rs", ".", "ext", ".", "ExceptionMapper", ";", "import", "javax", ".", "ws", ".", "rs", ".", "ext", ".", "Provider", ";", "@", "Provider", "public", "class", "AnnisQLSyntaxMapper", "implements", "ExceptionMapper", "<", "AnnisQLSyntaxException", ">", "{", "@", "Override", "public", "Response", "toResponse", "(", "AnnisQLSyntaxException", "exception", ")", "{", "return", "Response", ".", "status", "(", "Response", ".", "Status", ".", "BAD_REQUEST", ")", ".", "entity", "(", "\"\"", "+", "exception", ".", "getMessage", "(", ")", ")", ".", "type", "(", "\"text/plain\"", ")", ".", "build", "(", ")", ";", "}", "}", "</s>" ]
8,709
[ "<s>", "package", "annis", ".", "provider", ";", "import", "de", ".", "hu_berlin", ".", "german", ".", "korpling", ".", "saltnpepper", ".", "salt", ".", "saltCommon", ".", "SaltCommonFactory", ";", "import", "de", ".", "hu_berlin", ".", "german", ".", "korpling", ".", "saltnpepper", ".", "salt", ".", "saltCommon", ".", "SaltCommonPackage", ";", "import", "de", ".", "hu_berlin", ".", "german", ".", "korpling", ".", "saltnpepper", ".", "salt", ".", "saltCommon", ".", "SaltProject", ";", "import", "de", ".", "hu_berlin", ".", "german", ".", "korpling", ".", "saltnpepper", ".", "salt", ".", "saltCommon", ".", "sCorpusStructure", ".", "SCorpusGraph", ";", "import", "de", ".", "hu_berlin", ".", "german", ".", "korpling", ".", "saltnpepper", ".", "salt", ".", "saltCommon", ".", "sCorpusStructure", ".", "SDocument", ";", "import", "java", ".", "io", ".", "IOException", ";", "import", "java", ".", "io", ".", "InputStream", ";", "import", "java", ".", "io", ".", "OutputStream", ";", "import", "java", ".", "lang", ".", "annotation", ".", "Annotation", ";", "import", "java", ".", "lang", ".", "reflect", ".", "Type", ";", "import", "java", ".", "util", ".", "Map", ";", "import", "java", ".", "util", ".", "logging", ".", "Level", ";", "import", "java", ".", "util", ".", "logging", ".", "Logger", ";", "import", "javax", ".", "ws", ".", "rs", ".", "WebApplicationException", ";", "import", "javax", ".", "ws", ".", "rs", ".", "core", ".", "MediaType", ";", "import", "javax", ".", "ws", ".", "rs", ".", "core", ".", "MultivaluedMap", ";", "import", "javax", ".", "ws", ".", "rs", ".", "ext", ".", "MessageBodyReader", ";", "import", "javax", ".", "ws", ".", "rs", ".", "ext", ".", "MessageBodyWriter", ";", "import", "javax", ".", "ws", ".", "rs", ".", "ext", ".", "Provider", ";", "import", "org", ".", "eclipse", ".", "emf", ".", "ecore", ".", "EObject", ";", "import", "org", ".", "eclipse", ".", "emf", ".", "ecore", ".", "resource", ".", "Resource", ";", "import", "org", ".", "eclipse", ".", "emf", ".", "ecore", ".", "resource", ".", "ResourceSet", ";", "import", "org", ".", "eclipse", ".", "emf", ".", "ecore", ".", "resource", ".", "impl", ".", "ResourceSetImpl", ";", "import", "org", ".", "eclipse", ".", "emf", ".", "ecore", ".", "xmi", ".", "XMLParserPool", ";", "import", "org", ".", "eclipse", ".", "emf", ".", "ecore", ".", "xmi", ".", "XMLResource", ";", "import", "org", ".", "eclipse", ".", "emf", ".", "ecore", ".", "xmi", ".", "impl", ".", "XMIResourceImpl", ";", "import", "org", ".", "eclipse", ".", "emf", ".", "ecore", ".", "xmi", ".", "impl", ".", "XMLParserPoolImpl", ";", "import", "org", ".", "slf4j", ".", "LoggerFactory", ";", "@", "Provider", "public", "class", "SaltProjectProvider", "implements", "MessageBodyWriter", "<", "SaltProject", ">", ",", "MessageBodyReader", "<", "SaltProject", ">", "{", "private", "static", "final", "org", ".", "slf4j", ".", "Logger", "log", "=", "LoggerFactory", ".", "getLogger", "(", "SaltProjectProvider", ".", "class", ")", ";", "private", "static", "ThreadLocal", "<", "XMLParserPool", ">", "xmlParserPool", "=", "new", "ThreadLocal", "<", "XMLParserPool", ">", "(", ")", ";", "@", "Override", "public", "boolean", "isWriteable", "(", "Class", "<", "?", ">", "type", ",", "Type", "genericType", ",", "Annotation", "[", "]", "annotations", ",", "MediaType", "mediaType", ")", "{", "return", "(", "MediaType", ".", "APPLICATION_XML_TYPE", ".", "isCompatible", "(", "mediaType", ")", "||", "MediaType", ".", "TEXT_XML_TYPE", ".", "isCompatible", "(", "mediaType", ")", ")", "&&", "SaltProject", ".", "class", ".", "isAssignableFrom", "(", "type", ")", ";", "}", "@", "Override", "public", "long", "getSize", "(", "SaltProject", "t", ",", "Class", "<", "?", ">", "type", ",", "Type", "genericType", ",", "Annotation", "[", "]", "annotations", ",", "MediaType", "mediaType", ")", "{", "return", "-", "1", ";", "}", "@", "Override", "public", "void", "writeTo", "(", "SaltProject", "project", ",", "Class", "<", "?", ">", "type", ",", "Type", "genericType", ",", "Annotation", "[", "]", "annotations", ",", "MediaType", "mediaType", ",", "MultivaluedMap", "<", "String", ",", "Object", ">", "httpHeaders", ",", "OutputStream", "entityStream", ")", "throws", "IOException", ",", "WebApplicationException", "{", "Resource", "resource", "=", "new", "XMIResourceImpl", "(", ")", ";", "resource", ".", "getContents", "(", ")", ".", "add", "(", "project", ")", ";", "for", "(", "SCorpusGraph", "corpusGraph", ":", "project", ".", "getSCorpusGraphs", "(", ")", ")", "{", "for", "(", "SDocument", "doc", ":", "corpusGraph", ".", "getSDocuments", "(", ")", ")", "{", "if", "(", "doc", ".", "getSDocumentGraph", "(", ")", "!=", "null", ")", "{", "resource", ".", "getContents", "(", ")", ".", "add", "(", "doc", ".", "getSDocumentGraph", "(", ")", ")", ";", "}", "}", "}", "try", "{", "resource", ".", "save", "(", "entityStream", ",", "null", ")", ";", "}", "catch", "(", "Exception", "ex", ")", "{", "log", ".", "error", "(", "\"\"", ",", "ex", ")", ";", "}", "}", "@", "Override", "public", "boolean", "isReadable", "(", "Class", "<", "?", ">", "type", ",", "Type", "genericType", ",", "Annotation", "[", "]", "annotations", ",", "MediaType", "mediaType", ")", "{", "return", "(", "MediaType", ".", "APPLICATION_XML_TYPE", ".", "isCompatible", "(", "mediaType", ")", "||", "MediaType", ".", "TEXT_XML_TYPE", ".", "isCompatible", "(", "mediaType", ")", ")", "&&", "SaltProject", ".", "class", ".", "isAssignableFrom", "(", "type", ")", ";", "}", "@", "Override", "public", "SaltProject", "readFrom", "(", "Class", "<", "SaltProject", ">", "type", ",", "Type", "genericType", ",", "Annotation", "[", "]", "annotations", ",", "MediaType", "mediaType", ",", "MultivaluedMap", "<", "String", ",", "String", ">", "httpHeaders", ",", "InputStream", "entityStream", ")", "throws", "IOException", ",", "WebApplicationException", "{", "ResourceSet", "resourceSet", "=", "new", "ResourceSetImpl", "(", ")", ";", "resourceSet", ".", "getPackageRegistry", "(", ")", ".", "put", "(", "SaltCommonPackage", ".", "eINSTANCE", ".", "getNsURI", "(", ")", ",", "SaltCommonPackage", ".", "eINSTANCE", ")", ";", "XMIResourceImpl", "resource", "=", "new", "XMIResourceImpl", "(", ")", ";", "resourceSet", ".", "getResources", "(", ")", ".", "add", "(", "resource", ")", ";", "if", "(", "xmlParserPool", ".", "get", "(", ")", "==", "null", ")", "{", "xmlParserPool", ".", "set", "(", "new", "XMLParserPoolImpl", "(", ")", ")", ";", "}", "Map", "<", "Object", ",", "Object", ">", "options", "=", "resource", ".", "getDefaultLoadOptions", "(", ")", ";", "options", ".", "put", "(", "XMLResource", ".", "OPTION_USE_PARSER_POOL", ",", "xmlParserPool", ".", "get", "(", ")", ")", ";", "options", ".", "put", "(", "XMLResource", ".", "OPTION_DEFER_IDREF_RESOLUTION", ",", "Boolean", ".", "TRUE", ")", ";", "resource", ".", "load", "(", "entityStream", ",", "null", ")", ";", "SaltProject", "project", "=", "SaltCommonFactory", ".", "eINSTANCE", ".", "createSaltProject", "(", ")", ";", "for", "(", "EObject", "o", ":", "resource", ".", "getContents", "(", ")", ")", "{", "if", "(", "o", "instanceof", "SaltProject", ")", "{", "project", "=", "(", "SaltProject", ")", "o", ";", "break", ";", "}", "}", "return", "project", ";", "}", "}", "</s>" ]
8,710
[ "<s>", "package", "annis", ".", "provider", ";", "import", "annis", ".", "exceptions", ".", "AnnisQLSemanticsException", ";", "import", "javax", ".", "ws", ".", "rs", ".", "core", ".", "Response", ";", "import", "javax", ".", "ws", ".", "rs", ".", "ext", ".", "ExceptionMapper", ";", "import", "javax", ".", "ws", ".", "rs", ".", "ext", ".", "Provider", ";", "@", "Provider", "public", "class", "AnnisQLSemanticsMapper", "implements", "ExceptionMapper", "<", "AnnisQLSemanticsException", ">", "{", "@", "Override", "public", "Response", "toResponse", "(", "AnnisQLSemanticsException", "exception", ")", "{", "return", "Response", ".", "status", "(", "Response", ".", "Status", ".", "BAD_REQUEST", ")", ".", "entity", "(", "\"\"", "+", "exception", ".", "getMessage", "(", ")", ")", ".", "type", "(", "\"text/plain\"", ")", ".", "build", "(", ")", ";", "}", "}", "</s>" ]
8,711
[ "<s>", "package", "annis", ".", "provider", ";", "import", "annis", ".", "exceptions", ".", "AnnisCorpusAccessException", ";", "import", "javax", ".", "ws", ".", "rs", ".", "core", ".", "Response", ";", "import", "javax", ".", "ws", ".", "rs", ".", "ext", ".", "ExceptionMapper", ";", "import", "javax", ".", "ws", ".", "rs", ".", "ext", ".", "Provider", ";", "@", "Provider", "public", "class", "AnnisCorpusAccessMapper", "implements", "ExceptionMapper", "<", "AnnisCorpusAccessException", ">", "{", "@", "Override", "public", "Response", "toResponse", "(", "AnnisCorpusAccessException", "exception", ")", "{", "return", "Response", ".", "status", "(", "Response", ".", "Status", ".", "BAD_REQUEST", ")", ".", "entity", "(", "\"\"", "+", "exception", ".", "getMessage", "(", ")", ")", ".", "type", "(", "\"text/plain\"", ")", ".", "build", "(", ")", ";", "}", "}", "</s>" ]
8,712
[ "<s>", "package", "annis", ".", "service", ".", "objects", ";", "import", "java", ".", "io", ".", "Serializable", ";", "import", "java", ".", "util", ".", "Collection", ";", "import", "java", ".", "util", ".", "LinkedHashSet", ";", "import", "java", ".", "util", ".", "List", ";", "import", "javax", ".", "xml", ".", "bind", ".", "annotation", ".", "XmlElement", ";", "import", "javax", ".", "xml", ".", "bind", ".", "annotation", ".", "XmlElementWrapper", ";", "import", "org", ".", "apache", ".", "commons", ".", "lang3", ".", "builder", ".", "EqualsBuilder", ";", "import", "org", ".", "apache", ".", "commons", ".", "lang3", ".", "builder", ".", "HashCodeBuilder", ";", "import", "javax", ".", "xml", ".", "bind", ".", "annotation", ".", "XmlRootElement", ";", "@", "XmlRootElement", "public", "class", "AnnisAttribute", "implements", "Serializable", "{", "public", "enum", "Type", "{", "node", ",", "edge", ",", "segmentation", ",", "unknown", "}", ";", "public", "enum", "SubType", "{", "n", ",", "d", ",", "p", ",", "c", ",", "unknown", "}", ";", "private", "String", "name", "=", "\"\"", ";", "private", "String", "edgeName", "=", "null", ";", "private", "LinkedHashSet", "<", "String", ">", "distinctValues", "=", "new", "LinkedHashSet", "<", "String", ">", "(", ")", ";", "private", "Type", "type", ";", "private", "SubType", "subtype", ";", "@", "XmlElementWrapper", "(", "name", "=", "\"value-set\"", ")", "@", "XmlElement", "(", "name", "=", "\"value\"", ")", "public", "Collection", "<", "String", ">", "getValueSet", "(", ")", "{", "return", "distinctValues", ";", "}", "public", "void", "setValueSet", "(", "Collection", "<", "String", ">", "values", ")", "{", "this", ".", "distinctValues", "=", "new", "LinkedHashSet", "<", "String", ">", "(", "values", ")", ";", "}", "public", "String", "getName", "(", ")", "{", "return", "this", ".", "name", ";", "}", "public", "void", "setName", "(", "String", "name", ")", "{", "this", ".", "name", "=", "name", ";", "}", "public", "String", "getEdgeName", "(", ")", "{", "return", "edgeName", ";", "}", "public", "void", "setEdgeName", "(", "String", "edgeName", ")", "{", "this", ".", "edgeName", "=", "edgeName", ";", "}", "public", "Type", "getType", "(", ")", "{", "return", "type", ";", "}", "public", "void", "setType", "(", "Type", "type", ")", "{", "this", ".", "type", "=", "type", ";", "}", "public", "SubType", "getSubtype", "(", ")", "{", "return", "subtype", ";", "}", "public", "void", "setSubtype", "(", "SubType", "subtype", ")", "{", "this", ".", "subtype", "=", "subtype", ";", "}", "public", "void", "addValue", "(", "String", "value", ")", "{", "this", ".", "distinctValues", ".", "add", "(", "value", ")", ";", "}", "public", "boolean", "hasValue", "(", "String", "value", ")", "{", "return", "this", ".", "distinctValues", ".", "contains", "(", "value", ")", ";", "}", "@", "Override", "public", "String", "toString", "(", ")", "{", "return", "name", "+", "\"", "\"", "+", "distinctValues", ";", "}", "@", "Override", "public", "boolean", "equals", "(", "Object", "obj", ")", "{", "if", "(", "obj", "==", "null", "||", "!", "(", "obj", "instanceof", "AnnisAttribute", ")", ")", "{", "return", "false", ";", "}", "AnnisAttribute", "other", "=", "(", "AnnisAttribute", ")", "obj", ";", "return", "new", "EqualsBuilder", "(", ")", ".", "append", "(", "this", ".", "name", ",", "other", ".", "name", ")", ".", "append", "(", "this", ".", "distinctValues", ",", "other", ".", "distinctValues", ")", ".", "isEquals", "(", ")", ";", "}", "@", "Override", "public", "int", "hashCode", "(", ")", "{", "return", "new", "HashCodeBuilder", "(", ")", ".", "append", "(", "name", ")", ".", "append", "(", "distinctValues", ")", ".", "toHashCode", "(", ")", ";", "}", "}", "</s>" ]
8,713
[ "<s>", "package", "annis", ".", "service", ".", "objects", ";", "import", "java", ".", "io", ".", "Serializable", ";", "import", "java", ".", "util", ".", "Arrays", ";", "import", "javax", ".", "xml", ".", "bind", ".", "annotation", ".", "XmlRootElement", ";", "@", "XmlRootElement", "public", "class", "AnnisBinary", "extends", "AnnisBinaryMetaData", "implements", "Serializable", "{", "private", "byte", "[", "]", "bytes", ";", "public", "byte", "[", "]", "getBytes", "(", ")", "{", "return", "Arrays", ".", "copyOf", "(", "bytes", ",", "bytes", ".", "length", ")", ";", "}", "public", "void", "setBytes", "(", "byte", "[", "]", "bytes", ")", "{", "if", "(", "bytes", "==", "null", ")", "{", "throw", "new", "RuntimeException", "(", "\"\"", ")", ";", "}", "this", ".", "bytes", "=", "Arrays", ".", "copyOf", "(", "bytes", ",", "bytes", ".", "length", ")", ";", "}", "}", "</s>" ]
8,714
[ "<s>", "package", "annis", ".", "service", ".", "objects", ";", "import", "java", ".", "io", ".", "Serializable", ";", "import", "javax", ".", "xml", ".", "bind", ".", "annotation", ".", "XmlRootElement", ";", "@", "XmlRootElement", "public", "class", "AnnisBinaryMetaData", "implements", "Serializable", "{", "private", "String", "corpusName", ";", "private", "String", "mimeType", ";", "private", "String", "fileName", ";", "private", "int", "length", ";", "public", "String", "getCorpusName", "(", ")", "{", "return", "corpusName", ";", "}", "public", "void", "setCorpusName", "(", "String", "corpusName", ")", "{", "this", ".", "corpusName", "=", "corpusName", ";", "}", "public", "String", "getMimeType", "(", ")", "{", "return", "mimeType", ";", "}", "public", "void", "setMimeType", "(", "String", "mimeType", ")", "{", "this", ".", "mimeType", "=", "mimeType", ";", "}", "public", "String", "getFileName", "(", ")", "{", "return", "fileName", ";", "}", "public", "void", "setFileName", "(", "String", "fileName", ")", "{", "this", ".", "fileName", "=", "fileName", ";", "}", "public", "int", "getLength", "(", ")", "{", "return", "length", ";", "}", "public", "void", "setLength", "(", "int", "length", ")", "{", "this", ".", "length", "=", "length", ";", "}", "}", "</s>" ]
8,715
[ "<s>", "package", "annis", ".", "service", ".", "objects", ";", "import", "java", ".", "io", ".", "Serializable", ";", "import", "java", ".", "util", ".", "Map", ";", "import", "javax", ".", "xml", ".", "bind", ".", "annotation", ".", "XmlElementWrapper", ";", "import", "javax", ".", "xml", ".", "bind", ".", "annotation", ".", "XmlRootElement", ";", "@", "XmlRootElement", "public", "class", "CorpusConfig", "implements", "Serializable", "{", "private", "Map", "<", "String", ",", "String", ">", "config", ";", "@", "XmlElementWrapper", "public", "Map", "<", "String", ",", "String", ">", "getConfig", "(", ")", "{", "return", "config", ";", "}", "public", "void", "setConfig", "(", "Map", "<", "String", ",", "String", ">", "config", ")", "{", "this", ".", "config", "=", "config", ";", "}", "}", "</s>" ]
8,716
[ "<s>", "package", "annis", ".", "service", ".", "objects", ";", "import", "java", ".", "io", ".", "Serializable", ";", "import", "java", ".", "util", ".", "Collection", ";", "import", "java", ".", "util", ".", "HashSet", ";", "import", "javax", ".", "xml", ".", "bind", ".", "annotation", ".", "XmlRootElement", ";", "@", "XmlRootElement", "public", "class", "AnnisCorpusSet", "extends", "HashSet", "<", "AnnisCorpus", ">", "implements", "Serializable", "{", "public", "AnnisCorpusSet", "(", ")", "{", "super", "(", ")", ";", "}", "public", "AnnisCorpusSet", "(", "Collection", "<", "?", "extends", "AnnisCorpus", ">", "collection", ")", "{", "super", "(", "collection", ")", ";", "}", "}", "</s>" ]
8,717
[ "<s>", "package", "annis", ".", "service", ".", "objects", ";", "import", "java", ".", "util", ".", "HashMap", ";", "import", "org", ".", "apache", ".", "commons", ".", "lang3", ".", "builder", ".", "EqualsBuilder", ";", "import", "org", ".", "apache", ".", "commons", ".", "lang3", ".", "builder", ".", "HashCodeBuilder", ";", "import", "annis", ".", "service", ".", "ifaces", ".", "AnnisToken", ";", "public", "class", "AnnisTokenImpl", "extends", "HashMap", "<", "String", ",", "String", ">", "implements", "AnnisToken", "{", "private", "long", "id", ";", "private", "String", "text", ";", "private", "long", "left", ";", "private", "long", "right", ";", "private", "long", "tokenIndex", ";", "private", "long", "corpusId", ";", "public", "AnnisTokenImpl", "(", "long", "id", ",", "String", "text", ",", "long", "left", ",", "long", "right", ",", "long", "tokenIndex", ",", "long", "corpusId", ")", "{", "this", ".", "id", "=", "id", ";", "this", ".", "text", "=", "text", ";", "this", ".", "left", "=", "left", ";", "this", ".", "right", "=", "right", ";", "this", ".", "tokenIndex", "=", "tokenIndex", ";", "this", ".", "corpusId", "=", "corpusId", ";", "}", "public", "AnnisTokenImpl", "(", ")", "{", "}", "@", "Override", "public", "long", "getId", "(", ")", "{", "return", "id", ";", "}", "@", "Override", "public", "String", "getText", "(", ")", "{", "return", "text", ";", "}", "@", "Override", "public", "long", "getLeft", "(", ")", "{", "return", "left", ";", "}", "@", "Override", "public", "long", "getRight", "(", ")", "{", "return", "right", ";", "}", "@", "Override", "public", "long", "getTokenIndex", "(", ")", "{", "return", "tokenIndex", ";", "}", "@", "Override", "public", "boolean", "equals", "(", "Object", "o", ")", "{", "if", "(", "!", "(", "o", "instanceof", "AnnisTokenImpl", ")", ")", "{", "return", "false", ";", "}", "AnnisTokenImpl", "other", "=", "(", "AnnisTokenImpl", ")", "o", ";", "return", "new", "EqualsBuilder", "(", ")", ".", "append", "(", "this", ".", "id", ",", "other", ".", "id", ")", ".", "append", "(", "this", ".", "text", ",", "other", ".", "text", ")", ".", "isEquals", "(", ")", ";", "}", "@", "Override", "public", "int", "hashCode", "(", ")", "{", "return", "new", "HashCodeBuilder", "(", ")", ".", "append", "(", "id", ")", ".", "append", "(", "text", ")", ".", "toHashCode", "(", ")", ";", "}", "public", "void", "setId", "(", "long", "id", ")", "{", "}", "@", "Override", "public", "void", "setText", "(", "String", "text", ")", "{", "}", "@", "Override", "public", "String", "toString", "(", ")", "{", "return", "\"token:", "'\"", "+", "text", "+", "\"'", "\"", "+", "super", ".", "toString", "(", ")", ";", "}", "@", "Override", "public", "long", "getCorpusId", "(", ")", "{", "return", "this", ".", "corpusId", ";", "}", "@", "Override", "public", "void", "setCorpusId", "(", "long", "corpusId", ")", "{", "this", ".", "corpusId", "=", "corpusId", ";", "}", "}", "</s>" ]
8,718
[ "<s>", "package", "annis", ".", "service", ".", "objects", ";", "import", "java", ".", "io", ".", "Serializable", ";", "import", "java", ".", "util", ".", "Collection", ";", "import", "java", ".", "util", ".", "Comparator", ";", "import", "java", ".", "util", ".", "HashSet", ";", "import", "java", ".", "util", ".", "Set", ";", "import", "java", ".", "util", ".", "TreeSet", ";", "import", "annis", ".", "service", ".", "ifaces", ".", "AnnisResult", ";", "import", "annis", ".", "service", ".", "ifaces", ".", "AnnisResultSet", ";", "public", "class", "AnnisResultSetImpl", "extends", "TreeSet", "<", "AnnisResult", ">", "implements", "AnnisResultSet", "{", "private", "static", "class", "AnnisResultSetComparator", "implements", "Comparator", "<", "AnnisResult", ">", ",", "Serializable", "{", "@", "Override", "public", "int", "compare", "(", "AnnisResult", "o1", ",", "AnnisResult", "o2", ")", "{", "int", "order", "=", "Long", ".", "signum", "(", "o1", ".", "getStartNodeId", "(", ")", "-", "o2", ".", "getStartNodeId", "(", ")", ")", ";", "if", "(", "order", "==", "0", ")", "{", "order", "=", "Long", ".", "signum", "(", "o1", ".", "getEndNodeId", "(", ")", "-", "o2", ".", "getEndNodeId", "(", ")", ")", ";", "if", "(", "order", "==", "0", ")", "return", "-", "1", ";", "else", "return", "order", ";", "}", "else", "return", "order", ";", "}", "}", "public", "AnnisResultSetImpl", "(", ")", "{", "super", "(", "new", "AnnisResultSetComparator", "(", ")", ")", ";", "}", "public", "AnnisResultSetImpl", "(", "Collection", "<", "?", "extends", "AnnisResult", ">", "collection", ")", "{", "this", "(", ")", ";", "addAll", "(", "collection", ")", ";", "}", "@", "Override", "public", "Set", "<", "String", ">", "getAnnotationLevelSet", "(", ")", "{", "Set", "<", "String", ">", "levelSet", "=", "new", "HashSet", "<", "String", ">", "(", ")", ";", "for", "(", "AnnisResult", "result", ":", "this", ")", "levelSet", ".", "addAll", "(", "result", ".", "getAnnotationLevelSet", "(", ")", ")", ";", "return", "levelSet", ";", "}", "@", "Override", "public", "Set", "<", "String", ">", "getTokenAnnotationLevelSet", "(", ")", "{", "Set", "<", "String", ">", "levelSet", "=", "new", "HashSet", "<", "String", ">", "(", ")", ";", "for", "(", "AnnisResult", "result", ":", "this", ")", "levelSet", ".", "addAll", "(", "result", ".", "getTokenAnnotationLevelSet", "(", ")", ")", ";", "return", "levelSet", ";", "}", "}", "</s>" ]
8,719
[ "<s>", "package", "annis", ".", "service", ".", "objects", ";", "import", "java", ".", "io", ".", "Serializable", ";", "import", "javax", ".", "xml", ".", "bind", ".", "annotation", ".", "XmlRootElement", ";", "@", "XmlRootElement", "public", "class", "AnnisCorpus", "implements", "Serializable", ",", "Comparable", "<", "AnnisCorpus", ">", "{", "private", "long", "id", ";", "private", "String", "name", ";", "private", "int", "textCount", ",", "tokenCount", ";", "private", "String", "sourcePath", ";", "public", "AnnisCorpus", "(", "long", "id", ",", "String", "name", ",", "int", "textCount", ",", "int", "tokenCount", ")", "{", "this", ".", "id", "=", "id", ";", "this", ".", "textCount", "=", "textCount", ";", "this", ".", "tokenCount", "=", "tokenCount", ";", "this", ".", "name", "=", "name", ";", "}", "public", "AnnisCorpus", "(", ")", "{", "this", "(", "0", ",", "null", ",", "0", ",", "0", ")", ";", "}", "public", "long", "getId", "(", ")", "{", "return", "id", ";", "}", "public", "void", "setId", "(", "long", "id", ")", "{", "this", ".", "id", "=", "id", ";", "}", "public", "String", "getName", "(", ")", "{", "return", "name", ";", "}", "public", "void", "setName", "(", "String", "name", ")", "{", "this", ".", "name", "=", "name", ";", "}", "public", "int", "getTextCount", "(", ")", "{", "return", "textCount", ";", "}", "public", "void", "setTextCount", "(", "int", "textCount", ")", "{", "this", ".", "textCount", "=", "textCount", ";", "}", "public", "int", "getTokenCount", "(", ")", "{", "return", "tokenCount", ";", "}", "public", "void", "setTokenCount", "(", "int", "tokenCount", ")", "{", "this", ".", "tokenCount", "=", "tokenCount", ";", "}", "public", "String", "getSourcePath", "(", ")", "{", "return", "sourcePath", ";", "}", "public", "void", "setSourcePath", "(", "String", "sourcePath", ")", "{", "this", ".", "sourcePath", "=", "sourcePath", ";", "}", "@", "Override", "public", "String", "toString", "(", ")", "{", "return", "String", ".", "valueOf", "(", "\"corpus", "#\"", "+", "id", "+", "\":", "\"", "+", "name", ")", ";", "}", "@", "Override", "public", "boolean", "equals", "(", "Object", "obj", ")", "{", "if", "(", "obj", "==", "null", ")", "{", "return", "false", ";", "}", "if", "(", "getClass", "(", ")", "!=", "obj", ".", "getClass", "(", ")", ")", "{", "return", "false", ";", "}", "final", "AnnisCorpus", "other", "=", "(", "AnnisCorpus", ")", "obj", ";", "if", "(", "this", ".", "id", "!=", "other", ".", "id", ")", "{", "return", "false", ";", "}", "return", "true", ";", "}", "@", "Override", "public", "int", "hashCode", "(", ")", "{", "int", "hash", "=", "5", ";", "hash", "=", "53", "*", "hash", "+", "(", "int", ")", "(", "this", ".", "id", "^", "(", "this", ".", "id", ">>>", "32", ")", ")", ";", "return", "hash", ";", "}", "@", "Override", "public", "int", "compareTo", "(", "AnnisCorpus", "o", ")", "{", "if", "(", "o", "==", "null", ")", "{", "return", "-", "1", ";", "}", "else", "{", "return", "id", "<", "o", ".", "getId", "(", ")", "?", "-", "1", ":", "(", "id", ">", "o", ".", "getId", "(", ")", "?", "+", "1", ":", "0", ")", ";", "}", "}", "}", "</s>" ]
8,720
[ "<s>", "package", "annis", ".", "service", ".", "objects", ";", "import", "java", ".", "io", ".", "Serializable", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "util", ".", "List", ";", "import", "javax", ".", "xml", ".", "bind", ".", "annotation", ".", "XmlElement", ";", "import", "javax", ".", "xml", ".", "bind", ".", "annotation", ".", "XmlElementWrapper", ";", "import", "javax", ".", "xml", ".", "bind", ".", "annotation", ".", "XmlRootElement", ";", "import", "javax", ".", "xml", ".", "bind", ".", "annotation", ".", "XmlTransient", ";", "@", "SuppressWarnings", "(", "\"serial\"", ")", "@", "XmlRootElement", "public", "class", "Match", "implements", "Serializable", "{", "private", "List", "<", "String", ">", "saltIDs", ";", "public", "Match", "(", ")", "{", "saltIDs", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "}", "public", "void", "setSaltId", "(", "String", "id", ")", "{", "saltIDs", ".", "add", "(", "id", ")", ";", "}", "public", "String", "getSaltId", "(", "int", "i", ")", "{", "return", "saltIDs", ".", "get", "(", "i", ")", ";", "}", "@", "XmlElementWrapper", "(", "name", "=", "\"salt-ids\"", ")", "@", "XmlElement", "(", "name", "=", "\"id\"", ")", "public", "List", "<", "String", ">", "getSaltIDs", "(", ")", "{", "return", "saltIDs", ";", "}", "public", "void", "setSaltIDs", "(", "List", "<", "String", ">", "saltIDs", ")", "{", "this", ".", "saltIDs", "=", "saltIDs", ";", "}", "}", "</s>" ]
8,721
[ "<s>", "package", "annis", ".", "service", ".", "objects", ";", "import", "java", ".", "io", ".", "StringWriter", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "util", ".", "Collections", ";", "import", "java", ".", "util", ".", "HashMap", ";", "import", "java", ".", "util", ".", "HashSet", ";", "import", "java", ".", "util", ".", "LinkedList", ";", "import", "java", ".", "util", ".", "List", ";", "import", "java", ".", "util", ".", "Map", ";", "import", "java", ".", "util", ".", "Set", ";", "import", "javax", ".", "xml", ".", "parsers", ".", "DocumentBuilderFactory", ";", "import", "javax", ".", "xml", ".", "transform", ".", "OutputKeys", ";", "import", "javax", ".", "xml", ".", "transform", ".", "Transformer", ";", "import", "javax", ".", "xml", ".", "transform", ".", "TransformerFactory", ";", "import", "javax", ".", "xml", ".", "transform", ".", "dom", ".", "DOMSource", ";", "import", "javax", ".", "xml", ".", "transform", ".", "stream", ".", "StreamResult", ";", "import", "org", ".", "w3c", ".", "dom", ".", "Document", ";", "import", "org", ".", "w3c", ".", "dom", ".", "Element", ";", "import", "annis", ".", "model", ".", "AnnisNode", ";", "import", "annis", ".", "model", ".", "Annotation", ";", "import", "annis", ".", "model", ".", "AnnotationGraph", ";", "import", "annis", ".", "model", ".", "Edge", ";", "import", "annis", ".", "model", ".", "Edge", ".", "EdgeType", ";", "import", "annis", ".", "service", ".", "ifaces", ".", "AnnisResult", ";", "import", "annis", ".", "service", ".", "ifaces", ".", "AnnisToken", ";", "import", "java", ".", "io", ".", "UnsupportedEncodingException", ";", "import", "java", ".", "util", ".", "LinkedHashSet", ";", "import", "javax", ".", "xml", ".", "parsers", ".", "ParserConfigurationException", ";", "import", "javax", ".", "xml", ".", "transform", ".", "TransformerException", ";", "@", "Deprecated", "public", "class", "AnnisResultImpl", "implements", "AnnisResult", "{", "private", "AnnotationGraph", "graph", ";", "private", "String", "paulaString", "=", "null", ";", "public", "AnnisResultImpl", "(", ")", "{", "}", "public", "AnnisResultImpl", "(", "AnnotationGraph", "graph", ")", "{", "this", ".", "graph", "=", "graph", ";", "}", "public", "List", "<", "AnnisToken", ">", "getTokenList", "(", ")", "{", "List", "<", "AnnisToken", ">", "result", "=", "new", "ArrayList", "<", "AnnisToken", ">", "(", ")", ";", "for", "(", "AnnisNode", "node", ":", "graph", ".", "getTokens", "(", ")", ")", "{", "AnnisTokenImpl", "annisToken", "=", "new", "AnnisTokenImpl", "(", "node", ".", "getId", "(", ")", ",", "node", ".", "getSpannedText", "(", ")", ",", "node", ".", "getLeft", "(", ")", ",", "node", ".", "getRight", "(", ")", ",", "node", ".", "getTokenIndex", "(", ")", ",", "node", ".", "getCorpus", "(", ")", ")", ";", "for", "(", "Annotation", "annotation", ":", "node", ".", "getNodeAnnotations", "(", ")", ")", "{", "annisToken", ".", "put", "(", "annotation", ".", "getQualifiedName", "(", ")", ",", "annotation", ".", "getValue", "(", ")", ")", ";", "}", "result", ".", "add", "(", "annisToken", ")", ";", "}", "return", "result", ";", "}", "public", "long", "getStartNodeId", "(", ")", "{", "List", "<", "AnnisNode", ">", "tokens", "=", "graph", ".", "getTokens", "(", ")", ";", "if", "(", "!", "tokens", ".", "isEmpty", "(", ")", ")", "{", "return", "tokens", ".", "get", "(", "0", ")", ".", "getId", "(", ")", ";", "}", "else", "{", "return", "0", ";", "}", "}", "public", "long", "getEndNodeId", "(", ")", "{", "List", "<", "AnnisNode", ">", "tokens", "=", "graph", ".", "getTokens", "(", ")", ";", "if", "(", "!", "tokens", ".", "isEmpty", "(", ")", ")", "{", "return", "tokens", ".", "get", "(", "tokens", ".", "size", "(", ")", "-", "1", ")", ".", "getId", "(", ")", ";", "}", "else", "{", "return", "0", ";", "}", "}", "public", "Set", "<", "String", ">", "getAnnotationLevelSet", "(", ")", "{", "Set", "<", "String", ">", "result", "=", "new", "HashSet", "<", "String", ">", "(", ")", ";", "for", "(", "AnnisNode", "node", ":", "graph", ".", "getNodes", "(", ")", ")", "{", "if", "(", "!", "node", ".", "isToken", "(", ")", ")", "{", "for", "(", "Annotation", "annotation", ":", "node", ".", "getNodeAnnotations", "(", ")", ")", "{", "result", ".", "add", "(", "annotation", ".", "getQualifiedName", "(", ")", ")", ";", "}", "}", "}", "return", "result", ";", "}", "public", "Set", "<", "String", ">", "getTokenAnnotationLevelSet", "(", ")", "{", "Set", "<", "String", ">", "result", "=", "new", "HashSet", "<", "String", ">", "(", ")", ";", "for", "(", "AnnisNode", "token", ":", "graph", ".", "getTokens", "(", ")", ")", "{", "for", "(", "Annotation", "annotation", ":", "token", ".", "getNodeAnnotations", "(", ")", ")", "{", "result", ".", "add", "(", "annotation", ".", "getQualifiedName", "(", ")", ")", ";", "}", "}", "return", "result", ";", "}", "public", "String", "getMarkerId", "(", "Long", "nodeId", ")", "{", "return", "isMarked", "(", "nodeId", ")", "?", "String", ".", "valueOf", "(", "nodeId", ")", ":", "null", ";", "}", "public", "boolean", "hasMarker", "(", "String", "markerId", ")", "{", "return", "isMarked", "(", "Long", ".", "parseLong", "(", "markerId", ")", ")", ";", "}", "private", "void", "addNamespace", "(", "Set", "<", "String", ">", "namespaces", ",", "String", "namespace", ")", "{", "if", "(", "namespace", "!=", "null", ")", "{", "namespaces", ".", "add", "(", "namespace", ")", ";", "}", "}", "private", "boolean", "isMarked", "(", "Long", "nodeId", ")", "{", "return", "graph", ".", "getMatchedNodeIds", "(", ")", ".", "contains", "(", "nodeId", ")", ";", "}", "public", "AnnotationGraph", "getGraph", "(", ")", "{", "return", "graph", ";", "}", "public", "void", "setGraph", "(", "AnnotationGraph", "graph", ")", "{", "this", ".", "graph", "=", "graph", ";", "}", "@", "Override", "public", "String", "getDocumentName", "(", ")", "{", "return", "graph", ".", "getDocumentName", "(", ")", ";", "}", "@", "Override", "public", "String", "[", "]", "getPath", "(", ")", "{", "return", "graph", ".", "getPath", "(", ")", ";", "}", "}", "</s>" ]
8,722
[ "<s>", "package", "annis", ".", "service", ".", "ifaces", ";", "import", "annis", ".", "model", ".", "AnnotationGraph", ";", "import", "java", ".", "io", ".", "Serializable", ";", "import", "java", ".", "util", ".", "List", ";", "import", "java", ".", "util", ".", "Set", ";", "public", "interface", "AnnisResult", "extends", "Serializable", "{", "public", "String", "getDocumentName", "(", ")", ";", "public", "String", "[", "]", "getPath", "(", ")", ";", "public", "long", "getEndNodeId", "(", ")", ";", "public", "long", "getStartNodeId", "(", ")", ";", "public", "List", "<", "AnnisToken", ">", "getTokenList", "(", ")", ";", "public", "Set", "<", "String", ">", "getAnnotationLevelSet", "(", ")", ";", "public", "Set", "<", "String", ">", "getTokenAnnotationLevelSet", "(", ")", ";", "public", "String", "getMarkerId", "(", "Long", "nodeId", ")", ";", "public", "boolean", "hasMarker", "(", "String", "markerId", ")", ";", "public", "AnnotationGraph", "getGraph", "(", ")", ";", "}", "</s>" ]
8,723
[ "<s>", "package", "annis", ".", "service", ".", "ifaces", ";", "import", "java", ".", "io", ".", "Serializable", ";", "import", "java", ".", "util", ".", "Map", ";", "public", "interface", "AnnisToken", "extends", "Map", "<", "String", ",", "String", ">", ",", "Serializable", "{", "public", "abstract", "long", "getId", "(", ")", ";", "public", "abstract", "void", "setId", "(", "long", "id", ")", ";", "public", "abstract", "String", "getText", "(", ")", ";", "public", "abstract", "void", "setText", "(", "String", "text", ")", ";", "public", "abstract", "long", "getCorpusId", "(", ")", ";", "public", "abstract", "void", "setCorpusId", "(", "long", "corpusId", ")", ";", "long", "getLeft", "(", ")", ";", "long", "getRight", "(", ")", ";", "long", "getTokenIndex", "(", ")", ";", "}", "</s>" ]
8,724
[ "<s>", "package", "annis", ".", "service", ".", "ifaces", ";", "import", "java", ".", "io", ".", "Serializable", ";", "import", "java", ".", "util", ".", "Set", ";", "public", "interface", "AnnisResultSet", "extends", "Set", "<", "AnnisResult", ">", ",", "Serializable", "{", "public", "abstract", "Set", "<", "String", ">", "getAnnotationLevelSet", "(", ")", ";", "public", "abstract", "Set", "<", "String", ">", "getTokenAnnotationLevelSet", "(", ")", ";", "}", "</s>" ]
8,725
[ "<s>", "package", "annis", ".", "resolver", ";", "import", "java", ".", "io", ".", "Serializable", ";", "import", "java", ".", "util", ".", "Properties", ";", "import", "javax", ".", "xml", ".", "bind", ".", "annotation", ".", "XmlRootElement", ";", "@", "XmlRootElement", "public", "class", "ResolverEntry", "implements", "Serializable", "{", "public", "enum", "ElementType", "{", "node", ",", "edge", "}", "private", "long", "id", ";", "private", "String", "corpus", ";", "private", "String", "version", ";", "private", "String", "namespace", ";", "private", "ElementType", "element", ";", "private", "String", "visType", ";", "private", "String", "displayName", ";", "private", "String", "visibility", ";", "private", "Properties", "mappings", ";", "private", "int", "order", ";", "public", "ResolverEntry", "(", ")", "{", "}", "public", "ResolverEntry", "(", "long", "id", ",", "String", "corpus", ",", "String", "version", ",", "String", "namespace", ",", "ElementType", "element", ",", "String", "visType", ",", "String", "displayName", ",", "String", "visibility", ",", "Properties", "mappings", ",", "int", "order", ")", "{", "this", ".", "id", "=", "id", ";", "this", ".", "corpus", "=", "corpus", ";", "this", ".", "version", "=", "version", ";", "this", ".", "namespace", "=", "namespace", ";", "this", ".", "element", "=", "element", ";", "this", ".", "visType", "=", "visType", ";", "this", ".", "displayName", "=", "displayName", ";", "this", ".", "mappings", "=", "mappings", ";", "this", ".", "visibility", "=", "visibility", ";", "this", ".", "order", "=", "order", ";", "}", "public", "String", "getCorpus", "(", ")", "{", "return", "corpus", ";", "}", "public", "void", "setCorpus", "(", "String", "corpus", ")", "{", "this", ".", "corpus", "=", "corpus", ";", "}", "public", "String", "getDisplayName", "(", ")", "{", "return", "displayName", ";", "}", "public", "void", "setDisplayName", "(", "String", "displayName", ")", "{", "this", ".", "displayName", "=", "displayName", ";", "}", "public", "ElementType", "getElement", "(", ")", "{", "return", "element", ";", "}", "public", "void", "setElement", "(", "ElementType", "element", ")", "{", "this", ".", "element", "=", "element", ";", "}", "public", "long", "getId", "(", ")", "{", "return", "id", ";", "}", "public", "void", "setId", "(", "long", "id", ")", "{", "this", ".", "id", "=", "id", ";", "}", "public", "Properties", "getMappings", "(", ")", "{", "return", "mappings", ";", "}", "public", "void", "setMappings", "(", "Properties", "mappings", ")", "{", "this", ".", "mappings", "=", "mappings", ";", "}", "public", "String", "getNamespace", "(", ")", "{", "return", "namespace", ";", "}", "public", "void", "setNamespace", "(", "String", "namespace", ")", "{", "this", ".", "namespace", "=", "namespace", ";", "}", "public", "int", "getOrder", "(", ")", "{", "return", "order", ";", "}", "public", "void", "setOrder", "(", "int", "order", ")", "{", "this", ".", "order", "=", "order", ";", "}", "public", "String", "getVersion", "(", ")", "{", "return", "version", ";", "}", "public", "void", "setVersion", "(", "String", "version", ")", "{", "this", ".", "version", "=", "version", ";", "}", "public", "String", "getVisType", "(", ")", "{", "return", "visType", ";", "}", "public", "void", "setVisType", "(", "String", "visType", ")", "{", "this", ".", "visType", "=", "visType", ";", "}", "public", "String", "getVisibility", "(", ")", "{", "return", "this", ".", "visibility", ";", "}", "public", "void", "setVisibility", "(", "String", "visibility", ")", "{", "this", ".", "visibility", "=", "visibility", ";", "}", "@", "Override", "public", "boolean", "equals", "(", "Object", "obj", ")", "{", "if", "(", "obj", "==", "null", ")", "{", "return", "false", ";", "}", "if", "(", "getClass", "(", ")", "!=", "obj", ".", "getClass", "(", ")", ")", "{", "return", "false", ";", "}", "final", "ResolverEntry", "other", "=", "(", "ResolverEntry", ")", "obj", ";", "if", "(", "this", ".", "id", "!=", "other", ".", "id", ")", "{", "return", "false", ";", "}", "if", "(", "(", "this", ".", "corpus", "==", "null", ")", "?", "(", "other", ".", "corpus", "!=", "null", ")", ":", "!", "this", ".", "corpus", ".", "equals", "(", "other", ".", "corpus", ")", ")", "{", "return", "false", ";", "}", "if", "(", "(", "this", ".", "version", "==", "null", ")", "?", "(", "other", ".", "version", "!=", "null", ")", ":", "!", "this", ".", "version", ".", "equals", "(", "other", ".", "version", ")", ")", "{", "return", "false", ";", "}", "if", "(", "(", "this", ".", "namespace", "==", "null", ")", "?", "(", "other", ".", "namespace", "!=", "null", ")", ":", "!", "this", ".", "namespace", ".", "equals", "(", "other", ".", "namespace", ")", ")", "{", "return", "false", ";", "}", "if", "(", "this", ".", "element", "!=", "other", ".", "element", "&&", "(", "this", ".", "element", "==", "null", "||", "!", "this", ".", "element", ".", "equals", "(", "other", ".", "element", ")", ")", ")", "{", "return", "false", ";", "}", "if", "(", "(", "this", ".", "visType", "==", "null", ")", "?", "(", "other", ".", "visType", "!=", "null", ")", ":", "!", "this", ".", "visType", ".", "equals", "(", "other", ".", "visType", ")", ")", "{", "return", "false", ";", "}", "if", "(", "(", "this", ".", "displayName", "==", "null", ")", "?", "(", "other", ".", "displayName", "!=", "null", ")", ":", "!", "this", ".", "displayName", ".", "equals", "(", "other", ".", "displayName", ")", ")", "{", "return", "false", ";", "}", "if", "(", "(", "this", ".", "visibility", "==", "null", ")", "?", "(", "other", ".", "visibility", "!=", "null", ")", ":", "!", "this", ".", "visibility", ".", "equals", "(", "other", ".", "visibility", ")", ")", "{", "return", "false", ";", "}", "if", "(", "this", ".", "mappings", "!=", "other", ".", "mappings", "&&", "(", "this", ".", "mappings", "==", "null", "||", "!", "this", ".", "mappings", ".", "equals", "(", "other", ".", "mappings", ")", ")", ")", "{", "return", "false", ";", "}", "if", "(", "this", ".", "order", "!=", "other", ".", "order", ")", "{", "return", "false", ";", "}", "return", "true", ";", "}", "@", "Override", "public", "int", "hashCode", "(", ")", "{", "int", "hash", "=", "7", ";", "hash", "=", "97", "*", "hash", "+", "(", "int", ")", "(", "this", ".", "id", "^", "(", "this", ".", "id", ">>>", "32", ")", ")", ";", "hash", "=", "97", "*", "hash", "+", "(", "this", ".", "corpus", "!=", "null", "?", "this", ".", "corpus", ".", "hashCode", "(", ")", ":", "0", ")", ";", "hash", "=", "97", "*", "hash", "+", "(", "this", ".", "version", "!=", "null", "?", "this", ".", "version", ".", "hashCode", "(", ")", ":", "0", ")", ";", "hash", "=", "97", "*", "hash", "+", "(", "this", ".", "namespace", "!=", "null", "?", "this", ".", "namespace", ".", "hashCode", "(", ")", ":", "0", ")", ";", "hash", "=", "97", "*", "hash", "+", "(", "this", ".", "element", "!=", "null", "?", "this", ".", "element", ".", "hashCode", "(", ")", ":", "0", ")", ";", "hash", "=", "97", "*", "hash", "+", "(", "this", ".", "visType", "!=", "null", "?", "this", ".", "visType", ".", "hashCode", "(", ")", ":", "0", ")", ";", "hash", "=", "97", "*", "hash", "+", "(", "this", ".", "displayName", "!=", "null", "?", "this", ".", "displayName", ".", "hashCode", "(", ")", ":", "0", ")", ";", "hash", "=", "97", "*", "hash", "+", "(", "this", ".", "visibility", "!=", "null", "?", "this", ".", "visibility", ".", "hashCode", "(", ")", ":", "0", ")", ";", "hash", "=", "97", "*", "hash", "+", "(", "this", ".", "mappings", "!=", "null", "?", "this", ".", "mappings", ".", "hashCode", "(", ")", ":", "0", ")", ";", "hash", "=", "97", "*", "hash", "+", "this", ".", "order", ";", "return", "hash", ";", "}", "}", "</s>" ]
8,726
[ "<s>", "package", "annis", ".", "resolver", ";", "import", "annis", ".", "resolver", ".", "ResolverEntry", ".", "ElementType", ";", "import", "java", ".", "io", ".", "Serializable", ";", "import", "javax", ".", "xml", ".", "bind", ".", "annotation", ".", "XmlRootElement", ";", "@", "XmlRootElement", "public", "class", "SingleResolverRequest", "implements", "Serializable", "{", "private", "String", "corpusName", ";", "private", "String", "namespace", ";", "private", "ResolverEntry", ".", "ElementType", "type", ";", "public", "SingleResolverRequest", "(", ")", "{", "}", "public", "SingleResolverRequest", "(", "String", "corpusName", ",", "String", "namespace", ",", "ElementType", "type", ")", "{", "this", ".", "corpusName", "=", "corpusName", ";", "this", ".", "namespace", "=", "namespace", ";", "this", ".", "type", "=", "type", ";", "}", "public", "String", "getCorpusName", "(", ")", "{", "return", "corpusName", ";", "}", "public", "String", "getNamespace", "(", ")", "{", "return", "namespace", ";", "}", "public", "ElementType", "getType", "(", ")", "{", "return", "type", ";", "}", "@", "Override", "public", "boolean", "equals", "(", "Object", "obj", ")", "{", "if", "(", "obj", "==", "null", ")", "{", "return", "false", ";", "}", "if", "(", "getClass", "(", ")", "!=", "obj", ".", "getClass", "(", ")", ")", "{", "return", "false", ";", "}", "final", "SingleResolverRequest", "other", "=", "(", "SingleResolverRequest", ")", "obj", ";", "if", "(", "!", "this", ".", "corpusName", ".", "equals", "(", "other", ".", "corpusName", ")", ")", "{", "return", "false", ";", "}", "if", "(", "(", "this", ".", "namespace", "==", "null", ")", "?", "(", "other", ".", "namespace", "!=", "null", ")", ":", "!", "this", ".", "namespace", ".", "equals", "(", "other", ".", "namespace", ")", ")", "{", "return", "false", ";", "}", "if", "(", "this", ".", "type", "!=", "other", ".", "type", ")", "{", "return", "false", ";", "}", "return", "true", ";", "}", "@", "Override", "public", "int", "hashCode", "(", ")", "{", "int", "hash", "=", "7", ";", "hash", "=", "41", "*", "hash", "+", "(", "this", ".", "corpusName", "!=", "null", "?", "this", ".", "corpusName", ".", "hashCode", "(", ")", ":", "0", ")", ";", "hash", "=", "41", "*", "hash", "+", "(", "this", ".", "namespace", "!=", "null", "?", "this", ".", "namespace", ".", "hashCode", "(", ")", ":", "0", ")", ";", "hash", "=", "41", "*", "hash", "+", "(", "this", ".", "type", "!=", "null", "?", "this", ".", "type", ".", "hashCode", "(", ")", ":", "0", ")", ";", "return", "hash", ";", "}", "}", "</s>" ]
8,727
[ "<s>", "package", "annis", ".", "sqlgen", ".", "model", ";", "import", "annis", ".", "model", ".", "QueryNode", ";", "public", "class", "RightOverlap", "extends", "Join", "{", "public", "RightOverlap", "(", "QueryNode", "target", ")", "{", "super", "(", "target", ")", ";", "}", "@", "Override", "public", "String", "toString", "(", ")", "{", "return", "\"\"", "+", "target", ".", "getId", "(", ")", ";", "}", "}", "</s>" ]
8,728
[ "<s>", "package", "annis", ".", "sqlgen", ".", "model", ";", "import", "annis", ".", "model", ".", "QueryNode", ";", "public", "class", "LeftOverlap", "extends", "Join", "{", "public", "LeftOverlap", "(", "QueryNode", "target", ")", "{", "super", "(", "target", ")", ";", "}", "@", "Override", "public", "String", "toString", "(", ")", "{", "return", "\"\"", "+", "target", ".", "getId", "(", ")", ";", "}", "}", "</s>" ]
8,729
[ "<s>", "package", "annis", ".", "sqlgen", ".", "model", ";", "import", "annis", ".", "model", ".", "QueryNode", ";", "@", "SuppressWarnings", "(", "\"serial\"", ")", "public", "class", "Sibling", "extends", "Dominance", "{", "public", "Sibling", "(", "QueryNode", "target", ")", "{", "super", "(", "target", ")", ";", "}", "public", "Sibling", "(", "QueryNode", "target", ",", "String", "name", ")", "{", "super", "(", "target", ",", "name", ")", ";", "}", "@", "Override", "public", "String", "toString", "(", ")", "{", "return", "\"\"", "+", "target", ".", "getId", "(", ")", "+", "\"", "(\"", "+", "name", "+", "\")\"", ";", "}", "}", "</s>" ]
8,730
[ "<s>", "package", "annis", ".", "sqlgen", ".", "model", ";", "import", "annis", ".", "model", ".", "QueryNode", ";", "public", "class", "PointingRelation", "extends", "RankTableJoin", "{", "public", "PointingRelation", "(", "QueryNode", "target", ",", "String", "name", ")", "{", "this", "(", "target", ",", "name", ",", "0", ",", "0", ")", ";", "}", "public", "PointingRelation", "(", "QueryNode", "target", ",", "String", "name", ",", "int", "distance", ")", "{", "this", "(", "target", ",", "name", ",", "distance", ",", "distance", ")", ";", "}", "public", "PointingRelation", "(", "QueryNode", "target", ",", "String", "name", ",", "int", "minDistance", ",", "int", "maxDistance", ")", "{", "super", "(", "target", ",", "name", ",", "minDistance", ",", "maxDistance", ")", ";", "}", "@", "Override", "public", "String", "toString", "(", ")", "{", "return", "\"\"", "+", "target", ".", "getId", "(", ")", "+", "\"", "(\"", "+", "name", "+", "\",", "\"", "+", "minDistance", "+", "\",", "\"", "+", "maxDistance", "+", "\")\"", ";", "}", "}", "</s>" ]
8,731
[ "<s>", "package", "annis", ".", "sqlgen", ".", "model", ";", "import", "annis", ".", "model", ".", "QueryNode", ";", "@", "SuppressWarnings", "(", "\"serial\"", ")", "public", "class", "RightDominance", "extends", "Dominance", "{", "public", "RightDominance", "(", "QueryNode", "target", ")", "{", "super", "(", "target", ")", ";", "}", "public", "RightDominance", "(", "QueryNode", "target", ",", "String", "name", ")", "{", "super", "(", "target", ",", "name", ",", "1", ")", ";", "}", "@", "Override", "public", "String", "toString", "(", ")", "{", "return", "\"\"", "+", "target", ".", "getId", "(", ")", "+", "\"", "(\"", "+", "name", "+", "\")\"", ";", "}", "}", "</s>" ]
8,732
[ "<s>", "package", "annis", ".", "sqlgen", ".", "model", ";", "import", "annis", ".", "model", ".", "QueryNode", ";", "public", "class", "Identical", "extends", "Join", "{", "public", "Identical", "(", "QueryNode", "target", ")", "{", "super", "(", "target", ")", ";", "}", "@", "Override", "public", "String", "toString", "(", ")", "{", "return", "\"\"", "+", "target", ".", "getId", "(", ")", ";", "}", "}", "</s>" ]
8,733
[ "<s>", "package", "annis", ".", "sqlgen", ".", "model", ";", "import", "annis", ".", "model", ".", "QueryNode", ";", "public", "class", "Dominance", "extends", "RankTableJoin", "{", "public", "Dominance", "(", "QueryNode", "target", ")", "{", "this", "(", "target", ",", "null", ")", ";", "}", "public", "Dominance", "(", "QueryNode", "target", ",", "String", "name", ")", "{", "this", "(", "target", ",", "name", ",", "0", ",", "0", ")", ";", "}", "public", "Dominance", "(", "QueryNode", "target", ",", "int", "distance", ")", "{", "this", "(", "target", ",", "null", ",", "distance", ")", ";", "}", "public", "Dominance", "(", "QueryNode", "target", ",", "String", "name", ",", "int", "distance", ")", "{", "this", "(", "target", ",", "name", ",", "distance", ",", "distance", ")", ";", "}", "public", "Dominance", "(", "QueryNode", "target", ",", "int", "minDistance", ",", "int", "maxDistance", ")", "{", "this", "(", "target", ",", "null", ",", "minDistance", ",", "maxDistance", ")", ";", "}", "public", "Dominance", "(", "QueryNode", "target", ",", "String", "name", ",", "int", "minDistance", ",", "int", "maxDistance", ")", "{", "super", "(", "target", ",", "name", ",", "minDistance", ",", "maxDistance", ")", ";", "}", "@", "Override", "public", "String", "toString", "(", ")", "{", "return", "\"\"", "+", "target", ".", "getId", "(", ")", "+", "\"", "(\"", "+", "name", "+", "\",", "\"", "+", "minDistance", "+", "\",", "\"", "+", "maxDistance", "+", "\")\"", ";", "}", "}", "</s>" ]
8,734
[ "<s>", "package", "annis", ".", "sqlgen", ".", "model", ";", "import", "annis", ".", "model", ".", "QueryNode", ";", "public", "class", "SameSpan", "extends", "Join", "{", "public", "SameSpan", "(", "QueryNode", "target", ")", "{", "super", "(", "target", ")", ";", "}", "@", "Override", "public", "String", "toString", "(", ")", "{", "return", "\"\"", "+", "target", ".", "getId", "(", ")", ";", "}", "}", "</s>" ]
8,735
[ "<s>", "package", "annis", ".", "sqlgen", ".", "model", ";", "import", "annis", ".", "model", ".", "QueryNode", ";", "public", "class", "LeftAlignment", "extends", "Join", "{", "public", "LeftAlignment", "(", "QueryNode", "target", ")", "{", "super", "(", "target", ")", ";", "}", "@", "Override", "public", "String", "toString", "(", ")", "{", "return", "\"\"", "+", "target", ".", "getId", "(", ")", ";", "}", "}", "</s>" ]
8,736
[ "<s>", "package", "annis", ".", "sqlgen", ".", "model", ";", "import", "annis", ".", "model", ".", "QueryNode", ";", "public", "class", "RightAlignment", "extends", "Join", "{", "public", "RightAlignment", "(", "QueryNode", "target", ")", "{", "super", "(", "target", ")", ";", "}", "@", "Override", "public", "String", "toString", "(", ")", "{", "return", "\"\"", "+", "target", ".", "getId", "(", ")", ";", "}", "}", "</s>" ]
8,737
[ "<s>", "package", "annis", ".", "sqlgen", ".", "model", ";", "import", "annis", ".", "model", ".", "QueryNode", ";", "public", "class", "Precedence", "extends", "RangedJoin", "{", "private", "String", "segmentationName", ";", "public", "Precedence", "(", "QueryNode", "target", ")", "{", "this", "(", "target", ",", "0", ",", "0", ")", ";", "}", "public", "Precedence", "(", "QueryNode", "target", ",", "String", "segmentationName", ")", "{", "this", "(", "target", ",", "0", ",", "0", ",", "segmentationName", ")", ";", "}", "public", "Precedence", "(", "QueryNode", "target", ",", "int", "distance", ")", "{", "this", "(", "target", ",", "distance", ",", "distance", ")", ";", "}", "public", "Precedence", "(", "QueryNode", "target", ",", "int", "distance", ",", "String", "segmentationName", ")", "{", "this", "(", "target", ",", "distance", ",", "distance", ",", "segmentationName", ")", ";", "}", "public", "Precedence", "(", "QueryNode", "target", ",", "int", "minDistance", ",", "int", "maxDistance", ")", "{", "this", "(", "target", ",", "minDistance", ",", "maxDistance", ",", "null", ")", ";", "}", "public", "Precedence", "(", "QueryNode", "target", ",", "int", "minDistance", ",", "int", "maxDistance", ",", "String", "segmentationName", ")", "{", "super", "(", "target", ",", "minDistance", ",", "maxDistance", ")", ";", "this", ".", "segmentationName", "=", "segmentationName", ";", "}", "public", "String", "getSegmentationName", "(", ")", "{", "return", "segmentationName", ";", "}", "public", "void", "setSegmentationName", "(", "String", "segmentationName", ")", "{", "this", ".", "segmentationName", "=", "segmentationName", ";", "}", "@", "Override", "public", "String", "toString", "(", ")", "{", "return", "\"\"", "+", "target", ".", "getId", "(", ")", "+", "\"", "(\"", "+", "segmentationName", "+", "\"", "\"", "+", "minDistance", "+", "\",", "\"", "+", "maxDistance", "+", "\")\"", ";", "}", "@", "Override", "public", "int", "hashCode", "(", ")", "{", "int", "hash", "=", "7", ";", "return", "hash", ";", "}", "@", "Override", "public", "boolean", "equals", "(", "Object", "obj", ")", "{", "if", "(", "obj", "==", "null", ")", "{", "return", "false", ";", "}", "if", "(", "getClass", "(", ")", "!=", "obj", ".", "getClass", "(", ")", ")", "{", "return", "false", ";", "}", "final", "Precedence", "other", "=", "(", "Precedence", ")", "obj", ";", "if", "(", "(", "this", ".", "segmentationName", "==", "null", ")", "?", "(", "other", ".", "segmentationName", "!=", "null", ")", ":", "!", "this", ".", "segmentationName", ".", "equals", "(", "other", ".", "segmentationName", ")", ")", "{", "return", "false", ";", "}", "return", "super", ".", "equals", "(", "obj", ")", ";", "}", "}", "</s>" ]
8,738
[ "<s>", "package", "annis", ".", "sqlgen", ".", "model", ";", "import", "annis", ".", "model", ".", "QueryNode", ";", "@", "SuppressWarnings", "(", "\"serial\"", ")", "public", "class", "LeftDominance", "extends", "Dominance", "{", "public", "LeftDominance", "(", "QueryNode", "target", ")", "{", "super", "(", "target", ")", ";", "}", "public", "LeftDominance", "(", "QueryNode", "target", ",", "String", "name", ")", "{", "super", "(", "target", ",", "name", ",", "1", ")", ";", "}", "@", "Override", "public", "String", "toString", "(", ")", "{", "return", "\"\"", "+", "target", ".", "getId", "(", ")", "+", "\"", "(\"", "+", "name", "+", "\")\"", ";", "}", "}", "</s>" ]
8,739
[ "<s>", "package", "annis", ".", "sqlgen", ".", "model", ";", "import", "annis", ".", "model", ".", "QueryNode", ";", "public", "class", "Inclusion", "extends", "Join", "{", "public", "Inclusion", "(", "QueryNode", "target", ")", "{", "super", "(", "target", ")", ";", "}", "@", "Override", "public", "String", "toString", "(", ")", "{", "return", "\"\"", "+", "target", ".", "getId", "(", ")", ";", "}", "}", "</s>" ]
8,740
[ "<s>", "package", "annis", ".", "sqlgen", ".", "model", ";", "import", "annis", ".", "model", ".", "QueryNode", ";", "public", "abstract", "class", "RankTableJoin", "extends", "RangedJoin", "{", "protected", "String", "name", ";", "public", "RankTableJoin", "(", "QueryNode", "target", ",", "String", "name", ",", "int", "minDistance", ",", "int", "maxDistance", ")", "{", "super", "(", "target", ",", "minDistance", ",", "maxDistance", ")", ";", "this", ".", "name", "=", "name", ";", "}", "public", "String", "getName", "(", ")", "{", "return", "name", ";", "}", "public", "void", "setName", "(", "String", "name", ")", "{", "this", ".", "name", "=", "name", ";", "}", "}", "</s>" ]
8,741
[ "<s>", "package", "annis", ".", "sqlgen", ".", "model", ";", "import", "annis", ".", "model", ".", "QueryNode", ";", "import", "annis", ".", "model", ".", "DataObject", ";", "@", "SuppressWarnings", "(", "\"serial\"", ")", "public", "abstract", "class", "Join", "extends", "DataObject", "{", "protected", "QueryNode", "target", ";", "public", "Join", "(", "QueryNode", "target", ")", "{", "this", ".", "target", "=", "target", ";", "}", "public", "QueryNode", "getTarget", "(", ")", "{", "return", "target", ";", "}", "public", "void", "setTarget", "(", "QueryNode", "target", ")", "{", "this", ".", "target", "=", "target", ";", "}", "}", "</s>" ]
8,742
[ "<s>", "package", "annis", ".", "sqlgen", ".", "model", ";", "import", "annis", ".", "model", ".", "QueryNode", ";", "public", "abstract", "class", "RangedJoin", "extends", "Join", "{", "protected", "int", "minDistance", ";", "protected", "int", "maxDistance", ";", "public", "RangedJoin", "(", "QueryNode", "target", ",", "int", "minDistance", ",", "int", "maxDistance", ")", "{", "super", "(", "target", ")", ";", "this", ".", "minDistance", "=", "minDistance", ";", "this", ".", "maxDistance", "=", "maxDistance", ";", "}", "public", "int", "getMinDistance", "(", ")", "{", "return", "minDistance", ";", "}", "public", "int", "getMaxDistance", "(", ")", "{", "return", "maxDistance", ";", "}", "}", "</s>" ]
8,743
[ "<s>", "package", "annis", ".", "sqlgen", ".", "model", ";", "import", "annis", ".", "model", ".", "QueryNode", ";", "public", "class", "CommonAncestor", "extends", "Dominance", "{", "public", "CommonAncestor", "(", "QueryNode", "target", ")", "{", "super", "(", "target", ")", ";", "}", "public", "CommonAncestor", "(", "QueryNode", "target", ",", "String", "name", ")", "{", "super", "(", "target", ",", "name", ")", ";", "}", "@", "Override", "public", "String", "toString", "(", ")", "{", "return", "\"\"", "+", "target", ".", "getId", "(", ")", "+", "\"", "(\"", "+", "name", "+", "\")\"", ";", "}", "}", "</s>" ]
8,744
[ "<s>", "package", "annis", ".", "sqlgen", ".", "model", ";", "import", "annis", ".", "model", ".", "QueryNode", ";", "@", "Deprecated", "public", "class", "DirectDominance", "extends", "Join", "{", "public", "DirectDominance", "(", "QueryNode", "target", ")", "{", "super", "(", "target", ")", ";", "}", "@", "Override", "public", "String", "toString", "(", ")", "{", "return", "\"\"", "+", "target", ".", "getId", "(", ")", ";", "}", "}", "</s>" ]
8,745
[ "<s>", "package", "annis", ".", "sqlgen", ".", "model", ";", "import", "annis", ".", "model", ".", "QueryNode", ";", "public", "class", "Overlap", "extends", "Join", "{", "public", "Overlap", "(", "QueryNode", "target", ")", "{", "super", "(", "target", ")", ";", "}", "@", "Override", "public", "String", "toString", "(", ")", "{", "return", "\"\"", "+", "target", ".", "getId", "(", ")", ";", "}", "}", "</s>" ]
8,746
[ "<s>", "package", "annis", ".", "utils", ";", "import", "annis", ".", "service", ".", "objects", ".", "AnnisResultImpl", ";", "import", "annis", ".", "model", ".", "AnnisNode", ";", "import", "annis", ".", "model", ".", "Annotation", ";", "import", "annis", ".", "model", ".", "AnnotationGraph", ";", "import", "annis", ".", "model", ".", "Edge", ";", "import", "annis", ".", "model", ".", "Edge", ".", "EdgeType", ";", "import", "annis", ".", "service", ".", "ifaces", ".", "AnnisResultSet", ";", "import", "de", ".", "hu_berlin", ".", "german", ".", "korpling", ".", "saltnpepper", ".", "salt", ".", "graph", ".", "Node", ";", "import", "de", ".", "hu_berlin", ".", "german", ".", "korpling", ".", "saltnpepper", ".", "salt", ".", "saltCommon", ".", "SaltProject", ";", "import", "de", ".", "hu_berlin", ".", "german", ".", "korpling", ".", "saltnpepper", ".", "salt", ".", "saltCommon", ".", "sCorpusStructure", ".", "SCorpusGraph", ";", "import", "de", ".", "hu_berlin", ".", "german", ".", "korpling", ".", "saltnpepper", ".", "salt", ".", "saltCommon", ".", "sCorpusStructure", ".", "SDocument", ";", "import", "de", ".", "hu_berlin", ".", "german", ".", "korpling", ".", "saltnpepper", ".", "salt", ".", "saltCommon", ".", "sDocumentStructure", ".", "SDataSourceSequence", ";", "import", "de", ".", "hu_berlin", ".", "german", ".", "korpling", ".", "saltnpepper", ".", "salt", ".", "saltCommon", ".", "sDocumentStructure", ".", "SDocumentGraph", ";", "import", "de", ".", "hu_berlin", ".", "german", ".", "korpling", ".", "saltnpepper", ".", "salt", ".", "saltCommon", ".", "sDocumentStructure", ".", "SDominanceRelation", ";", "import", "de", ".", "hu_berlin", ".", "german", ".", "korpling", ".", "saltnpepper", ".", "salt", ".", "saltCommon", ".", "sDocumentStructure", ".", "SPointingRelation", ";", "import", "de", ".", "hu_berlin", ".", "german", ".", "korpling", ".", "saltnpepper", ".", "salt", ".", "saltCommon", ".", "sDocumentStructure", ".", "SSpanningRelation", ";", "import", "de", ".", "hu_berlin", ".", "german", ".", "korpling", ".", "saltnpepper", ".", "salt", ".", "saltCommon", ".", "sDocumentStructure", ".", "STYPE_NAME", ";", "import", "de", ".", "hu_berlin", ".", "german", ".", "korpling", ".", "saltnpepper", ".", "salt", ".", "saltCommon", ".", "sDocumentStructure", ".", "SToken", ";", "import", "de", ".", "hu_berlin", ".", "german", ".", "korpling", ".", "saltnpepper", ".", "salt", ".", "saltCore", ".", "SAnnotation", ";", "import", "de", ".", "hu_berlin", ".", "german", ".", "korpling", ".", "saltnpepper", ".", "salt", ".", "saltCore", ".", "SFeature", ";", "import", "de", ".", "hu_berlin", ".", "german", ".", "korpling", ".", "saltnpepper", ".", "salt", ".", "saltCore", ".", "SNode", ";", "import", "de", ".", "hu_berlin", ".", "german", ".", "korpling", ".", "saltnpepper", ".", "salt", ".", "saltCore", ".", "SRelation", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "util", ".", "Arrays", ";", "import", "java", ".", "util", ".", "HashMap", ";", "import", "java", ".", "util", ".", "HashSet", ";", "import", "java", ".", "util", ".", "List", ";", "import", "java", ".", "util", ".", "Map", ";", "import", "java", ".", "util", ".", "Set", ";", "import", "static", "annis", ".", "model", ".", "AnnisConstants", ".", "*", ";", "import", "annis", ".", "service", ".", "objects", ".", "AnnisResultSetImpl", ";", "import", "org", ".", "apache", ".", "commons", ".", "lang3", ".", "StringUtils", ";", "import", "org", ".", "eclipse", ".", "emf", ".", "common", ".", "util", ".", "BasicEList", ";", "import", "org", ".", "eclipse", ".", "emf", ".", "common", ".", "util", ".", "EList", ";", "public", "class", "LegacyGraphConverter", "{", "public", "static", "AnnisResultSet", "convertToResultSet", "(", "SaltProject", "p", ")", "{", "List", "<", "AnnotationGraph", ">", "annotationGraphs", "=", "convertToAOM", "(", "p", ")", ";", "AnnisResultSetImpl", "annisResultSet", "=", "new", "AnnisResultSetImpl", "(", ")", ";", "for", "(", "AnnotationGraph", "annotationGraph", ":", "annotationGraphs", ")", "{", "annisResultSet", ".", "add", "(", "new", "AnnisResultImpl", "(", "annotationGraph", ")", ")", ";", "}", "return", "annisResultSet", ";", "}", "public", "static", "List", "<", "AnnotationGraph", ">", "convertToAOM", "(", "SaltProject", "p", ")", "{", "List", "<", "AnnotationGraph", ">", "result", "=", "new", "ArrayList", "<", "AnnotationGraph", ">", "(", ")", ";", "for", "(", "SCorpusGraph", "corpusGraph", ":", "p", ".", "getSCorpusGraphs", "(", ")", ")", "{", "for", "(", "SDocument", "doc", ":", "corpusGraph", ".", "getSDocuments", "(", ")", ")", "{", "result", ".", "add", "(", "convertToAnnotationGraph", "(", "doc", ")", ")", ";", "}", "}", "return", "result", ";", "}", "public", "static", "AnnotationGraph", "convertToAnnotationGraph", "(", "SDocument", "document", ")", "{", "AnnotationGraph", "result", "=", "null", ";", "List", "<", "String", ">", "matchedIDs", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "SFeature", "featMatchedIDs", "=", "document", ".", "getSFeature", "(", "ANNIS_NS", ",", "FEAT_MATCHEDIDS", ")", ";", "if", "(", "featMatchedIDs", "!=", "null", "&&", "featMatchedIDs", ".", "getSValueSTEXT", "(", ")", "!=", "null", ")", "{", "matchedIDs", "=", "Arrays", ".", "asList", "(", "StringUtils", ".", "split", "(", "featMatchedIDs", ".", "getSValueSTEXT", "(", ")", ",", "','", ")", ")", ";", "}", "SDocumentGraph", "docGraph", "=", "document", ".", "getSDocumentGraph", "(", ")", ";", "result", "=", "convertToAnnotationGraph", "(", "docGraph", ",", "matchedIDs", ")", ";", "return", "result", ";", "}", "public", "static", "AnnotationGraph", "convertToAnnotationGraph", "(", "SDocumentGraph", "docGraph", ",", "List", "<", "String", ">", "matchedIDs", ")", "{", "Set", "<", "String", ">", "matchSet", "=", "new", "HashSet", "<", "String", ">", "(", "matchedIDs", ")", ";", "AnnotationGraph", "annoGraph", "=", "new", "AnnotationGraph", "(", ")", ";", "annoGraph", ".", "setDocumentName", "(", "docGraph", ".", "getSDocument", "(", ")", ".", "getSName", "(", ")", ")", ";", "Map", "<", "Node", ",", "AnnisNode", ">", "allNodes", "=", "new", "HashMap", "<", "Node", ",", "AnnisNode", ">", "(", ")", ";", "for", "(", "SNode", "sNode", ":", "docGraph", ".", "getSNodes", "(", ")", ")", "{", "SFeature", "featInternalID", "=", "sNode", ".", "getSFeature", "(", "ANNIS_NS", ",", "FEAT_INTERNALID", ")", ";", "if", "(", "featInternalID", "!=", "null", ")", "{", "long", "internalID", "=", "featInternalID", ".", "getSValueSNUMERIC", "(", ")", ";", "AnnisNode", "aNode", "=", "new", "AnnisNode", "(", "internalID", ")", ";", "for", "(", "SAnnotation", "sAnno", ":", "sNode", ".", "getSAnnotations", "(", ")", ")", "{", "aNode", ".", "addNodeAnnotation", "(", "new", "Annotation", "(", "sAnno", ".", "getSNS", "(", ")", ",", "sAnno", ".", "getSName", "(", ")", ",", "sAnno", ".", "getSValueSTEXT", "(", ")", ")", ")", ";", "}", "aNode", ".", "setName", "(", "sNode", ".", "getSName", "(", ")", ")", ";", "aNode", ".", "setNamespace", "(", "sNode", ".", "getSLayers", "(", ")", ".", "get", "(", "0", ")", ".", "getSName", "(", ")", ")", ";", "if", "(", "sNode", "instanceof", "SToken", ")", "{", "BasicEList", "<", "STYPE_NAME", ">", "textualRelation", "=", "new", "BasicEList", "<", "STYPE_NAME", ">", "(", ")", ";", "textualRelation", ".", "add", "(", "STYPE_NAME", ".", "STEXT_OVERLAPPING_RELATION", ")", ";", "EList", "<", "SDataSourceSequence", ">", "seqList", "=", "docGraph", ".", "getOverlappedDSSequences", "(", "sNode", ",", "textualRelation", ")", ";", "if", "(", "seqList", "!=", "null", ")", "{", "SDataSourceSequence", "seq", "=", "seqList", ".", "get", "(", "0", ")", ";", "aNode", ".", "setSpannedText", "(", "(", "(", "String", ")", "seq", ".", "getSSequentialDS", "(", ")", ".", "getSData", "(", ")", ")", ".", "substring", "(", "seq", ".", "getSStart", "(", ")", ",", "seq", ".", "getSEnd", "(", ")", ")", ")", ";", "aNode", ".", "setToken", "(", "true", ")", ";", "aNode", ".", "setTokenIndex", "(", "sNode", ".", "getSFeature", "(", "ANNIS_NS", ",", "FEAT_TOKENINDEX", ")", ".", "getSValueSNUMERIC", "(", ")", ")", ";", "}", "}", "else", "{", "aNode", ".", "setToken", "(", "false", ")", ";", "aNode", ".", "setTokenIndex", "(", "null", ")", ";", "}", "aNode", ".", "setCorpus", "(", "sNode", ".", "getSFeature", "(", "ANNIS_NS", ",", "FEAT_CORPUSREF", ")", ".", "getSValueSNUMERIC", "(", ")", ")", ";", "aNode", ".", "setTextId", "(", "sNode", ".", "getSFeature", "(", "ANNIS_NS", ",", "FEAT_TEXTREF", ")", ".", "getSValueSNUMERIC", "(", ")", ")", ";", "aNode", ".", "setLeft", "(", "sNode", ".", "getSFeature", "(", "ANNIS_NS", ",", "FEAT_LEFT", ")", ".", "getSValueSNUMERIC", "(", ")", ")", ";", "aNode", ".", "setLeftToken", "(", "sNode", ".", "getSFeature", "(", "ANNIS_NS", ",", "FEAT_LEFTTOKEN", ")", ".", "getSValueSNUMERIC", "(", ")", ")", ";", "aNode", ".", "setRight", "(", "sNode", ".", "getSFeature", "(", "ANNIS_NS", ",", "FEAT_RIGHT", ")", ".", "getSValueSNUMERIC", "(", ")", ")", ";", "aNode", ".", "setRightToken", "(", "sNode", ".", "getSFeature", "(", "ANNIS_NS", ",", "FEAT_RIGHTTOKEN", ")", ".", "getSValueSNUMERIC", "(", ")", ")", ";", "if", "(", "matchSet", ".", "contains", "(", "aNode", ".", "getName", "(", ")", ")", ")", "{", "aNode", ".", "setMatchedNodeInQuery", "(", "(", "long", ")", "matchedIDs", ".", "indexOf", "(", "aNode", ".", "getName", "(", ")", ")", "+", "1", ")", ";", "annoGraph", ".", "getMatchedNodeIds", "(", ")", ".", "add", "(", "aNode", ".", "getId", "(", ")", ")", ";", "}", "else", "{", "aNode", ".", "setMatchedNodeInQuery", "(", "null", ")", ";", "}", "annoGraph", ".", "addNode", "(", "aNode", ")", ";", "allNodes", ".", "put", "(", "sNode", ",", "aNode", ")", ";", "}", "}", "for", "(", "SRelation", "rel", ":", "docGraph", ".", "getSRelations", "(", ")", ")", "{", "SFeature", "featPre", "=", "rel", ".", "getSFeature", "(", "ANNIS_NS", ",", "FEAT_INTERNALID", ")", ";", "SFeature", "featComponentID", "=", "rel", ".", "getSFeature", "(", "ANNIS_NS", ",", "FEAT_COMPONENTID", ")", ";", "if", "(", "featPre", "!=", "null", ")", "{", "Edge", "aEdge", "=", "new", "Edge", "(", ")", ";", "aEdge", ".", "setSource", "(", "allNodes", ".", "get", "(", "rel", ".", "getSource", "(", ")", ")", ")", ";", "aEdge", ".", "setDestination", "(", "allNodes", ".", "get", "(", "rel", ".", "getTarget", "(", ")", ")", ")", ";", "aEdge", ".", "setEdgeType", "(", "EdgeType", ".", "UNKNOWN", ")", ";", "aEdge", ".", "setPre", "(", "featPre", ".", "getSValueSNUMERIC", "(", ")", ")", ";", "aEdge", ".", "setComponentID", "(", "featComponentID", ".", "getSValueSNUMERIC", "(", ")", ")", ";", "aEdge", ".", "setNamespace", "(", "rel", ".", "getSLayers", "(", ")", ".", "get", "(", "0", ")", ".", "getSName", "(", ")", ")", ";", "aEdge", ".", "setName", "(", "(", "rel", ".", "getSTypes", "(", ")", "!=", "null", "&&", "rel", ".", "getSTypes", "(", ")", ".", "size", "(", ")", ">", "0", ")", "?", "rel", ".", "getSTypes", "(", ")", ".", "get", "(", "0", ")", ":", "null", ")", ";", "if", "(", "rel", "instanceof", "SDominanceRelation", ")", "{", "aEdge", ".", "setEdgeType", "(", "EdgeType", ".", "DOMINANCE", ")", ";", "}", "else", "if", "(", "rel", "instanceof", "SPointingRelation", ")", "{", "aEdge", ".", "setEdgeType", "(", "EdgeType", ".", "POINTING_RELATION", ")", ";", "}", "else", "if", "(", "rel", "instanceof", "SSpanningRelation", ")", "{", "aEdge", ".", "setEdgeType", "(", "EdgeType", ".", "COVERAGE", ")", ";", "}", "for", "(", "SAnnotation", "sAnno", ":", "rel", ".", "getSAnnotations", "(", ")", ")", "{", "aEdge", ".", "addAnnotation", "(", "new", "Annotation", "(", "sAnno", ".", "getSNS", "(", ")", ",", "sAnno", ".", "getSName", "(", ")", ",", "sAnno", ".", "getSValueSTEXT", "(", ")", ")", ")", ";", "}", "annoGraph", ".", "addEdge", "(", "aEdge", ")", ";", "aEdge", ".", "getDestination", "(", ")", ".", "addIncomingEdge", "(", "aEdge", ")", ";", "if", "(", "aEdge", ".", "getSource", "(", ")", "!=", "null", ")", "{", "aEdge", ".", "getSource", "(", ")", ".", "addOutgoingEdge", "(", "aEdge", ")", ";", "}", "}", "}", "return", "annoGraph", ";", "}", "}", "</s>" ]
8,747
[ "<s>", "package", "annis", ".", "visualizers", ";", "public", "interface", "LoadableVisualizer", "{", "public", "void", "addOnLoadCallBack", "(", "Callback", "callback", ")", ";", "public", "void", "clearCallbacks", "(", ")", ";", "public", "boolean", "isLoaded", "(", ")", ";", "public", "interface", "Callback", "{", "public", "void", "visualizerLoaded", "(", "LoadableVisualizer", "origin", ")", ";", "}", "}", "</s>" ]
8,748
[ "<s>", "package", "annis", ".", "exceptions", ";", "public", "class", "AnnisException", "extends", "RuntimeException", "{", "public", "AnnisException", "(", ")", "{", "super", "(", ")", ";", "}", "public", "AnnisException", "(", "String", "message", ")", "{", "super", "(", "message", ")", ";", "}", "public", "AnnisException", "(", "Throwable", "cause", ")", "{", "super", "(", "cause", ")", ";", "}", "public", "AnnisException", "(", "String", "message", ",", "Throwable", "cause", ")", "{", "super", "(", "message", ",", "cause", ")", ";", "}", "}", "</s>" ]
8,749
[ "<s>", "package", "annis", ".", "exceptions", ";", "public", "class", "AnnisMappingException", "extends", "AnnisException", "{", "public", "AnnisMappingException", "(", ")", "{", "super", "(", ")", ";", "}", "public", "AnnisMappingException", "(", "String", "message", ",", "Throwable", "cause", ")", "{", "super", "(", "message", ",", "cause", ")", ";", "}", "public", "AnnisMappingException", "(", "String", "message", ")", "{", "super", "(", "message", ")", ";", "}", "public", "AnnisMappingException", "(", "Throwable", "cause", ")", "{", "super", "(", "cause", ")", ";", "}", "}", "</s>" ]
8,750
[ "<s>", "package", "annis", ".", "exceptions", ";", "public", "class", "AnnisCorpusAccessException", "extends", "AnnisException", "{", "public", "AnnisCorpusAccessException", "(", ")", "{", "super", "(", ")", ";", "}", "public", "AnnisCorpusAccessException", "(", "String", "message", ",", "Throwable", "cause", ")", "{", "super", "(", "message", ",", "cause", ")", ";", "}", "public", "AnnisCorpusAccessException", "(", "String", "message", ")", "{", "super", "(", "message", ")", ";", "}", "public", "AnnisCorpusAccessException", "(", "Throwable", "cause", ")", "{", "super", "(", "cause", ")", ";", "}", "}", "</s>" ]
8,751
[ "<s>", "package", "annis", ".", "exceptions", ";", "public", "class", "AnnisQLSyntaxException", "extends", "AnnisException", "{", "public", "AnnisQLSyntaxException", "(", ")", "{", "super", "(", ")", ";", "}", "public", "AnnisQLSyntaxException", "(", "String", "message", ")", "{", "super", "(", "message", ")", ";", "}", "}", "</s>" ]
8,752
[ "<s>", "package", "annis", ".", "exceptions", ";", "public", "class", "AnnisQLSemanticsException", "extends", "AnnisException", "{", "public", "AnnisQLSemanticsException", "(", ")", "{", "super", "(", ")", ";", "}", "public", "AnnisQLSemanticsException", "(", "String", "message", ")", "{", "super", "(", "message", ")", ";", "}", "}", "</s>" ]
8,753
[ "<s>", "package", "annis", ";", "import", "de", ".", "hu_berlin", ".", "german", ".", "korpling", ".", "saltnpepper", ".", "salt", ".", "graph", ".", "Edge", ";", "import", "de", ".", "hu_berlin", ".", "german", ".", "korpling", ".", "saltnpepper", ".", "salt", ".", "graph", ".", "GRAPH_TRAVERSE_TYPE", ";", "import", "de", ".", "hu_berlin", ".", "german", ".", "korpling", ".", "saltnpepper", ".", "salt", ".", "saltCommon", ".", "SaltProject", ";", "import", "de", ".", "hu_berlin", ".", "german", ".", "korpling", ".", "saltnpepper", ".", "salt", ".", "saltCommon", ".", "sCorpusStructure", ".", "SCorpus", ";", "import", "de", ".", "hu_berlin", ".", "german", ".", "korpling", ".", "saltnpepper", ".", "salt", ".", "saltCommon", ".", "sCorpusStructure", ".", "SCorpusGraph", ";", "import", "de", ".", "hu_berlin", ".", "german", ".", "korpling", ".", "saltnpepper", ".", "salt", ".", "saltCommon", ".", "sCorpusStructure", ".", "SDocument", ";", "import", "de", ".", "hu_berlin", ".", "german", ".", "korpling", ".", "saltnpepper", ".", "salt", ".", "saltCommon", ".", "sDocumentStructure", ".", "SDocumentGraph", ";", "import", "de", ".", "hu_berlin", ".", "german", ".", "korpling", ".", "saltnpepper", ".", "salt", ".", "saltCommon", ".", "sDocumentStructure", ".", "SOrderRelation", ";", "import", "de", ".", "hu_berlin", ".", "german", ".", "korpling", ".", "saltnpepper", ".", "salt", ".", "saltCommon", ".", "sDocumentStructure", ".", "STextualDS", ";", "import", "de", ".", "hu_berlin", ".", "german", ".", "korpling", ".", "saltnpepper", ".", "salt", ".", "saltCommon", ".", "sDocumentStructure", ".", "STextualRelation", ";", "import", "de", ".", "hu_berlin", ".", "german", ".", "korpling", ".", "saltnpepper", ".", "salt", ".", "saltCommon", ".", "sDocumentStructure", ".", "SToken", ";", "import", "de", ".", "hu_berlin", ".", "german", ".", "korpling", ".", "saltnpepper", ".", "salt", ".", "saltCore", ".", "SAnnotation", ";", "import", "de", ".", "hu_berlin", ".", "german", ".", "korpling", ".", "saltnpepper", ".", "salt", ".", "saltCore", ".", "SGraphTraverseHandler", ";", "import", "de", ".", "hu_berlin", ".", "german", ".", "korpling", ".", "saltnpepper", ".", "salt", ".", "saltCore", ".", "SNode", ";", "import", "de", ".", "hu_berlin", ".", "german", ".", "korpling", ".", "saltnpepper", ".", "salt", ".", "saltCore", ".", "SRelation", ";", "import", "java", ".", "io", ".", "UnsupportedEncodingException", ";", "import", "java", ".", "net", ".", "URI", ";", "import", "java", ".", "net", ".", "URLDecoder", ";", "import", "java", ".", "util", ".", "*", ";", "import", "org", ".", "apache", ".", "commons", ".", "lang3", ".", "StringUtils", ";", "import", "org", ".", "eclipse", ".", "emf", ".", "common", ".", "util", ".", "BasicEList", ";", "import", "org", ".", "eclipse", ".", "emf", ".", "common", ".", "util", ".", "EList", ";", "import", "org", ".", "slf4j", ".", "Logger", ";", "import", "org", ".", "slf4j", ".", "LoggerFactory", ";", "public", "class", "CommonHelper", "{", "private", "final", "static", "Logger", "log", "=", "LoggerFactory", ".", "getLogger", "(", "CommonHelper", ".", "class", ")", ";", "public", "static", "boolean", "containsRTLText", "(", "String", "str", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "str", ".", "length", "(", ")", ";", "i", "++", ")", "{", "char", "cc", "=", "str", ".", "charAt", "(", "i", ")", ";", "if", "(", "cc", ">=", "1425", "&&", "cc", "<=", "1785", ")", "{", "return", "true", ";", "}", "else", "if", "(", "cc", ">=", "64286", "&&", "cc", "<=", "65019", ")", "{", "return", "true", ";", "}", "else", "if", "(", "cc", ">=", "65136", "&&", "cc", "<=", "65276", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}", "public", "static", "List", "<", "SNode", ">", "getSortedSegmentationNodes", "(", "String", "segName", ",", "SDocumentGraph", "graph", ")", "{", "List", "<", "SNode", ">", "token", "=", "new", "ArrayList", "<", "SNode", ">", "(", ")", ";", "if", "(", "segName", "==", "null", ")", "{", "token", ".", "addAll", "(", "graph", ".", "getSortedSTokenByText", "(", ")", ")", ";", "}", "else", "{", "Set", "<", "SNode", ">", "startNodes", "=", "new", "LinkedHashSet", "<", "SNode", ">", "(", ")", ";", "Map", "<", "SNode", ",", "SOrderRelation", ">", "outRelationForNode", "=", "new", "HashMap", "<", "SNode", ",", "SOrderRelation", ">", "(", ")", ";", "for", "(", "SOrderRelation", "rel", ":", "graph", ".", "getSOrderRelations", "(", ")", ")", "{", "if", "(", "rel", ".", "getSTypes", "(", ")", ".", "contains", "(", "segName", ")", ")", "{", "SNode", "node", "=", "rel", ".", "getSSource", "(", ")", ";", "outRelationForNode", ".", "put", "(", "node", ",", "rel", ")", ";", "EList", "<", "Edge", ">", "inEdgesForSource", "=", "graph", ".", "getInEdges", "(", "node", ".", "getSId", "(", ")", ")", ";", "boolean", "hasInOrderEdge", "=", "false", ";", "for", "(", "Edge", "e", ":", "inEdgesForSource", ")", "{", "if", "(", "e", "instanceof", "SOrderRelation", ")", "{", "hasInOrderEdge", "=", "true", ";", "break", ";", "}", "}", "if", "(", "!", "hasInOrderEdge", ")", "{", "startNodes", ".", "add", "(", "rel", ".", "getSSource", "(", ")", ")", ";", "}", "}", "}", "for", "(", "SNode", "s", ":", "startNodes", ")", "{", "SNode", "current", "=", "s", ";", "while", "(", "current", "!=", "null", ")", "{", "token", ".", "add", "(", "current", ")", ";", "if", "(", "outRelationForNode", ".", "containsKey", "(", "current", ")", ")", "{", "current", "=", "outRelationForNode", ".", "get", "(", "current", ")", ".", "getSTarget", "(", ")", ";", "}", "else", "{", "current", "=", "null", ";", "}", "}", "}", "}", "return", "token", ";", "}", "public", "static", "Set", "<", "String", ">", "getTokenAnnotationLevelSet", "(", "SDocumentGraph", "graph", ")", "{", "Set", "<", "String", ">", "result", "=", "new", "TreeSet", "<", "String", ">", "(", ")", ";", "if", "(", "graph", "!=", "null", ")", "{", "for", "(", "SToken", "n", ":", "graph", ".", "getSTokens", "(", ")", ")", "{", "for", "(", "SAnnotation", "anno", ":", "n", ".", "getSAnnotations", "(", ")", ")", "{", "result", ".", "add", "(", "anno", ".", "getQName", "(", ")", ")", ";", "}", "}", "}", "return", "result", ";", "}", "public", "static", "Set", "<", "String", ">", "getTokenAnnotationLevelSet", "(", "SaltProject", "p", ")", "{", "Set", "<", "String", ">", "result", "=", "new", "TreeSet", "<", "String", ">", "(", ")", ";", "for", "(", "SCorpusGraph", "corpusGraphs", ":", "p", ".", "getSCorpusGraphs", "(", ")", ")", "{", "for", "(", "SDocument", "doc", ":", "corpusGraphs", ".", "getSDocuments", "(", ")", ")", "{", "SDocumentGraph", "g", "=", "doc", ".", "getSDocumentGraph", "(", ")", ";", "result", ".", "addAll", "(", "getTokenAnnotationLevelSet", "(", "g", ")", ")", ";", "}", "}", "return", "result", ";", "}", "public", "static", "Set", "<", "String", ">", "getOrderingTypes", "(", "SaltProject", "p", ")", "{", "Set", "<", "String", ">", "result", "=", "new", "TreeSet", "<", "String", ">", "(", ")", ";", "for", "(", "SCorpusGraph", "corpusGraphs", ":", "p", ".", "getSCorpusGraphs", "(", ")", ")", "{", "for", "(", "SDocument", "doc", ":", "corpusGraphs", ".", "getSDocuments", "(", ")", ")", "{", "SDocumentGraph", "g", "=", "doc", ".", "getSDocumentGraph", "(", ")", ";", "if", "(", "g", "!=", "null", ")", "{", "EList", "<", "SOrderRelation", ">", "orderRelations", "=", "g", ".", "getSOrderRelations", "(", ")", ";", "if", "(", "orderRelations", "!=", "null", ")", "{", "for", "(", "SOrderRelation", "rel", ":", "orderRelations", ")", "{", "result", ".", "addAll", "(", "rel", ".", "getSTypes", "(", ")", ")", ";", "}", "}", "}", "}", "}", "return", "result", ";", "}", "public", "static", "String", "getSpannedText", "(", "SToken", "tok", ")", "{", "SDocumentGraph", "graph", "=", "tok", ".", "getSDocumentGraph", "(", ")", ";", "EList", "<", "Edge", ">", "edges", "=", "graph", ".", "getOutEdges", "(", "tok", ".", "getSId", "(", ")", ")", ";", "for", "(", "Edge", "e", ":", "edges", ")", "{", "if", "(", "e", "instanceof", "STextualRelation", ")", "{", "STextualRelation", "textRel", "=", "(", "STextualRelation", ")", "e", ";", "return", "textRel", ".", "getSTextualDS", "(", ")", ".", "getSText", "(", ")", ".", "substring", "(", "textRel", ".", "getSStart", "(", ")", ",", "textRel", ".", "getSEnd", "(", ")", ")", ";", "}", "}", "return", "\"\"", ";", "}", "public", "static", "List", "<", "String", ">", "getCorpusPath", "(", "SCorpusGraph", "corpusGraph", ",", "SDocument", "doc", ")", "{", "final", "List", "<", "String", ">", "result", "=", "new", "LinkedList", "<", "String", ">", "(", ")", ";", "result", ".", "add", "(", "doc", ".", "getSName", "(", ")", ")", ";", "SCorpus", "c", "=", "corpusGraph", ".", "getSCorpus", "(", "doc", ")", ";", "BasicEList", "<", "SCorpus", ">", "cAsList", "=", "new", "BasicEList", "<", "SCorpus", ">", "(", ")", ";", "cAsList", ".", "add", "(", "c", ")", ";", "corpusGraph", ".", "traverse", "(", "cAsList", ",", "GRAPH_TRAVERSE_TYPE", ".", "BOTTOM_UP_DEPTH_FIRST", ",", "\"\"", ",", "new", "SGraphTraverseHandler", "(", ")", "{", "@", "Override", "public", "void", "nodeReached", "(", "GRAPH_TRAVERSE_TYPE", "traversalType", ",", "String", "traversalId", ",", "SNode", "currNode", ",", "SRelation", "edge", ",", "SNode", "fromNode", ",", "long", "order", ")", "{", "result", ".", "add", "(", "currNode", ".", "getSName", "(", ")", ")", ";", "}", "@", "Override", "public", "void", "nodeLeft", "(", "GRAPH_TRAVERSE_TYPE", "traversalType", ",", "String", "traversalId", ",", "SNode", "currNode", ",", "SRelation", "edge", ",", "SNode", "fromNode", ",", "long", "order", ")", "{", "}", "@", "Override", "public", "boolean", "checkConstraint", "(", "GRAPH_TRAVERSE_TYPE", "traversalType", ",", "String", "traversalId", ",", "SRelation", "edge", ",", "SNode", "currNode", ",", "long", "order", ")", "{", "return", "true", ";", "}", "}", ")", ";", "return", "result", ";", "}", "public", "static", "List", "<", "String", ">", "getCorpusPath", "(", "URI", "uri", ")", "{", "String", "rawPath", "=", "StringUtils", ".", "strip", "(", "uri", ".", "getRawPath", "(", ")", ",", "\"/", "t\"", ")", ";", "String", "[", "]", "path", "=", "rawPath", ".", "split", "(", "\"/\"", ")", ";", "ArrayList", "<", "String", ">", "result", "=", "new", "ArrayList", "<", "String", ">", "(", "path", ".", "length", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "path", ".", "length", ";", "i", "++", ")", "{", "try", "{", "result", ".", "add", "(", "URLDecoder", ".", "decode", "(", "path", "[", "i", "]", ",", "\"UTF-8\"", ")", ")", ";", "}", "catch", "(", "UnsupportedEncodingException", "ex", ")", "{", "log", ".", "error", "(", "null", ",", "ex", ")", ";", "result", ".", "add", "(", "path", "[", "i", "]", ")", ";", "}", "}", "return", "result", ";", "}", "}", "</s>" ]
8,754
[ "<s>", "package", "annis", ";", "import", "annis", ".", "exceptions", ".", "AnnisQLSyntaxException", ";", "import", "annis", ".", "utils", ".", "Utils", ";", "import", "ch", ".", "qos", ".", "logback", ".", "classic", ".", "LoggerContext", ";", "import", "ch", ".", "qos", ".", "logback", ".", "classic", ".", "PatternLayout", ";", "import", "ch", ".", "qos", ".", "logback", ".", "classic", ".", "encoder", ".", "PatternLayoutEncoder", ";", "import", "ch", ".", "qos", ".", "logback", ".", "classic", ".", "filter", ".", "ThresholdFilter", ";", "import", "ch", ".", "qos", ".", "logback", ".", "classic", ".", "joran", ".", "JoranConfigurator", ";", "import", "ch", ".", "qos", ".", "logback", ".", "core", ".", "ConsoleAppender", ";", "import", "ch", ".", "qos", ".", "logback", ".", "core", ".", "joran", ".", "spi", ".", "JoranException", ";", "import", "ch", ".", "qos", ".", "logback", ".", "core", ".", "util", ".", "StatusPrinter", ";", "import", "java", ".", "io", ".", "File", ";", "import", "java", ".", "io", ".", "IOException", ";", "import", "java", ".", "io", ".", "PrintStream", ";", "import", "java", ".", "lang", ".", "reflect", ".", "InvocationTargetException", ";", "import", "java", ".", "lang", ".", "reflect", ".", "Method", ";", "import", "java", ".", "util", ".", "*", ";", "import", "org", ".", "apache", ".", "commons", ".", "lang3", ".", "StringUtils", ";", "import", "jline", ".", "console", ".", "ConsoleReader", ";", "import", "jline", ".", "console", ".", "completer", ".", "StringsCompleter", ";", "import", "jline", ".", "console", ".", "history", ".", "FileHistory", ";", "import", "org", ".", "slf4j", ".", "Logger", ";", "import", "org", ".", "slf4j", ".", "LoggerFactory", ";", "import", "org", ".", "slf4j", ".", "bridge", ".", "SLF4JBridgeHandler", ";", "import", "org", ".", "springframework", ".", "context", ".", "support", ".", "GenericXmlApplicationContext", ";", "import", "org", ".", "springframework", ".", "core", ".", "env", ".", "MutablePropertySources", ";", "import", "org", ".", "springframework", ".", "core", ".", "io", ".", "support", ".", "ResourcePropertySource", ";", "public", "abstract", "class", "AnnisBaseRunner", "{", "private", "static", "final", "Logger", "log", "=", "LoggerFactory", ".", "getLogger", "(", "AnnisBaseRunner", ".", "class", ")", ";", "private", "static", "String", "annisHomePath", ";", "protected", "PrintStream", "out", "=", "System", ".", "out", ";", "private", "FileHistory", "history", ";", "private", "String", "helloMessage", ";", "private", "String", "prompt", ";", "public", "static", "AnnisBaseRunner", "getInstance", "(", "String", "beanName", ",", "String", "...", "contextLocations", ")", "{", "return", "getInstance", "(", "beanName", ",", "true", ",", "contextLocations", ")", ";", "}", "public", "static", "AnnisBaseRunner", "getInstance", "(", "String", "beanName", ",", "boolean", "logToConsole", ",", "String", "...", "contextLocations", ")", "{", "return", "(", "AnnisBaseRunner", ")", "getBean", "(", "beanName", ",", "logToConsole", ",", "contextLocations", ")", ";", "}", "public", "static", "Object", "getBean", "(", "String", "beanName", ",", "boolean", "logToConsole", ",", "String", "...", "contextLocations", ")", "{", "checkForAnnisHome", "(", ")", ";", "setupLogging", "(", "logToConsole", ")", ";", "GenericXmlApplicationContext", "ctx", "=", "new", "GenericXmlApplicationContext", "(", ")", ";", "MutablePropertySources", "sources", "=", "ctx", ".", "getEnvironment", "(", ")", ".", "getPropertySources", "(", ")", ";", "try", "{", "sources", ".", "addFirst", "(", "new", "ResourcePropertySource", "(", "\"file:\"", "+", "Utils", ".", "getAnnisFile", "(", "\"\"", ")", ".", "getAbsolutePath", "(", ")", ")", ")", ";", "}", "catch", "(", "IOException", "ex", ")", "{", "log", ".", "error", "(", "\"\"", ",", "ex", ")", ";", "}", "ctx", ".", "load", "(", "contextLocations", ")", ";", "ctx", ".", "refresh", "(", ")", ";", "return", "ctx", ".", "getBean", "(", "beanName", ")", ";", "}", "public", "void", "run", "(", "String", "[", "]", "args", ")", "{", "try", "{", "if", "(", "args", ".", "length", "==", "0", ")", "{", "runInteractive", "(", ")", ";", "return", ";", "}", "else", "{", "for", "(", "String", "cmd", ":", "args", ")", "{", "String", "[", "]", "split", "=", "cmd", ".", "split", "(", "\"\\\\s+\"", ",", "2", ")", ";", "System", ".", "out", ".", "println", "(", "\"\"", "+", "cmd", "+", "\"'\"", ")", ";", "runCommand", "(", "split", "[", "0", "]", ",", "split", ".", "length", ">=", "2", "?", "split", "[", "1", "]", ":", "\"\"", ")", ";", "}", "}", "}", "catch", "(", "AnnisRunnerException", "e", ")", "{", "log", ".", "error", "(", "\"\"", ",", "e", ")", ";", "error", "(", "\"\"", "+", "e", ".", "getMessage", "(", ")", ")", ";", "}", "catch", "(", "Throwable", "e", ")", "{", "log", ".", "warn", "(", "\"\"", ",", "e", ")", ";", "error", "(", "e", ")", ";", "}", "}", "protected", "void", "runInteractive", "(", ")", "throws", "IOException", "{", "System", ".", "out", ".", "println", "(", "helloMessage", ")", ";", "System", ".", "out", ".", "println", "(", ")", ";", "System", ".", "out", ".", "println", "(", "\"\"", ")", ";", "System", ".", "out", ".", "println", "(", ")", ";", "ConsoleReader", "console", "=", "new", "ConsoleReader", "(", ")", ";", "File", "annisDir", "=", "new", "File", "(", "System", ".", "getProperty", "(", "\"user.home\"", ")", "+", "\"/.annis/\"", ")", ";", "if", "(", "!", "annisDir", ".", "mkdirs", "(", ")", ")", "{", "log", ".", "warn", "(", "\"\"", "+", "annisDir", ".", "getAbsolutePath", "(", ")", ")", ";", "}", "history", "=", "new", "FileHistory", "(", "new", "File", "(", "System", ".", "getProperty", "(", "\"user.home\"", ")", "+", "\"\"", ")", ")", ";", "console", ".", "setHistory", "(", "history", ")", ";", "console", ".", "setHistoryEnabled", "(", "true", ")", ";", "console", ".", "setBellEnabled", "(", "true", ")", ";", "List", "<", "String", ">", "commands", "=", "detectAvailableCommands", "(", ")", ";", "Collections", ".", "sort", "(", "commands", ")", ";", "console", ".", "addCompleter", "(", "new", "StringsCompleter", "(", "commands", ")", ")", ";", "String", "line", ";", "prompt", "=", "\"no", "corpus>\"", ";", "while", "(", "(", "line", "=", "console", ".", "readLine", "(", "prompt", "+", "\"", "\"", ")", ")", "!=", "null", ")", "{", "try", "{", "String", "command", "=", "line", ".", "split", "(", "\"", "\"", ")", "[", "0", "]", ";", "if", "(", "\"help\"", ".", "equalsIgnoreCase", "(", "command", ")", ")", "{", "System", ".", "out", ".", "println", "(", "\"\"", ")", ";", "System", ".", "out", ".", "println", "(", "StringUtils", ".", "join", "(", "commands", ",", "\"n\"", ")", ")", ";", "}", "else", "{", "String", "args", "=", "StringUtils", ".", "join", "(", "Arrays", ".", "asList", "(", "line", ".", "split", "(", "\"", "\"", ")", ")", ".", "subList", "(", "1", ",", "line", ".", "split", "(", "\"", "\"", ")", ".", "length", ")", ",", "\"", "\"", ")", ";", "runCommand", "(", "command", ",", "args", ")", ";", "}", "}", "catch", "(", "IndexOutOfBoundsException", "e", ")", "{", "continue", ";", "}", "catch", "(", "UsageException", "e", ")", "{", "error", "(", "e", ")", ";", "}", "}", "}", "protected", "void", "error", "(", "Throwable", "e", ")", "{", "error", "(", "e", ".", "getMessage", "(", ")", ")", ";", "}", "protected", "void", "error", "(", "String", "error", ")", "{", "System", ".", "out", ".", "println", "(", ")", ";", "System", ".", "out", ".", "println", "(", "\"ERROR:", "\"", "+", "error", ")", ";", "}", "protected", "List", "<", "String", ">", "detectAvailableCommands", "(", ")", "{", "LinkedList", "<", "String", ">", "result", "=", "new", "LinkedList", "<", "String", ">", "(", ")", ";", "Method", "[", "]", "methods", "=", "getClass", "(", ")", ".", "getMethods", "(", ")", ";", "for", "(", "Method", "m", ":", "methods", ")", "{", "if", "(", "m", ".", "getName", "(", ")", ".", "startsWith", "(", "\"do\"", ")", ")", "{", "String", "commandName", "=", "m", ".", "getName", "(", ")", ".", "substring", "(", "\"do\"", ".", "length", "(", ")", ")", ";", "if", "(", "commandName", ".", "length", "(", ")", ">", "1", ")", "{", "commandName", "=", "commandName", ".", "substring", "(", "0", ",", "1", ")", ".", "toLowerCase", "(", ")", "+", "commandName", ".", "substring", "(", "1", ")", ";", "result", ".", "add", "(", "commandName", ")", ";", "}", "}", "}", "return", "result", ";", "}", "protected", "void", "runCommand", "(", "String", "command", ",", "String", "args", ")", "{", "String", "methodName", "=", "\"do\"", "+", "command", ".", "substring", "(", "0", ",", "1", ")", ".", "toUpperCase", "(", ")", "+", "command", ".", "substring", "(", "1", ")", ";", "log", ".", "debug", "(", "\"\"", "+", "methodName", ")", ";", "try", "{", "long", "start", "=", "new", "Date", "(", ")", ".", "getTime", "(", ")", ";", "Method", "commandMethod", "=", "getClass", "(", ")", ".", "getMethod", "(", "methodName", ",", "String", ".", "class", ")", ";", "commandMethod", ".", "invoke", "(", "this", ",", "args", ")", ";", "System", ".", "out", ".", "println", "(", "\"Time:", "\"", "+", "(", "new", "Date", "(", ")", ".", "getTime", "(", ")", "-", "start", ")", "+", "\"", "ms\"", ")", ";", "if", "(", "history", "!=", "null", ")", "{", "history", ".", "flush", "(", ")", ";", "}", "}", "catch", "(", "InvocationTargetException", "e", ")", "{", "Throwable", "cause", "=", "e", ".", "getCause", "(", ")", ";", "try", "{", "throw", "cause", ";", "}", "catch", "(", "AnnisQLSyntaxException", "ee", ")", "{", "error", "(", "ee", ".", "getMessage", "(", ")", ")", ";", "}", "catch", "(", "Throwable", "ee", ")", "{", "log", ".", "error", "(", "\"\"", ",", "ee", ")", ";", "error", "(", "\"\"", "+", "ee", ".", "getMessage", "(", ")", ")", ";", "}", "}", "catch", "(", "IllegalAccessException", "e", ")", "{", "log", ".", "error", "(", "\"\"", ",", "e", ")", ";", "throw", "new", "AnnisRunnerException", "(", "\"\"", "+", "methodName", ",", "e", ")", ";", "}", "catch", "(", "SecurityException", "e", ")", "{", "log", ".", "error", "(", "\"\"", ",", "e", ")", ";", "error", "(", "e", ")", ";", "}", "catch", "(", "NoSuchMethodException", "e", ")", "{", "throw", "new", "UsageException", "(", "\"\"", "+", "command", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "log", ".", "error", "(", "\"\"", ",", "e", ")", ";", "}", "}", "private", "static", "void", "checkForAnnisHome", "(", ")", "{", "annisHomePath", "=", "System", ".", "getProperty", "(", "\"annis.home\"", ")", ";", "if", "(", "annisHomePath", "==", "null", ")", "{", "System", ".", "out", ".", "println", "(", "\"\"", ")", ";", "System", ".", "exit", "(", "1", ")", ";", "}", "File", "file", "=", "new", "File", "(", "annisHomePath", ")", ";", "if", "(", "!", "file", ".", "exists", "(", ")", "||", "!", "file", ".", "isDirectory", "(", ")", ")", "{", "System", ".", "out", ".", "println", "(", "\"\"", "+", "annisHomePath", "+", "\"\"", ")", ";", "System", ".", "exit", "(", "2", ")", ";", "}", "}", "public", "static", "void", "setupLogging", "(", "boolean", "console", ")", "{", "LoggerContext", "loggerContext", "=", "(", "LoggerContext", ")", "LoggerFactory", ".", "getILoggerFactory", "(", ")", ";", "JoranConfigurator", "jc", "=", "new", "JoranConfigurator", "(", ")", ";", "jc", ".", "setContext", "(", "loggerContext", ")", ";", "loggerContext", ".", "reset", "(", ")", ";", "try", "{", "jc", ".", "doConfigure", "(", "System", ".", "getProperty", "(", "\"annis.home\"", ")", "+", "\"\"", ")", ";", "}", "catch", "(", "JoranException", "ex", ")", "{", "System", ".", "out", ".", "println", "(", "ex", ".", "getMessage", "(", ")", ")", ";", "}", "ConsoleAppender", "consoleAppender", "=", "new", "ConsoleAppender", "(", ")", ";", "consoleAppender", ".", "setContext", "(", "loggerContext", ")", ";", "consoleAppender", ".", "setName", "(", "\"CONSOLE\"", ")", ";", "PatternLayoutEncoder", "consoleEncoder", "=", "new", "PatternLayoutEncoder", "(", ")", ";", "consoleEncoder", ".", "setContext", "(", "loggerContext", ")", ";", "consoleEncoder", ".", "setPattern", "(", "\"\"", ")", ";", "consoleEncoder", ".", "start", "(", ")", ";", "ThresholdFilter", "consoleFilter", "=", "new", "ThresholdFilter", "(", ")", ";", "consoleFilter", ".", "setLevel", "(", "console", "?", "\"INFO\"", ":", "\"WARN\"", ")", ";", "consoleFilter", ".", "start", "(", ")", ";", "consoleAppender", ".", "setEncoder", "(", "consoleEncoder", ")", ";", "consoleAppender", ".", "addFilter", "(", "consoleFilter", ")", ";", "consoleAppender", ".", "setTarget", "(", "\"System.err\"", ")", ";", "consoleAppender", ".", "start", "(", ")", ";", "ch", ".", "qos", ".", "logback", ".", "classic", ".", "Logger", "logbackLogger", "=", "loggerContext", ".", "getLogger", "(", "Logger", ".", "ROOT_LOGGER_NAME", ")", ";", "logbackLogger", ".", "addAppender", "(", "consoleAppender", ")", ";", "SLF4JBridgeHandler", ".", "removeHandlersForRootLogger", "(", ")", ";", ";", "SLF4JBridgeHandler", ".", "install", "(", ")", ";", "}", "public", "static", "String", "getAnnisHome", "(", ")", "{", "return", "annisHomePath", ";", "}", "public", "String", "getHelloMessage", "(", ")", "{", "return", "helloMessage", ";", "}", "public", "void", "setHelloMessage", "(", "String", "helloMessage", ")", "{", "this", ".", "helloMessage", "=", "helloMessage", ";", "}", "public", "String", "getPrompt", "(", ")", "{", "return", "prompt", ";", "}", "public", "void", "setPrompt", "(", "String", "prompt", ")", "{", "this", ".", "prompt", "=", "prompt", ";", "}", "public", "PrintStream", "getOut", "(", ")", "{", "return", "out", ";", "}", "public", "void", "setOut", "(", "PrintStream", "out", ")", "{", "this", ".", "out", "=", "out", ";", "}", "}", "</s>" ]
8,755
[ "<s>", "package", "annis", ";", "@", "Deprecated", "public", "class", "FindHelper", "{", "}", "</s>" ]
8,756
[ "<s>", "package", "annis", ".", "administration", ";", "import", "java", ".", "io", ".", "BufferedReader", ";", "import", "java", ".", "io", ".", "IOException", ";", "import", "java", ".", "io", ".", "InputStreamReader", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "util", ".", "Arrays", ";", "import", "java", ".", "util", ".", "HashMap", ";", "import", "java", ".", "util", ".", "List", ";", "import", "java", ".", "util", ".", "Map", ";", "import", "org", ".", "apache", ".", "commons", ".", "cli", ".", "CommandLineParser", ";", "import", "org", ".", "apache", ".", "commons", ".", "cli", ".", "Option", ";", "import", "org", ".", "apache", ".", "commons", ".", "cli", ".", "Options", ";", "import", "org", ".", "apache", ".", "commons", ".", "cli", ".", "ParseException", ";", "import", "org", ".", "apache", ".", "commons", ".", "cli", ".", "PosixParser", ";", "import", "org", ".", "springframework", ".", "core", ".", "io", ".", "ClassPathResource", ";", "import", "org", ".", "springframework", ".", "core", ".", "io", ".", "Resource", ";", "import", "annis", ".", "AnnisBaseRunner", ";", "import", "annis", ".", "UsageException", ";", "import", "annis", ".", "corpuspathsearch", ".", "Search", ";", "import", "annis", ".", "utils", ".", "Utils", ";", "import", "java", ".", "io", ".", "File", ";", "import", "java", ".", "util", ".", "LinkedList", ";", "import", "org", ".", "apache", ".", "commons", ".", "cli", ".", "CommandLine", ";", "import", "org", ".", "slf4j", ".", "Logger", ";", "import", "org", ".", "slf4j", ".", "LoggerFactory", ";", "public", "class", "AnnisAdminRunner", "extends", "AnnisBaseRunner", "{", "private", "static", "final", "Logger", "log", "=", "LoggerFactory", ".", "getLogger", "(", "AnnisAdminRunner", ".", "class", ")", ";", "private", "CorpusAdministration", "corpusAdministration", ";", "public", "static", "void", "main", "(", "String", "[", "]", "args", ")", "{", "AnnisBaseRunner", ".", "getInstance", "(", "\"\"", ",", "\"file:\"", "+", "Utils", ".", "getAnnisFile", "(", "\"\"", ")", ".", "getAbsolutePath", "(", ")", ")", ".", "run", "(", "args", ")", ";", "}", "@", "Override", "public", "void", "run", "(", "String", "[", "]", "args", ")", "{", "if", "(", "args", ".", "length", "==", "0", ")", "{", "throw", "new", "UsageException", "(", "\"\"", ")", ";", "}", "String", "command", "=", "args", "[", "0", "]", ";", "List", "<", "String", ">", "commandArgs", "=", "Arrays", ".", "asList", "(", "args", ")", ".", "subList", "(", "1", ",", "args", ".", "length", ")", ";", "if", "(", "\"help\"", ".", "equals", "(", "command", ")", "||", "\"--help\"", ".", "equals", "(", "command", ")", ")", "{", "usage", "(", "null", ")", ";", "}", "else", "if", "(", "\"init\"", ".", "equals", "(", "command", ")", ")", "{", "doInit", "(", "commandArgs", ")", ";", "}", "else", "if", "(", "\"import\"", ".", "equals", "(", "command", ")", ")", "{", "doImport", "(", "commandArgs", ")", ";", "}", "else", "if", "(", "\"delete\"", ".", "equals", "(", "command", ")", ")", "{", "doDelete", "(", "commandArgs", ")", ";", "}", "else", "if", "(", "\"list\"", ".", "equals", "(", "command", ")", ")", "{", "doList", "(", ")", ";", "}", "else", "if", "(", "\"stats\"", ".", "equals", "(", "command", ")", ")", "{", "doStats", "(", ")", ";", "}", "else", "if", "(", "\"indexes\"", ".", "equals", "(", "command", ")", ")", "{", "doIndexes", "(", ")", ";", "}", "else", "{", "throw", "new", "UsageException", "(", "\"\"", "+", "command", ")", ";", "}", "}", "static", "class", "OptionBuilder", "{", "private", "Options", "options", ";", "public", "OptionBuilder", "(", ")", "{", "options", "=", "new", "Options", "(", ")", ";", "}", "public", "OptionBuilder", "addParameter", "(", "String", "opt", ",", "String", "longOpt", ",", "String", "description", ")", "{", "options", ".", "addOption", "(", "opt", ",", "longOpt", ",", "true", ",", "description", ")", ";", "return", "this", ";", "}", "public", "OptionBuilder", "addLongParameter", "(", "String", "longOpt", ",", "String", "description", ")", "{", "options", ".", "addOption", "(", "null", ",", "longOpt", ",", "true", ",", "description", ")", ";", "return", "this", ";", "}", "public", "OptionBuilder", "addRequiredParameter", "(", "String", "opt", ",", "String", "longOpt", ",", "String", "description", ")", "{", "Option", "option", "=", "new", "Option", "(", "opt", ",", "longOpt", ",", "true", ",", "description", ")", ";", "option", ".", "setRequired", "(", "true", ")", ";", "options", ".", "addOption", "(", "option", ")", ";", "return", "this", ";", "}", "public", "OptionBuilder", "addToggle", "(", "String", "opt", ",", "String", "longOpt", ",", "boolean", "hasArg", ",", "String", "description", ")", "{", "options", ".", "addOption", "(", "opt", ",", "longOpt", ",", "false", ",", "description", ")", ";", "return", "this", ";", "}", "public", "Options", "createOptions", "(", ")", "{", "return", "options", ";", "}", "}", "private", "void", "doInit", "(", "List", "<", "String", ">", "commandArgs", ")", "{", "Options", "options", "=", "new", "OptionBuilder", "(", ")", ".", "addParameter", "(", "\"h\"", ",", "\"host\"", ",", "\"\"", ")", ".", "addLongParameter", "(", "\"port\"", ",", "\"\"", ")", ".", "addRequiredParameter", "(", "\"d\"", ",", "\"database\"", ",", "\"\"", ")", ".", "addRequiredParameter", "(", "\"u\"", ",", "\"user\"", ",", "\"\"", ")", ".", "addRequiredParameter", "(", "\"p\"", ",", "\"password\"", ",", "\"\"", ")", ".", "addParameter", "(", "\"D\"", ",", "\"defaultdb\"", ",", "\"\"", ")", ".", "addParameter", "(", "\"U\"", ",", "\"superuser\"", ",", "\"\"", ")", ".", "addParameter", "(", "\"P\"", ",", "\"\"", ",", "\"\"", ")", ".", "addParameter", "(", "\"m\"", ",", "\"\"", ",", "\"\"", "+", "\"\"", ")", ".", "createOptions", "(", ")", ";", "CommandLineParser", "parser", "=", "new", "PosixParser", "(", ")", ";", "CommandLine", "cmdLine", "=", "null", ";", "try", "{", "cmdLine", "=", "parser", ".", "parse", "(", "options", ",", "commandArgs", ".", "toArray", "(", "new", "String", "[", "]", "{", "}", ")", ")", ";", "}", "catch", "(", "ParseException", "e", ")", "{", "throw", "new", "UsageException", "(", "e", ".", "getMessage", "(", ")", ")", ";", "}", "String", "host", "=", "cmdLine", ".", "getOptionValue", "(", "\"host\"", ",", "\"localhost\"", ")", ";", "String", "port", "=", "cmdLine", ".", "getOptionValue", "(", "\"port\"", ",", "\"5432\"", ")", ";", "String", "database", "=", "cmdLine", ".", "getOptionValue", "(", "\"database\"", ")", ";", "String", "user", "=", "cmdLine", ".", "getOptionValue", "(", "\"user\"", ")", ";", "String", "password", "=", "cmdLine", ".", "getOptionValue", "(", "\"password\"", ")", ";", "String", "defaultDatabase", "=", "cmdLine", ".", "getOptionValue", "(", "\"defaultdb\"", ",", "\"postgres\"", ")", ";", "String", "superUser", "=", "cmdLine", ".", "getOptionValue", "(", "\"superuser\"", ",", "\"postgres\"", ")", ";", "String", "superPassword", "=", "cmdLine", ".", "getOptionValue", "(", "\"\"", ")", ";", "boolean", "migrateCorpora", "=", "cmdLine", ".", "hasOption", "(", "\"\"", ")", ";", "List", "<", "Map", "<", "String", ",", "Object", ">", ">", "existingCorpora", "=", "new", "LinkedList", "<", "Map", "<", "String", ",", "Object", ">", ">", "(", ")", ";", "if", "(", "migrateCorpora", ")", "{", "try", "{", "existingCorpora", "=", "corpusAdministration", ".", "listCorpusStats", "(", ")", ";", "}", "catch", "(", "Exception", "ex", ")", "{", "log", ".", "warn", "(", "\"\"", "+", "\"\"", ",", "ex", ")", ";", "migrateCorpora", "=", "false", ";", "}", "}", "corpusAdministration", ".", "initializeDatabase", "(", "host", ",", "port", ",", "database", ",", "user", ",", "password", ",", "defaultDatabase", ",", "superUser", ",", "superPassword", ")", ";", "if", "(", "migrateCorpora", "&&", "existingCorpora", ".", "size", "(", ")", ">", "0", ")", "{", "String", "corpusRoot", "=", "cmdLine", ".", "getOptionValue", "(", "\"\"", ")", ";", "Search", "search", "=", "null", ";", "if", "(", "corpusRoot", "!=", "null", "&&", "!", "\"\"", ".", "equals", "(", "corpusRoot", ")", ")", "{", "File", "rootCorpusPath", "=", "new", "File", "(", "corpusRoot", ")", ";", "if", "(", "rootCorpusPath", ".", "isDirectory", "(", ")", ")", "{", "LinkedList", "<", "File", ">", "l", "=", "new", "LinkedList", "<", "File", ">", "(", ")", ";", "l", ".", "add", "(", "rootCorpusPath", ")", ";", "search", "=", "new", "Search", "(", "l", ")", ";", "}", "}", "for", "(", "Map", "<", "String", ",", "Object", ">", "corpusStat", ":", "existingCorpora", ")", "{", "String", "corpusName", "=", "(", "String", ")", "corpusStat", ".", "get", "(", "\"name\"", ")", ";", "String", "migratePath", "=", "(", "String", ")", "corpusStat", ".", "get", "(", "\"source_path\"", ")", ";", "if", "(", "migratePath", "==", "null", ")", "{", "if", "(", "search", "==", "null", ")", "{", "log", ".", "error", "(", "\"\"", ")", ";", "search", "=", "new", "Search", "(", "new", "LinkedList", "<", "File", ">", "(", ")", ")", ";", "}", "else", "if", "(", "!", "search", ".", "isWasSearched", "(", ")", ")", "{", "log", ".", "info", "(", "\"\"", "+", "\"\"", ")", ";", "search", ".", "startSearch", "(", ")", ";", "}", "if", "(", "search", ".", "getCorpusPaths", "(", ")", ".", "containsKey", "(", "corpusName", ")", ")", "{", "migratePath", "=", "search", ".", "getCorpusPaths", "(", ")", ".", "get", "(", "corpusName", ")", ".", "getParentFile", "(", ")", ".", "getAbsolutePath", "(", ")", ";", "}", "}", "if", "(", "migratePath", "==", "null", "||", "!", "(", "new", "File", "(", "migratePath", ")", ".", "isDirectory", "(", ")", ")", ")", "{", "log", ".", "warn", "(", "\"\"", "+", "corpusName", "+", "\"\"", "+", "\"\"", ")", ";", "}", "else", "{", "log", ".", "info", "(", "\"\"", "+", "corpusName", ")", ";", "corpusAdministration", ".", "importCorpora", "(", "migratePath", ")", ";", "}", "}", "}", "}", "private", "void", "doImport", "(", "List", "<", "String", ">", "commandArgs", ")", "{", "if", "(", "commandArgs", ".", "isEmpty", "(", ")", ")", "{", "throw", "new", "UsageException", "(", "\"\"", ")", ";", "}", "corpusAdministration", ".", "importCorpora", "(", "commandArgs", ")", ";", "}", "private", "void", "doDelete", "(", "List", "<", "String", ">", "commandArgs", ")", "{", "if", "(", "commandArgs", ".", "isEmpty", "(", ")", ")", "{", "throw", "new", "UsageException", "(", "\"\"", ")", ";", "}", "List", "<", "Long", ">", "ids", "=", "new", "ArrayList", "<", "Long", ">", "(", ")", ";", "for", "(", "String", "id", ":", "commandArgs", ")", "{", "try", "{", "ids", ".", "add", "(", "Long", ".", "parseLong", "(", "id", ")", ")", ";", "}", "catch", "(", "NumberFormatException", "e", ")", "{", "throw", "new", "UsageException", "(", "\"\"", "+", "id", ")", ";", "}", "}", "corpusAdministration", ".", "deleteCorpora", "(", "ids", ")", ";", "}", "private", "void", "doList", "(", ")", "{", "List", "<", "Map", "<", "String", ",", "Object", ">", ">", "stats", "=", "corpusAdministration", ".", "listCorpusStats", "(", ")", ";", "if", "(", "stats", ".", "isEmpty", "(", ")", ")", "{", "System", ".", "out", ".", "println", "(", "\"\"", ")", ";", "return", ";", "}", "printTable", "(", "stats", ")", ";", "}", "private", "void", "doStats", "(", ")", "{", "printTable", "(", "corpusAdministration", ".", "listTableStats", "(", ")", ")", ";", "}", "private", "void", "doIndexes", "(", ")", "{", "for", "(", "String", "indexDefinition", ":", "corpusAdministration", ".", "listUsedIndexes", "(", ")", ")", "{", "System", ".", "out", ".", "println", "(", "indexDefinition", "+", "\";\"", ")", ";", "}", "for", "(", "String", "indexDefinition", ":", "corpusAdministration", ".", "listUnusedIndexes", "(", ")", ")", "{", "System", ".", "out", ".", "println", "(", "\"--", "\"", "+", "indexDefinition", "+", "\";\"", ")", ";", "}", "}", "private", "void", "usage", "(", "String", "error", ")", "{", "Resource", "resource", "=", "new", "ClassPathResource", "(", "\"\"", ")", ";", "BufferedReader", "reader", "=", "null", ";", "try", "{", "reader", "=", "new", "BufferedReader", "(", "new", "InputStreamReader", "(", "resource", ".", "getInputStream", "(", ")", ",", "\"UTF-8\"", ")", ")", ";", "for", "(", "String", "line", "=", "reader", ".", "readLine", "(", ")", ";", "line", "!=", "null", ";", "line", "=", "reader", ".", "readLine", "(", ")", ")", "{", "System", ".", "out", ".", "println", "(", "line", ")", ";", "}", "}", "catch", "(", "IOException", "e", ")", "{", "log", ".", "warn", "(", "\"\"", "+", "e", ".", "getMessage", "(", ")", ")", ";", "}", "finally", "{", "if", "(", "reader", "!=", "null", ")", "{", "try", "{", "reader", ".", "close", "(", ")", ";", "}", "catch", "(", "IOException", "ex", ")", "{", "log", ".", "error", "(", "null", ",", "ex", ")", ";", "}", "}", "}", "if", "(", "error", "!=", "null", ")", "{", "error", "(", "error", ")", ";", "}", "}", "private", "void", "printTable", "(", "List", "<", "Map", "<", "String", ",", "Object", ">", ">", "table", ")", "{", "Map", "<", "String", ",", "Object", ">", "first", "=", "table", ".", "get", "(", "0", ")", ";", "List", "<", "String", ">", "columnNames", "=", "new", "ArrayList", "<", "String", ">", "(", "first", ".", "keySet", "(", ")", ")", ";", "Map", "<", "String", ",", "Integer", ">", "columnSize", "=", "new", "HashMap", "<", "String", ",", "Integer", ">", "(", ")", ";", "for", "(", "String", "column", ":", "columnNames", ")", "{", "columnSize", ".", "put", "(", "column", ",", "column", ".", "length", "(", ")", ")", ";", "}", "for", "(", "Map", "<", "String", ",", "Object", ">", "row", ":", "table", ")", "{", "for", "(", "Map", ".", "Entry", "<", "String", ",", "Object", ">", "e", ":", "row", ".", "entrySet", "(", ")", ")", "{", "String", "column", "=", "e", ".", "getKey", "(", ")", ";", "final", "Object", "value", "=", "e", ".", "getValue", "(", ")", ";", "if", "(", "value", "==", "null", ")", "{", "continue", ";", "}", "int", "length", "=", "value", ".", "toString", "(", ")", ".", "length", "(", ")", ";", "if", "(", "columnSize", ".", "get", "(", "column", ")", "<", "length", ")", "{", "columnSize", ".", "put", "(", "column", ",", "length", ")", ";", "}", "}", "}", "StringBuffer", "sb", "=", "new", "StringBuffer", "(", ")", ";", "for", "(", "String", "column", ":", "columnNames", ")", "{", "sb", ".", "append", "(", "pad", "(", "column", ",", "columnSize", ".", "get", "(", "column", ")", ")", ")", ";", "sb", ".", "append", "(", "\"", "|", "\"", ")", ";", "}", "sb", ".", "setLength", "(", "sb", ".", "length", "(", ")", "-", "\"", "|", "\"", ".", "length", "(", ")", ")", ";", "System", ".", "out", ".", "println", "(", "sb", ")", ";", "for", "(", "Map", "<", "String", ",", "Object", ">", "row", ":", "table", ")", "{", "sb", "=", "new", "StringBuffer", "(", ")", ";", "for", "(", "String", "column", ":", "columnNames", ")", "{", "sb", ".", "append", "(", "pad", "(", "row", ".", "get", "(", "column", ")", ",", "columnSize", ".", "get", "(", "column", ")", ")", ")", ";", "sb", ".", "append", "(", "\"", "|", "\"", ")", ";", "}", "sb", ".", "setLength", "(", "sb", ".", "length", "(", ")", "-", "\"", "|", "\"", ".", "length", "(", ")", ")", ";", "System", ".", "out", ".", "println", "(", "sb", ")", ";", "}", "}", "private", "String", "pad", "(", "Object", "o", ",", "int", "length", ")", "{", "String", "s", "=", "o", "!=", "null", "?", "o", ".", "toString", "(", ")", ":", "\"\"", ";", "if", "(", "s", ".", "length", "(", ")", ">", "length", ")", "{", "return", "s", ";", "}", "StringBuilder", "padded", "=", "new", "StringBuilder", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "length", "-", "s", ".", "length", "(", ")", ";", "++", "i", ")", "{", "padded", ".", "append", "(", "\"", "\"", ")", ";", "}", "padded", ".", "append", "(", "o", ")", ";", "return", "padded", ".", "toString", "(", ")", ";", "}", "public", "CorpusAdministration", "getCorpusAdministration", "(", ")", "{", "return", "corpusAdministration", ";", "}", "public", "void", "setCorpusAdministration", "(", "CorpusAdministration", "administration", ")", "{", "this", ".", "corpusAdministration", "=", "administration", ";", "}", "}", "</s>" ]
8,757
[ "<s>", "package", "annis", ".", "administration", ";", "import", "annis", ".", "AnnisRunnerException", ";", "@", "SuppressWarnings", "(", "\"serial\"", ")", "public", "class", "FileAccessException", "extends", "AnnisRunnerException", "{", "public", "FileAccessException", "(", ")", "{", "super", "(", ")", ";", "}", "public", "FileAccessException", "(", "String", "message", ",", "Throwable", "cause", ")", "{", "super", "(", "message", ",", "cause", ")", ";", "}", "public", "FileAccessException", "(", "String", "message", ")", "{", "super", "(", "message", ")", ";", "}", "public", "FileAccessException", "(", "Throwable", "cause", ")", "{", "super", "(", "cause", ")", ";", "}", "}", "</s>" ]
8,758
[ "<s>", "package", "annis", ".", "administration", ";", "import", "java", ".", "io", ".", "BufferedWriter", ";", "import", "java", ".", "io", ".", "File", ";", "import", "java", ".", "io", ".", "FileWriter", ";", "import", "java", ".", "io", ".", "IOException", ";", "import", "java", ".", "util", ".", "Arrays", ";", "import", "java", ".", "util", ".", "List", ";", "import", "java", ".", "util", ".", "Map", ";", "import", "javax", ".", "sql", ".", "DataSource", ";", "import", "org", ".", "postgresql", ".", "Driver", ";", "import", "org", ".", "springframework", ".", "jdbc", ".", "datasource", ".", "SimpleDriverDataSource", ";", "import", "org", ".", "springframework", ".", "transaction", ".", "annotation", ".", "Transactional", ";", "import", "annis", ".", "AnnisRunnerException", ";", "import", "annis", ".", "exceptions", ".", "AnnisException", ";", "import", "org", ".", "apache", ".", "commons", ".", "io", ".", "output", ".", "FileWriterWithEncoding", ";", "import", "org", ".", "slf4j", ".", "Logger", ";", "import", "org", ".", "slf4j", ".", "LoggerFactory", ";", "public", "class", "CorpusAdministration", "{", "private", "AdministrationDao", "administrationDao", ";", "private", "static", "final", "Logger", "log", "=", "LoggerFactory", ".", "getLogger", "(", "CorpusAdministration", ".", "class", ")", ";", "public", "CorpusAdministration", "(", ")", "{", "}", "protected", "DataSource", "createDataSource", "(", "String", "host", ",", "String", "port", ",", "String", "database", ",", "String", "user", ",", "String", "password", ")", "{", "String", "url", "=", "\"\"", "+", "host", "+", "\":\"", "+", "port", "+", "\"/\"", "+", "database", ";", "return", "new", "SimpleDriverDataSource", "(", "new", "Driver", "(", ")", ",", "url", ",", "user", ",", "password", ")", ";", "}", "@", "Transactional", "(", "readOnly", "=", "false", ")", "public", "void", "deleteCorpora", "(", "List", "<", "Long", ">", "ids", ")", "{", "List", "<", "Long", ">", "corpora", "=", "administrationDao", ".", "listToplevelCorpora", "(", ")", ";", "for", "(", "long", "id", ":", "ids", ")", "{", "if", "(", "!", "corpora", ".", "contains", "(", "id", ")", ")", "{", "throw", "new", "AnnisRunnerException", "(", "\"\"", "+", "id", ")", ";", "}", "}", "log", ".", "info", "(", "\"\"", "+", "ids", ")", ";", "administrationDao", ".", "deleteCorpora", "(", "ids", ")", ";", "log", ".", "info", "(", "\"\"", "+", "ids", ")", ";", "}", "public", "void", "initializeDatabase", "(", "String", "host", ",", "String", "port", ",", "String", "database", ",", "String", "user", ",", "String", "password", ",", "String", "defaultDatabase", ",", "String", "superUser", ",", "String", "superPassword", ")", "{", "log", ".", "info", "(", "\"\"", ")", ";", "log", ".", "info", "(", "\"\"", ")", ";", "administrationDao", ".", "setDataSource", "(", "createDataSource", "(", "host", ",", "port", ",", "defaultDatabase", ",", "superUser", ",", "superPassword", ")", ")", ";", "administrationDao", ".", "dropDatabase", "(", "database", ")", ";", "administrationDao", ".", "dropUser", "(", "user", ")", ";", "administrationDao", ".", "createUser", "(", "user", ",", "password", ")", ";", "administrationDao", ".", "createDatabase", "(", "database", ")", ";", "administrationDao", ".", "setDataSource", "(", "createDataSource", "(", "host", ",", "port", ",", "database", ",", "superUser", ",", "superPassword", ")", ")", ";", "administrationDao", ".", "setupDatabase", "(", ")", ";", "administrationDao", ".", "setDataSource", "(", "createDataSource", "(", "host", ",", "port", ",", "database", ",", "user", ",", "password", ")", ")", ";", "administrationDao", ".", "createSchema", "(", ")", ";", "administrationDao", ".", "createSchemaIndexes", "(", ")", ";", "administrationDao", ".", "populateSchema", "(", ")", ";", "writeDatabasePropertiesFile", "(", "host", ",", "port", ",", "database", ",", "user", ",", "password", ")", ";", "}", "public", "void", "importCorpora", "(", "List", "<", "String", ">", "paths", ")", "{", "for", "(", "String", "path", ":", "paths", ")", "{", "log", ".", "info", "(", "\"\"", "+", "path", ")", ";", "administrationDao", ".", "importCorpus", "(", "path", ")", ";", "log", ".", "info", "(", "\"\"", "+", "path", ")", ";", "}", "}", "public", "boolean", "checkDatabaseSchemaVersion", "(", ")", "{", "try", "{", "administrationDao", ".", "checkDatabaseSchemaVersion", "(", ")", ";", "}", "catch", "(", "AnnisException", "ex", ")", "{", "return", "false", ";", "}", "return", "true", ";", "}", "public", "void", "importCorpora", "(", "String", "...", "paths", ")", "{", "importCorpora", "(", "Arrays", ".", "asList", "(", "paths", ")", ")", ";", "}", "public", "List", "<", "Map", "<", "String", ",", "Object", ">", ">", "listCorpusStats", "(", ")", "{", "return", "administrationDao", ".", "listCorpusStats", "(", ")", ";", "}", "public", "List", "<", "Map", "<", "String", ",", "Object", ">", ">", "listTableStats", "(", ")", "{", "return", "administrationDao", ".", "listTableStats", "(", ")", ";", "}", "public", "List", "<", "String", ">", "listUsedIndexes", "(", ")", "{", "return", "administrationDao", ".", "listUsedIndexes", "(", ")", ";", "}", "public", "List", "<", "String", ">", "listUnusedIndexes", "(", ")", "{", "return", "administrationDao", ".", "listUnusedIndexes", "(", ")", ";", "}", "protected", "void", "writeDatabasePropertiesFile", "(", "String", "host", ",", "String", "port", ",", "String", "database", ",", "String", "user", ",", "String", "password", ")", "{", "File", "file", "=", "new", "File", "(", "System", ".", "getProperty", "(", "\"annis.home\"", ")", "+", "\"/conf\"", ",", "\"\"", ")", ";", "try", "{", "BufferedWriter", "writer", "=", "new", "BufferedWriter", "(", "new", "FileWriterWithEncoding", "(", "file", ",", "\"UTF-8\"", ")", ")", ";", "writer", ".", "write", "(", "\"\"", ")", ";", "writer", ".", "write", "(", "\"\"", ")", ";", "writer", ".", "write", "(", "\"\"", "+", "host", "+", "\":\"", "+", "port", "+", "\"/\"", "+", "database", "+", "\"n\"", ")", ";", "writer", ".", "write", "(", "\"\"", "+", "user", "+", "\"n\"", ")", ";", "writer", ".", "write", "(", "\"\"", "+", "password", "+", "\"n\"", ")", ";", "writer", ".", "close", "(", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "log", ".", "error", "(", "\"\"", ",", "e", ")", ";", "throw", "new", "FileAccessException", "(", "e", ")", ";", "}", "log", ".", "info", "(", "\"\"", "+", "file", ".", "getAbsolutePath", "(", ")", ")", ";", "}", "public", "AdministrationDao", "getAdministrationDao", "(", ")", "{", "return", "administrationDao", ";", "}", "public", "void", "setAdministrationDao", "(", "AdministrationDao", "administrationDao", ")", "{", "this", ".", "administrationDao", "=", "administrationDao", ";", "}", "}", "</s>" ]
8,759
[ "<s>", "package", "annis", ".", "administration", ";", "import", "annis", ".", "AnnisRunnerException", ";", "@", "SuppressWarnings", "(", "\"serial\"", ")", "public", "class", "DatabaseAccessException", "extends", "AnnisRunnerException", "{", "public", "DatabaseAccessException", "(", ")", "{", "super", "(", ")", ";", "}", "public", "DatabaseAccessException", "(", "String", "message", ",", "Throwable", "cause", ")", "{", "super", "(", "message", ",", "cause", ")", ";", "}", "public", "DatabaseAccessException", "(", "String", "message", ")", "{", "super", "(", "message", ")", ";", "}", "public", "DatabaseAccessException", "(", "Throwable", "cause", ")", "{", "super", "(", "cause", ")", ";", "}", "}", "</s>" ]
8,760
[ "<s>", "package", "annis", ".", "administration", ";", "import", "org", ".", "slf4j", ".", "Logger", ";", "import", "org", ".", "slf4j", ".", "LoggerFactory", ";", "public", "class", "ApAdministrationDao", "extends", "DefaultAdministrationDao", "{", "private", "static", "final", "Logger", "log", "=", "LoggerFactory", ".", "getLogger", "(", "ApAdministrationDao", ".", "class", ")", ";", "@", "Override", "public", "void", "populateSchema", "(", ")", "{", "super", ".", "populateSchema", "(", ")", ";", "log", ".", "info", "(", "\"\"", ")", ";", "executeSqlFromScript", "(", "getDbLayout", "(", ")", "+", "\"\"", ")", ";", "}", "}", "</s>" ]
8,761
[ "<s>", "package", "annis", ".", "administration", ";", "import", "annis", ".", "exceptions", ".", "AnnisException", ";", "import", "java", ".", "util", ".", "List", ";", "import", "java", ".", "util", ".", "Map", ";", "import", "javax", ".", "sql", ".", "DataSource", ";", "import", "org", ".", "springframework", ".", "jdbc", ".", "core", ".", "namedparam", ".", "MapSqlParameterSource", ";", "public", "interface", "AdministrationDao", "{", "public", "void", "setDataSource", "(", "DataSource", "dataSource", ")", ";", "public", "void", "dropDatabase", "(", "String", "database", ")", ";", "public", "List", "<", "Long", ">", "listToplevelCorpora", "(", ")", ";", "public", "void", "deleteCorpora", "(", "List", "<", "Long", ">", "ids", ")", ";", "public", "void", "dropUser", "(", "String", "username", ")", ";", "public", "void", "createUser", "(", "String", "username", ",", "String", "password", ")", ";", "public", "void", "createDatabase", "(", "String", "database", ")", ";", "public", "void", "setupDatabase", "(", ")", ";", "public", "void", "createSchema", "(", ")", ";", "public", "void", "populateSchema", "(", ")", ";", "public", "void", "createSchemaIndexes", "(", ")", ";", "public", "void", "importCorpus", "(", "String", "path", ")", ";", "public", "List", "<", "Map", "<", "String", ",", "Object", ">", ">", "listCorpusStats", "(", ")", ";", "public", "List", "<", "Map", "<", "String", ",", "Object", ">", ">", "listTableStats", "(", ")", ";", "public", "List", "<", "String", ">", "listUsedIndexes", "(", ")", ";", "public", "List", "<", "String", ">", "listUnusedIndexes", "(", ")", ";", "public", "String", "getDatabaseSchemaVersion", "(", ")", ";", "public", "boolean", "checkDatabaseSchemaVersion", "(", ")", "throws", "AnnisException", ";", "public", "boolean", "executeSqlFromScript", "(", "String", "script", ")", ";", "public", "boolean", "executeSqlFromScript", "(", "String", "script", ",", "MapSqlParameterSource", "args", ")", ";", "}", "</s>" ]
8,762
[ "<s>", "package", "annis", ".", "administration", ";", "import", "org", ".", "slf4j", ".", "Logger", ";", "import", "org", ".", "slf4j", ".", "LoggerFactory", ";", "public", "class", "SfAdministrationDao", "extends", "DefaultAdministrationDao", "{", "private", "static", "final", "Logger", "log", "=", "LoggerFactory", ".", "getLogger", "(", "AdministrationDao", ".", "class", ")", ";", "@", "Override", "public", "void", "populateSchema", "(", ")", "{", "super", ".", "populateSchema", "(", ")", ";", "log", ".", "info", "(", "\"\"", ")", ";", "executeSqlFromScript", "(", "getDbLayout", "(", ")", "+", "\"\"", ")", ";", "}", "@", "Override", "void", "analyzeFacts", "(", "long", "corpusID", ")", "{", "log", ".", "info", "(", "\"\"", "+", "corpusID", ")", ";", "getJdbcTemplate", "(", ")", ".", "getJdbcOperations", "(", ")", ".", "execute", "(", "\"\"", "+", "corpusID", ")", ";", "log", ".", "info", "(", "\"\"", "+", "corpusID", ")", ";", "getJdbcTemplate", "(", ")", ".", "getJdbcOperations", "(", ")", ".", "execute", "(", "\"\"", "+", "corpusID", ")", ";", "log", ".", "info", "(", "\"\"", ")", ";", "getJdbcTemplate", "(", ")", ".", "getJdbcOperations", "(", ")", ".", "execute", "(", "\"\"", ")", ";", "log", ".", "info", "(", "\"\"", ")", ";", "getJdbcTemplate", "(", ")", ".", "getJdbcOperations", "(", ")", ".", "execute", "(", "\"\"", ")", ";", "}", "}", "</s>" ]
8,763
[ "<s>", "package", "annis", ".", "administration", ";", "import", "java", ".", "io", ".", "File", ";", "import", "java", ".", "io", ".", "FileInputStream", ";", "import", "java", ".", "io", ".", "FileNotFoundException", ";", "import", "java", ".", "io", ".", "IOException", ";", "import", "java", ".", "sql", ".", "PreparedStatement", ";", "import", "java", ".", "sql", ".", "SQLException", ";", "import", "java", ".", "util", ".", "Map", ";", "import", "javax", ".", "activation", ".", "MimetypesFileTypeMap", ";", "import", "org", ".", "apache", ".", "commons", ".", "io", ".", "FilenameUtils", ";", "import", "org", ".", "slf4j", ".", "LoggerFactory", ";", "import", "org", ".", "springframework", ".", "dao", ".", "DataAccessException", ";", "import", "org", ".", "springframework", ".", "jdbc", ".", "core", ".", "PreparedStatementCallback", ";", "public", "class", "MediaImportPreparedStatementCallbackImpl", "implements", "PreparedStatementCallback", "<", "Boolean", ">", "{", "private", "static", "final", "org", ".", "slf4j", ".", "Logger", "log", "=", "LoggerFactory", ".", "getLogger", "(", "MediaImportPreparedStatementCallbackImpl", ".", "class", ")", ";", "private", "FileInputStream", "fileStream", ";", "private", "File", "file", ";", "private", "String", "mimeType", ";", "private", "long", "corpusRef", ";", "public", "MediaImportPreparedStatementCallbackImpl", "(", "String", "absolutePath", ",", "long", "corpusRef", ",", "Map", "<", "String", ",", "String", ">", "mimeTypeMapping", ")", "{", "try", "{", "this", ".", "file", "=", "new", "File", "(", "absolutePath", ")", ";", "fileStream", "=", "new", "FileInputStream", "(", "file", ")", ";", "String", "fileEnding", "=", "FilenameUtils", ".", "getExtension", "(", "absolutePath", ")", ";", "if", "(", "mimeTypeMapping", ".", "containsKey", "(", "fileEnding", ")", ")", "{", "this", ".", "mimeType", "=", "mimeTypeMapping", ".", "get", "(", "fileEnding", ")", ";", "}", "else", "{", "this", ".", "mimeType", "=", "new", "MimetypesFileTypeMap", "(", ")", ".", "getContentType", "(", "file", ")", ";", "}", "this", ".", "corpusRef", "=", "corpusRef", ";", "}", "catch", "(", "FileNotFoundException", "ex", ")", "{", "log", ".", "error", "(", "null", ",", "ex", ")", ";", "}", "}", "@", "Override", "public", "Boolean", "doInPreparedStatement", "(", "PreparedStatement", "ps", ")", "throws", "SQLException", ",", "DataAccessException", "{", "ps", ".", "setBinaryStream", "(", "1", ",", "fileStream", ",", "(", "int", ")", "file", ".", "length", "(", ")", ")", ";", "ps", ".", "setLong", "(", "2", ",", "this", ".", "corpusRef", ")", ";", "ps", ".", "setLong", "(", "3", ",", "file", ".", "length", "(", ")", ")", ";", "ps", ".", "setString", "(", "4", ",", "this", ".", "mimeType", ")", ";", "ps", ".", "setString", "(", "5", ",", "file", ".", "getName", "(", ")", ")", ";", "ps", ".", "executeUpdate", "(", ")", ";", "try", "{", "fileStream", ".", "close", "(", ")", ";", "}", "catch", "(", "IOException", "ex", ")", "{", "log", ".", "error", "(", "null", ",", "ex", ")", ";", "}", "return", "true", ";", "}", "}", "</s>" ]
8,764
[ "<s>", "package", "annis", ".", "administration", ";", "import", "annis", ".", "exceptions", ".", "AnnisException", ";", "import", "java", ".", "io", ".", "*", ";", "import", "java", ".", "sql", ".", "Connection", ";", "import", "java", ".", "sql", ".", "ResultSet", ";", "import", "java", ".", "sql", ".", "SQLException", ";", "import", "java", ".", "sql", ".", "Types", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "util", ".", "Arrays", ";", "import", "java", ".", "util", ".", "Collections", ";", "import", "java", ".", "util", ".", "HashMap", ";", "import", "java", ".", "util", ".", "List", ";", "import", "java", ".", "util", ".", "Map", ";", "import", "java", ".", "util", ".", "Map", ".", "Entry", ";", "import", "java", ".", "util", ".", "logging", ".", "Level", ";", "import", "javax", ".", "sql", ".", "DataSource", ";", "import", "org", ".", "apache", ".", "commons", ".", "io", ".", "FilenameUtils", ";", "import", "org", ".", "apache", ".", "commons", ".", "io", ".", "filefilter", ".", "DirectoryFileFilter", ";", "import", "org", ".", "apache", ".", "commons", ".", "io", ".", "filefilter", ".", "FileFileFilter", ";", "import", "org", ".", "apache", ".", "commons", ".", "lang3", ".", "StringUtils", ";", "import", "org", ".", "postgresql", ".", "PGConnection", ";", "import", "org", ".", "slf4j", ".", "Logger", ";", "import", "org", ".", "slf4j", ".", "LoggerFactory", ";", "import", "org", ".", "springframework", ".", "core", ".", "io", ".", "FileSystemResource", ";", "import", "org", ".", "springframework", ".", "core", ".", "io", ".", "Resource", ";", "import", "org", ".", "springframework", ".", "dao", ".", "DataAccessException", ";", "import", "org", ".", "springframework", ".", "jdbc", ".", "core", ".", "JdbcOperations", ";", "import", "org", ".", "springframework", ".", "jdbc", ".", "core", ".", "ResultSetExtractor", ";", "import", "org", ".", "springframework", ".", "jdbc", ".", "core", ".", "namedparam", ".", "MapSqlParameterSource", ";", "import", "org", ".", "springframework", ".", "jdbc", ".", "core", ".", "namedparam", ".", "NamedParameterJdbcTemplate", ";", "import", "org", ".", "springframework", ".", "jdbc", ".", "core", ".", "namedparam", ".", "SqlParameterSource", ";", "import", "org", ".", "springframework", ".", "jdbc", ".", "core", ".", "simple", ".", "ParameterizedSingleColumnRowMapper", ";", "import", "org", ".", "springframework", ".", "jdbc", ".", "datasource", ".", "DataSourceUtils", ";", "import", "org", ".", "springframework", ".", "transaction", ".", "annotation", ".", "Transactional", ";", "public", "class", "DefaultAdministrationDao", "implements", "AdministrationDao", "{", "private", "static", "final", "Logger", "log", "=", "LoggerFactory", ".", "getLogger", "(", "AdministrationDao", ".", "class", ")", ";", "private", "String", "externalFilesPath", ";", "private", "String", "scriptPath", ";", "private", "NamedParameterJdbcTemplate", "jdbcTemplate", ";", "private", "DataSource", "dataSource", ";", "private", "boolean", "temporaryStagingArea", ";", "private", "String", "schemaVersion", ";", "private", "Map", "<", "String", ",", "String", ">", "mimeTypeMapping", ";", "private", "static", "final", "String", "FILE_RESOLVER_VIS_MAP", "=", "\"\"", ";", "private", "String", "[", "]", "importedTables", "=", "{", "\"corpus\"", ",", "\"\"", ",", "\"text\"", ",", "\"node\"", ",", "\"\"", ",", "\"component\"", ",", "\"rank\"", ",", "\"\"", ",", "FILE_RESOLVER_VIS_MAP", "}", ";", "private", "String", "[", "]", "tablesToCopyManually", "=", "{", "\"corpus\"", ",", "\"\"", ",", "\"text\"", ",", "FILE_RESOLVER_VIS_MAP", ",", "\"corpus_stats\"", ",", "\"media_files\"", "}", ";", "private", "String", "[", "]", "createdTables", "=", "{", "\"corpus_stats\"", ",", "\"media_files\"", "}", ";", "private", "String", "dbLayout", ";", "@", "Override", "public", "void", "dropDatabase", "(", "String", "database", ")", "{", "String", "sql", "=", "\"\"", ";", "SqlParameterSource", "args", "=", "makeArgs", "(", ")", ".", "addValue", "(", "\"database\"", ",", "database", ")", ";", "int", "count", "=", "jdbcTemplate", ".", "queryForInt", "(", "sql", ",", "args", ")", ";", "if", "(", "count", "!=", "0", ")", "{", "log", ".", "debug", "(", "\"\"", ")", ";", "jdbcTemplate", ".", "getJdbcOperations", "(", ")", ".", "execute", "(", "\"\"", "+", "database", ")", ";", "}", "}", "@", "Override", "public", "void", "dropUser", "(", "String", "username", ")", "{", "String", "sql", "=", "\"\"", ";", "SqlParameterSource", "args", "=", "makeArgs", "(", ")", ".", "addValue", "(", "\"username\"", ",", "username", ")", ";", "int", "count", "=", "jdbcTemplate", ".", "queryForInt", "(", "sql", ",", "args", ")", ";", "if", "(", "count", "!=", "0", ")", "{", "log", ".", "debug", "(", "\"\"", ")", ";", "jdbcTemplate", ".", "getJdbcOperations", "(", ")", ".", "execute", "(", "\"DROP", "USER", "\"", "+", "username", ")", ";", "}", "}", "@", "Override", "public", "void", "createUser", "(", "String", "username", ",", "String", "password", ")", "{", "log", ".", "info", "(", "\"\"", "+", "username", ")", ";", "jdbcTemplate", ".", "getJdbcOperations", "(", ")", ".", "execute", "(", "\"CREATE", "USER", "\"", "+", "username", "+", "\"", "PASSWORD", "'\"", "+", "password", "+", "\"'\"", ")", ";", "}", "@", "Override", "public", "void", "createDatabase", "(", "String", "database", ")", "{", "log", ".", "info", "(", "\"\"", "+", "database", "+", "\"\"", ")", ";", "jdbcTemplate", ".", "getJdbcOperations", "(", ")", ".", "execute", "(", "\"\"", "+", "database", "+", "\"\"", ")", ";", "}", "@", "Override", "public", "void", "setupDatabase", "(", ")", "{", "installPlPgSql", "(", ")", ";", "createFunctionUniqueToplevelCorpusName", "(", ")", ";", "}", "protected", "void", "installPlPgSql", "(", ")", "{", "log", ".", "info", "(", "\"\"", ")", ";", "try", "{", "jdbcTemplate", ".", "getJdbcOperations", "(", ")", ".", "execute", "(", "\"\"", ")", ";", "}", "catch", "(", "Exception", "ex", ")", "{", "log", ".", "warn", "(", "\"\"", "+", "ex", ".", "getMessage", "(", ")", ")", ";", "}", "}", "protected", "void", "createFunctionUniqueToplevelCorpusName", "(", ")", "{", "log", ".", "info", "(", "\"\"", ")", ";", "executeSqlFromScript", "(", "\"\"", ")", ";", "}", "@", "Override", "public", "void", "createSchema", "(", ")", "{", "log", ".", "info", "(", "\"\"", "+", "dbLayout", "+", "\")\"", ")", ";", "executeSqlFromScript", "(", "dbLayout", "+", "\"/schema.sql\"", ")", ";", "jdbcTemplate", ".", "getJdbcOperations", "(", ")", ".", "execute", "(", "\"\"", "+", "\"\"", "+", "StringUtils", ".", "replace", "(", "getSchemaVersion", "(", ")", ",", "\"'\"", ",", "\"''\"", ")", "+", "\"');\"", ")", ";", "}", "@", "Override", "public", "void", "createSchemaIndexes", "(", ")", "{", "log", ".", "info", "(", "\"\"", "+", "dbLayout", "+", "\")\"", ")", ";", "executeSqlFromScript", "(", "dbLayout", "+", "\"\"", ")", ";", "}", "@", "Override", "public", "void", "populateSchema", "(", ")", "{", "log", ".", "info", "(", "\"\"", ")", ";", "bulkloadTableFromResource", "(", "\"\"", ",", "new", "FileSystemResource", "(", "new", "File", "(", "scriptPath", ",", "\"\"", ")", ")", ")", ";", "executeSqlFromScript", "(", "\"\"", ")", ";", "}", "@", "Override", "@", "Transactional", "(", "readOnly", "=", "true", ")", "public", "String", "getDatabaseSchemaVersion", "(", ")", "{", "try", "{", "Map", "<", "String", ",", "String", ">", "map", "=", "new", "HashMap", "<", "String", ",", "String", ">", "(", ")", ";", "List", "<", "Map", "<", "String", ",", "Object", ">", ">", "result", "=", "jdbcTemplate", ".", "queryForList", "(", "\"\"", ",", "map", ")", ";", "String", "schema", "=", "result", ".", "size", "(", ")", ">", "0", "?", "(", "String", ")", "result", ".", "get", "(", "0", ")", ".", "get", "(", "\"value\"", ")", ":", "\"\"", ";", "return", "schema", ";", "}", "catch", "(", "DataAccessException", "ex", ")", "{", "String", "error", "=", "\"\"", "+", "\"\"", ";", "log", ".", "error", "(", "error", ")", ";", "}", "return", "\"\"", ";", "}", "@", "Override", "public", "boolean", "checkDatabaseSchemaVersion", "(", ")", "throws", "AnnisException", "{", "String", "dbSchemaVersion", "=", "getDatabaseSchemaVersion", "(", ")", ";", "if", "(", "getSchemaVersion", "(", ")", "!=", "null", "&&", "!", "getSchemaVersion", "(", ")", ".", "equalsIgnoreCase", "(", "dbSchemaVersion", ")", ")", "{", "String", "error", "=", "\"\"", "+", "dbSchemaVersion", "+", "\"\"", ";", "log", ".", "error", "(", "error", ")", ";", "throw", "new", "AnnisException", "(", "error", ")", ";", "}", "return", "true", ";", "}", "@", "Override", "@", "Transactional", "(", "readOnly", "=", "false", ")", "public", "void", "importCorpus", "(", "String", "path", ")", "{", "checkDatabaseSchemaVersion", "(", ")", ";", "createStagingArea", "(", "temporaryStagingArea", ")", ";", "bulkImport", "(", "path", ")", ";", "createStagingAreaIndexes", "(", ")", ";", "computeTopLevelCorpus", "(", ")", ";", "analyzeStagingTables", "(", ")", ";", "computeLeftTokenRightToken", "(", ")", ";", "adjustRankPrePost", "(", ")", ";", "long", "corpusID", "=", "updateIds", "(", ")", ";", "importBinaryData", "(", "path", ")", ";", "extendStagingText", "(", "corpusID", ")", ";", "computeRealRoot", "(", ")", ";", "computeLevel", "(", ")", ";", "computeCorpusStatistics", "(", "path", ")", ";", "updateCorpusStatsId", "(", "corpusID", ")", ";", "applyConstraints", "(", ")", ";", "analyzeStagingTables", "(", ")", ";", "insertCorpus", "(", ")", ";", "computeCorpusPath", "(", "corpusID", ")", ";", "createAnnotations", "(", "corpusID", ")", ";", "createFacts", "(", "corpusID", ")", ";", "updateCorpusStatistic", "(", "corpusID", ")", ";", "if", "(", "temporaryStagingArea", ")", "{", "dropStagingArea", "(", ")", ";", "}", "analyzeFacts", "(", "corpusID", ")", ";", "}", "protected", "void", "dropIndexes", "(", ")", "{", "log", ".", "info", "(", "\"\"", ")", ";", "for", "(", "String", "index", ":", "listIndexesOnTables", "(", "allTables", "(", ")", ")", ")", "{", "log", ".", "debug", "(", "\"\"", "+", "index", ")", ";", "jdbcTemplate", ".", "getJdbcOperations", "(", ")", ".", "execute", "(", "\"DROP", "INDEX", "\"", "+", "index", ")", ";", "}", "}", "void", "createStagingArea", "(", "boolean", "useTemporary", ")", "{", "log", ".", "info", "(", "\"\"", ")", ";", "MapSqlParameterSource", "args", "=", "makeArgs", "(", ")", ".", "addValue", "(", "\":tmp\"", ",", "useTemporary", "?", "\"TEMPORARY\"", ":", "\"UNLOGGED\"", ")", ";", "executeSqlFromScript", "(", "\"\"", ",", "args", ")", ";", "}", "void", "bulkImport", "(", "String", "path", ")", "{", "log", ".", "info", "(", "\"\"", ")", ";", "for", "(", "String", "table", ":", "importedTables", ")", "{", "if", "(", "table", ".", "equalsIgnoreCase", "(", "FILE_RESOLVER_VIS_MAP", ")", ")", "{", "try", "{", "JdbcOperations", "sqlOps", "=", "jdbcTemplate", ".", "getJdbcOperations", "(", ")", ";", "File", "resolver_vis_tab", "=", "new", "File", "(", "path", ",", "table", "+", "\".tab\"", ")", ";", "BufferedReader", "bReader", "=", "new", "BufferedReader", "(", "new", "InputStreamReader", "(", "new", "FileInputStream", "(", "resolver_vis_tab", ")", ",", "\"UTF-8\"", ")", ")", ";", "String", "firstLine", "=", "bReader", ".", "readLine", "(", ")", ";", "bReader", ".", "close", "(", ")", ";", "int", "cols", "=", "9", ";", "if", "(", "firstLine", "!=", "null", ")", "{", "String", "[", "]", "entries", "=", "firstLine", ".", "split", "(", "\"t\"", ")", ";", "cols", "=", "entries", ".", "length", ";", "log", ".", "debug", "(", "\"\"", ",", "entries", ",", "cols", ")", ";", "}", "switch", "(", "cols", ")", "{", "case", "8", ":", "StringBuilder", "sb", "=", "new", "StringBuilder", "(", ")", ";", "sb", ".", "append", "(", "\"\"", ")", ";", "sb", ".", "append", "(", "\"(", "\"", ")", ";", "sb", ".", "append", "(", "\"\"", ")", ";", "sb", ".", "append", "(", "\"\"", ")", ";", "sb", ".", "append", "(", "\"\"", ")", ";", "sb", ".", "append", "(", "\"\"", ")", ";", "sb", ".", "append", "(", "\"\"", ")", ";", "sb", ".", "append", "(", "\"\"", ")", ";", "sb", ".", "append", "(", "\"\"", ")", ";", "sb", ".", "append", "(", "\"\"", ")", ";", "sb", ".", "append", "(", "\");\"", ")", ";", "sqlOps", ".", "execute", "(", "sb", ".", "toString", "(", ")", ")", ";", "bulkloadTableFromResource", "(", "\"\"", ",", "new", "FileSystemResource", "(", "resolver_vis_tab", ")", ")", ";", "sb", "=", "new", "StringBuilder", "(", ")", ";", "sb", ".", "append", "(", "\"INSERT", "INTO", "\"", ")", ";", "sb", ".", "append", "(", "tableInStagingArea", "(", "FILE_RESOLVER_VIS_MAP", ")", ")", ";", "sb", ".", "append", "(", "\"nt\"", ")", ";", "sb", ".", "append", "(", "\"", "(\"", ")", ";", "sb", ".", "append", "(", "\"corpus,", "\"", ")", ";", "sb", ".", "append", "(", "\"version,", "\"", ")", ";", "sb", ".", "append", "(", "\"namespace,", "\"", ")", ";", "sb", ".", "append", "(", "\"element,", "\"", ")", ";", "sb", ".", "append", "(", "\"vis_type,", "\"", ")", ";", "sb", ".", "append", "(", "\"\"", ")", ";", "sb", ".", "append", "(", "\"\\\"order\\\",", "\"", ")", ";", "sb", ".", "append", "(", "\"mappings\"", ")", ";", "sb", ".", "append", "(", "\")\"", ")", ";", "sb", ".", "append", "(", "\"n\"", ")", ";", "sb", ".", "append", "(", "\"\"", ")", ";", "sb", ".", "append", "(", "\"\"", ")", ";", "sb", ".", "append", "(", "\"\"", ")", ";", "sb", ".", "append", "(", "\"\"", ")", ";", "sb", ".", "append", "(", "\"\"", ")", ";", "sb", ".", "append", "(", "\"\"", ")", ";", "sb", ".", "append", "(", "\"\"", ")", ";", "sb", ".", "append", "(", "\"tmp.mappings\"", ")", ";", "sb", ".", "append", "(", "\"nt\"", ")", ";", "sb", ".", "append", "(", "\"\"", ")", ";", "sqlOps", ".", "execute", "(", "sb", ".", "toString", "(", ")", ")", ";", "sqlOps", ".", "execute", "(", "\"\"", ")", ";", "break", ";", "case", "9", ":", "bulkloadTableFromResource", "(", "tableInStagingArea", "(", "table", ")", ",", "new", "FileSystemResource", "(", "new", "File", "(", "path", ",", "table", "+", "\".tab\"", ")", ")", ")", ";", "break", ";", "default", ":", "log", ".", "error", "(", "\"\"", ")", ";", "throw", "new", "RuntimeException", "(", ")", ";", "}", "}", "catch", "(", "IOException", "e", ")", "{", "log", ".", "error", "(", "\"\"", ",", "table", "+", "\".tab\"", ",", "e", ")", ";", "}", "catch", "(", "FileAccessException", "e", ")", "{", "log", ".", "error", "(", "\"\"", ",", "table", "+", "\".tab\"", ",", "e", ")", ";", "}", "}", "else", "if", "(", "table", ".", "equalsIgnoreCase", "(", "\"node\"", ")", ")", "{", "bulkImportNode", "(", "path", ")", ";", "}", "else", "{", "bulkloadTableFromResource", "(", "tableInStagingArea", "(", "table", ")", ",", "new", "FileSystemResource", "(", "new", "File", "(", "path", ",", "table", "+", "\".tab\"", ")", ")", ")", ";", "}", "}", "}", "private", "void", "bulkImportNode", "(", "String", "path", ")", "{", "try", "{", "File", "nodeTabFile", "=", "new", "File", "(", "path", ",", "\"node.tab\"", ")", ";", "BufferedReader", "reader", "=", "new", "BufferedReader", "(", "new", "InputStreamReader", "(", "new", "FileInputStream", "(", "nodeTabFile", ")", ",", "\"UTF-8\"", ")", ")", ";", "String", "firstLine", "=", "reader", ".", "readLine", "(", ")", ";", "reader", ".", "close", "(", ")", ";", "int", "columnNumber", "=", "firstLine", "==", "null", "?", "13", ":", "firstLine", ".", "split", "(", "\"t\"", ")", ".", "length", ";", "if", "(", "columnNumber", "==", "13", ")", "{", "bulkloadTableFromResource", "(", "tableInStagingArea", "(", "\"node\"", ")", ",", "new", "FileSystemResource", "(", "nodeTabFile", ")", ")", ";", "}", "else", "if", "(", "columnNumber", "==", "10", ")", "{", "jdbcTemplate", ".", "getJdbcOperations", "(", ")", ".", "execute", "(", "\"\"", "+", "\"n(n\"", "+", "\"id", "bigint,n\"", "+", "\"\"", "+", "\"\"", "+", "\"\"", "+", "\"\"", "+", "\"\"", "+", "\"\"", "+", "\"\"", "+", "\"\"", "+", "\"\"", "+", "\");\"", ")", ";", "bulkloadTableFromResource", "(", "\"_tmpnode\"", ",", "new", "FileSystemResource", "(", "nodeTabFile", ")", ")", ";", "log", ".", "info", "(", "\"\"", ")", ";", "jdbcTemplate", ".", "getJdbcOperations", "(", ")", ".", "execute", "(", "\"INSERT", "INTO", "\"", "+", "tableInStagingArea", "(", "\"node\"", ")", "+", "\"n\"", "+", "\"\"", "+", "\"\"", "+", "\"\"", "+", "\"\"", "+", "\"\"", ")", ";", "}", "else", "{", "throw", "new", "RuntimeException", "(", "\"\"", "+", "\"\"", "+", "columnNumber", ")", ";", "}", "}", "catch", "(", "IOException", "ex", ")", "{", "log", ".", "error", "(", "null", ",", "ex", ")", ";", "}", "}", "void", "createStagingAreaIndexes", "(", ")", "{", "log", ".", "info", "(", "\"\"", ")", ";", "executeSqlFromScript", "(", "\"\"", ")", ";", "}", "void", "computeTopLevelCorpus", "(", ")", "{", "log", ".", "info", "(", "\"\"", ")", ";", "executeSqlFromScript", "(", "\"\"", ")", ";", "}", "void", "importBinaryData", "(", "String", "path", ")", "{", "log", ".", "info", "(", "\"\"", ")", ";", "File", "extData", "=", "new", "File", "(", "path", "+", "\"/ExtData\"", ")", ";", "if", "(", "extData", ".", "canRead", "(", ")", "&&", "extData", ".", "isDirectory", "(", ")", ")", "{", "File", "[", "]", "documents", "=", "extData", ".", "listFiles", "(", "(", "FileFilter", ")", "DirectoryFileFilter", ".", "DIRECTORY", ")", ";", "for", "(", "File", "doc", ":", "documents", ")", "{", "if", "(", "doc", ".", "isDirectory", "(", ")", "&&", "doc", ".", "canRead", "(", ")", ")", "{", "File", "[", "]", "dataFiles", "=", "doc", ".", "listFiles", "(", "(", "FileFilter", ")", "FileFileFilter", ".", "FILE", ")", ";", "for", "(", "File", "data", ":", "dataFiles", ")", "{", "String", "extension", "=", "FilenameUtils", ".", "getExtension", "(", "data", ".", "getName", "(", ")", ")", ";", "try", "{", "if", "(", "mimeTypeMapping", ".", "containsKey", "(", "extension", ")", ")", "{", "log", ".", "info", "(", "\"import", "\"", "+", "data", ".", "getCanonicalPath", "(", ")", "+", "\"\"", ")", ";", "String", "sqlScript", "=", "\"\"", ";", "long", "corpusID", "=", "jdbcTemplate", ".", "getJdbcOperations", "(", ")", ".", "queryForLong", "(", "sqlScript", ",", "doc", ".", "getName", "(", ")", ")", ";", "importSingleFile", "(", "data", ".", "getCanonicalPath", "(", ")", ",", "corpusID", ")", ";", "}", "else", "{", "log", ".", "warn", "(", "\"\"", "+", "data", ".", "getCanonicalPath", "(", ")", "+", "\"\"", ")", ";", "}", "}", "catch", "(", "IOException", "ex", ")", "{", "log", ".", "error", "(", "\"\"", ",", "ex", ")", ";", "}", "}", "}", "}", "}", "}", "@", "Deprecated", "private", "void", "importBinaryDataFromExtFileAnnotations", "(", "String", "path", ")", "{", "log", ".", "info", "(", "\"\"", ")", ";", "String", "extFilePattern", "=", "\"\\\\[ExtFile\\\\]\"", ";", "String", "selectSql", "=", "\"\"", "+", "\"'[ExtFile]%'\"", "+", "\"\"", ";", "List", "<", "String", "[", "]", ">", "list", "=", "jdbcTemplate", ".", "getJdbcOperations", "(", ")", ".", "query", "(", "selectSql", ",", "new", "ResultSetExtractor", "<", "List", "<", "String", "[", "]", ">", ">", "(", ")", "{", "@", "Override", "public", "List", "<", "String", "[", "]", ">", "extractData", "(", "ResultSet", "rs", ")", "throws", "SQLException", ",", "DataAccessException", "{", "ArrayList", "<", "String", "[", "]", ">", "result", "=", "new", "ArrayList", "<", "String", "[", "]", ">", "(", ")", ";", "while", "(", "rs", ".", "next", "(", ")", ")", "{", "String", "[", "]", "tmp", "=", "{", "rs", ".", "getString", "(", "\"value\"", ")", ",", "rs", ".", "getString", "(", "\"corpus_ref\"", ")", "}", ";", "result", ".", "add", "(", "tmp", ")", ";", "}", "return", "result", ";", "}", "}", ")", ";", "for", "(", "String", "[", "]", "externalData", ":", "list", ")", "{", "assert", "externalData", ".", "length", ">", "1", ";", "String", "filename", "=", "externalData", "[", "0", "]", ".", "replaceFirst", "(", "extFilePattern", ",", "\"\"", ")", ";", "log", ".", "info", "(", "\"import", "\"", "+", "filename", "+", "\"\"", ")", ";", "MediaImportPreparedStatementCallbackImpl", "preStat", "=", "new", "MediaImportPreparedStatementCallbackImpl", "(", "path", "+", "\"/ExtData/\"", "+", "filename", ",", "Long", ".", "parseLong", "(", "externalData", "[", "1", "]", ")", ",", "mimeTypeMapping", ")", ";", "String", "sqlScript", "=", "\"\"", ";", "jdbcTemplate", ".", "getJdbcOperations", "(", ")", ".", "execute", "(", "sqlScript", ",", "preStat", ")", ";", "String", "updateValueSql", "=", "\"\"", ";", "SqlParameterSource", "updateArgs", "=", "makeArgs", "(", ")", ".", "addValue", "(", "\"id\"", ",", "Types", ".", "BIGINT", ")", ".", "addValue", "(", "\"externalData\"", ",", "externalData", "[", "0", "]", ",", "Types", ".", "VARCHAR", ")", ";", "jdbcTemplate", ".", "update", "(", "updateValueSql", ",", "updateArgs", ")", ";", "}", "}", "private", "void", "importSingleFile", "(", "String", "path", ",", "long", "corpusRef", ")", "{", "MediaImportPreparedStatementCallbackImpl", "preStat", "=", "new", "MediaImportPreparedStatementCallbackImpl", "(", "path", ",", "corpusRef", ",", "mimeTypeMapping", ")", ";", "String", "sqlScript", "=", "\"\"", ";", "jdbcTemplate", ".", "getJdbcOperations", "(", ")", ".", "execute", "(", "sqlScript", ",", "preStat", ")", ";", "}", "void", "extendStagingText", "(", "long", "toplevelID", ")", "{", "log", ".", "info", "(", "\"\"", ")", ";", ";", "executeSqlFromScript", "(", "\"\"", ",", "makeArgs", "(", ")", ".", "addValue", "(", "\":id\"", ",", "toplevelID", ")", ")", ";", "}", "void", "computeLeftTokenRightToken", "(", ")", "{", "log", ".", "info", "(", "\"\"", ")", ";", "executeSqlFromScript", "(", "\"\"", ")", ";", "}", "void", "computeRealRoot", "(", ")", "{", "log", ".", "info", "(", "\"\"", ")", ";", "executeSqlFromScript", "(", "\"root.sql\"", ")", ";", "}", "void", "computeLevel", "(", ")", "{", "log", ".", "info", "(", "\"\"", ")", ";", "executeSqlFromScript", "(", "\"level.sql\"", ")", ";", "log", ".", "info", "(", "\"\"", ")", ";", "executeSqlFromScript", "(", "\"\"", ")", ";", "}", "void", "computeCorpusStatistics", "(", "String", "path", ")", "{", "File", "f", "=", "new", "File", "(", "path", ")", ";", "String", "absolutePath", "=", "path", ";", "try", "{", "absolutePath", "=", "f", ".", "getCanonicalPath", "(", ")", ";", "}", "catch", "(", "IOException", "ex", ")", "{", "log", ".", "error", "(", "\"\"", ",", "ex", ")", ";", "}", "log", ".", "info", "(", "\"\"", ")", ";", "MapSqlParameterSource", "args", "=", "makeArgs", "(", ")", ".", "addValue", "(", "\":path\"", ",", "absolutePath", ")", ";", "executeSqlFromScript", "(", "\"\"", ",", "args", ")", ";", "}", "void", "updateCorpusStatistic", "(", "long", "corpusID", ")", "{", "MapSqlParameterSource", "args", "=", "makeArgs", "(", ")", ".", "addValue", "(", "\":id\"", ",", "corpusID", ")", ";", "log", ".", "info", "(", "\"\"", ")", ";", "executeSqlFromScript", "(", "\"\"", ",", "args", ")", ";", "}", "void", "computeCorpusPath", "(", "long", "corpusID", ")", "{", "MapSqlParameterSource", "args", "=", "makeArgs", "(", ")", ".", "addValue", "(", "\":id\"", ",", "corpusID", ")", ";", "log", ".", "info", "(", "\"\"", "+", "corpusID", ")", ";", "executeSqlFromScript", "(", "\"\"", ",", "args", ")", ";", "}", "protected", "void", "adjustRankPrePost", "(", ")", "{", "log", ".", "info", "(", "\"\"", ")", ";", "executeSqlFromScript", "(", "\"\"", ")", ";", "log", ".", "info", "(", "\"\"", ")", ";", "jdbcTemplate", ".", "getJdbcOperations", "(", ")", ".", "execute", "(", "\"ANALYZE", "\"", "+", "tableInStagingArea", "(", "\"rank\"", ")", ")", ";", "}", "long", "updateIds", "(", ")", "{", "log", ".", "info", "(", "\"\"", ")", ";", "int", "numOfEntries", "=", "jdbcTemplate", ".", "getJdbcOperations", "(", ")", ".", "queryForInt", "(", "\"\"", ")", ";", "long", "recentCorpusId", "=", "0", ";", "if", "(", "numOfEntries", ">", "0", ")", "{", "recentCorpusId", "=", "jdbcTemplate", ".", "getJdbcOperations", "(", ")", ".", "queryForLong", "(", "\"\"", ")", ";", "log", ".", "info", "(", "\"\"", "+", "recentCorpusId", ")", ";", "}", "MapSqlParameterSource", "args", "=", "makeArgs", "(", ")", ".", "addValue", "(", "\":id\"", ",", "recentCorpusId", ")", ";", "executeSqlFromScript", "(", "\"\"", ",", "args", ")", ";", "log", ".", "info", "(", "\"\"", ")", ";", "long", "result", "=", "jdbcTemplate", ".", "getJdbcOperations", "(", ")", ".", "queryForLong", "(", "\"\"", ")", ";", "log", ".", "info", "(", "\"\"", "+", "result", ")", ";", "return", "result", ";", "}", "void", "updateCorpusStatsId", "(", "long", "corpusId", ")", "{", "log", ".", "info", "(", "\"\"", ")", ";", "jdbcTemplate", ".", "getJdbcOperations", "(", ")", ".", "update", "(", "\"\"", "+", "corpusId", ")", ";", "}", "void", "applyConstraints", "(", ")", "{", "log", ".", "info", "(", "\"\"", ")", ";", "executeSqlFromScript", "(", "\"\"", ")", ";", "}", "void", "insertCorpus", "(", ")", "{", "log", ".", "info", "(", "\"\"", ")", ";", "for", "(", "String", "table", ":", "tablesToCopyManually", ")", "{", "int", "numOfEntries", "=", "jdbcTemplate", ".", "getJdbcOperations", "(", ")", ".", "queryForInt", "(", "\"\"", "+", "tableInStagingArea", "(", "table", ")", ")", ";", "if", "(", "numOfEntries", ">", "0", ")", "{", "StringBuilder", "sql", "=", "new", "StringBuilder", "(", ")", ";", "if", "(", "table", ".", "equalsIgnoreCase", "(", "FILE_RESOLVER_VIS_MAP", ")", ")", "{", "sql", ".", "append", "(", "\"INSERT", "INTO", "\"", ")", ";", "sql", ".", "append", "(", "table", ")", ";", "sql", ".", "append", "(", "\"\"", ")", ";", "sql", ".", "append", "(", "\"\"", ")", ";", "sql", ".", "append", "(", "tableInStagingArea", "(", "table", ")", ")", ".", "append", "(", "\")\"", ")", ";", "}", "else", "{", "sql", ".", "append", "(", "\"INSERT", "INTO", "\"", ")", ";", "sql", ".", "append", "(", "table", ")", ";", "sql", ".", "append", "(", "\"\"", ")", ";", "sql", ".", "append", "(", "tableInStagingArea", "(", "table", ")", ")", ".", "append", "(", "\")\"", ")", ";", "}", "jdbcTemplate", ".", "getJdbcOperations", "(", ")", ".", "execute", "(", "sql", ".", "toString", "(", ")", ")", ";", "}", "}", "}", "void", "dropStagingArea", "(", ")", "{", "log", ".", "info", "(", "\"\"", ")", ";", "List", "<", "String", ">", "tables", "=", "importedAndCreatedTables", "(", ")", ";", "Collections", ".", "reverse", "(", "tables", ")", ";", "for", "(", "String", "table", ":", "tables", ")", "{", "jdbcTemplate", ".", "getJdbcOperations", "(", ")", ".", "execute", "(", "\"DROP", "TABLE", "\"", "+", "tableInStagingArea", "(", "table", ")", ")", ";", "}", "}", "void", "dropMaterializedTables", "(", ")", "{", "log", ".", "info", "(", "\"\"", ")", ";", "jdbcTemplate", ".", "getJdbcOperations", "(", ")", ".", "execute", "(", "\"\"", ")", ";", "}", "void", "analyzeStagingTables", "(", ")", "{", "for", "(", "String", "t", ":", "importedTables", ")", "{", "log", ".", "info", "(", "\"analyzing", "\"", "+", "t", ")", ";", "jdbcTemplate", ".", "getJdbcOperations", "(", ")", ".", "execute", "(", "\"ANALYZE", "\"", "+", "tableInStagingArea", "(", "t", ")", ")", ";", "}", "}", "void", "createAnnotations", "(", "long", "corpusID", ")", "{", "MapSqlParameterSource", "args", "=", "makeArgs", "(", ")", ".", "addValue", "(", "\":id\"", ",", "corpusID", ")", ";", "log", ".", "info", "(", "\"\"", "+", "corpusID", ")", ";", "executeSqlFromScript", "(", "\"\"", ",", "args", ")", ";", "log", ".", "info", "(", "\"\"", "+", "corpusID", ")", ";", "executeSqlFromScript", "(", "\"\"", ",", "args", ")", ";", "}", "void", "analyzeFacts", "(", "long", "corpusID", ")", "{", "log", ".", "info", "(", "\"\"", "+", "corpusID", ")", ";", "jdbcTemplate", ".", "getJdbcOperations", "(", ")", ".", "execute", "(", "\"\"", "+", "corpusID", ")", ";", "log", ".", "info", "(", "\"\"", ")", ";", "jdbcTemplate", ".", "getJdbcOperations", "(", ")", ".", "execute", "(", "\"\"", ")", ";", "}", "void", "createFacts", "(", "long", "corpusID", ")", "{", "MapSqlParameterSource", "args", "=", "makeArgs", "(", ")", ".", "addValue", "(", "\":id\"", ",", "corpusID", ")", ";", "log", ".", "info", "(", "\"\"", "+", "corpusID", ")", ";", "executeSqlFromScript", "(", "dbLayout", "+", "\"/facts.sql\"", ",", "args", ")", ";", "clusterFacts", "(", "corpusID", ")", ";", "log", ".", "info", "(", "\"\"", "+", "corpusID", "+", "\")\"", ")", ";", "executeSqlFromScript", "(", "dbLayout", "+", "\"/indexes.sql\"", ",", "args", ")", ";", "}", "void", "clusterFacts", "(", "long", "corpusID", ")", "{", "MapSqlParameterSource", "args", "=", "makeArgs", "(", ")", ".", "addValue", "(", "\":id\"", ",", "corpusID", ")", ";", "log", ".", "info", "(", "\"\"", "+", "corpusID", ")", ";", "if", "(", "!", "executeSqlFromScript", "(", "dbLayout", "+", "\"/cluster.sql\"", ",", "args", ")", ")", "{", "executeSqlFromScript", "(", "\"cluster.sql\"", ",", "args", ")", ";", "}", "}", "@", "Override", "public", "List", "<", "Long", ">", "listToplevelCorpora", "(", ")", "{", "String", "sql", "=", "\"\"", ";", "return", "jdbcTemplate", ".", "getJdbcOperations", "(", ")", ".", "query", "(", "sql", ",", "ParameterizedSingleColumnRowMapper", ".", "newInstance", "(", "Long", ".", "class", ")", ")", ";", "}", "@", "Transactional", "(", "readOnly", "=", "false", ")", "@", "Override", "public", "void", "deleteCorpora", "(", "List", "<", "Long", ">", "ids", ")", "{", "for", "(", "long", "l", ":", "ids", ")", "{", "log", ".", "debug", "(", "\"\"", "+", "l", ")", ";", "jdbcTemplate", ".", "getJdbcOperations", "(", ")", ".", "execute", "(", "\"\"", "+", "l", ")", ";", "jdbcTemplate", ".", "getJdbcOperations", "(", ")", ".", "execute", "(", "\"\"", "+", "l", ")", ";", "jdbcTemplate", ".", "getJdbcOperations", "(", ")", ".", "execute", "(", "\"\"", "+", "l", ")", ";", "log", ".", "debug", "(", "\"\"", "+", "l", ")", ";", "jdbcTemplate", ".", "getJdbcOperations", "(", ")", ".", "execute", "(", "\"\"", "+", "l", ")", ";", "log", ".", "debug", "(", "\"\"", "+", "l", ")", ";", "jdbcTemplate", ".", "getJdbcOperations", "(", ")", ".", "execute", "(", "\"\"", "+", "l", ")", ";", "}", "log", ".", "debug", "(", "\"\"", "+", "ids", ")", ";", "executeSqlFromScript", "(", "\"\"", ",", "makeArgs", "(", ")", ".", "addValue", "(", "\":ids\"", ",", "StringUtils", ".", "join", "(", "ids", ",", "\",", "\"", ")", ")", ")", ";", "}", "@", "Override", "public", "List", "<", "Map", "<", "String", ",", "Object", ">", ">", "listCorpusStats", "(", ")", "{", "return", "jdbcTemplate", ".", "getJdbcOperations", "(", ")", ".", "queryForList", "(", "\"\"", ")", ";", "}", "@", "Override", "public", "List", "<", "Map", "<", "String", ",", "Object", ">", ">", "listTableStats", "(", ")", "{", "return", "jdbcTemplate", ".", "getJdbcOperations", "(", ")", ".", "queryForList", "(", "\"\"", ")", ";", "}", "@", "Override", "public", "List", "<", "String", ">", "listUsedIndexes", "(", ")", "{", "log", ".", "info", "(", "\"\"", ")", ";", "return", "listIndexDefinitions", "(", "true", ")", ";", "}", "@", "Override", "public", "List", "<", "String", ">", "listUnusedIndexes", "(", ")", "{", "log", ".", "info", "(", "\"\"", ")", ";", "return", "listIndexDefinitions", "(", "false", ")", ";", "}", "private", "List", "<", "String", ">", "importedAndCreatedTables", "(", ")", "{", "List", "<", "String", ">", "tables", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "tables", ".", "addAll", "(", "Arrays", ".", "asList", "(", "importedTables", ")", ")", ";", "tables", ".", "addAll", "(", "Arrays", ".", "asList", "(", "createdTables", ")", ")", ";", "return", "tables", ";", "}", "private", "List", "<", "String", ">", "allTables", "(", ")", "{", "List", "<", "String", ">", "tables", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "tables", ".", "addAll", "(", "Arrays", ".", "asList", "(", "importedTables", ")", ")", ";", "tables", ".", "addAll", "(", "Arrays", ".", "asList", "(", "createdTables", ")", ")", ";", "return", "tables", ";", "}", "private", "String", "tableInStagingArea", "(", "String", "table", ")", "{", "return", "\"_\"", "+", "table", ";", "}", "private", "MapSqlParameterSource", "makeArgs", "(", ")", "{", "return", "new", "MapSqlParameterSource", "(", ")", ";", "}", "private", "ParameterizedSingleColumnRowMapper", "<", "String", ">", "stringRowMapper", "(", ")", "{", "return", "ParameterizedSingleColumnRowMapper", ".", "newInstance", "(", "String", ".", "class", ")", ";", "}", "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "private", "String", "readSqlFromResource", "(", "Resource", "resource", ",", "MapSqlParameterSource", "args", ")", "{", "Map", "<", "String", ",", "Object", ">", "parameters", "=", "args", "!=", "null", "?", "args", ".", "getValues", "(", ")", ":", "new", "HashMap", "(", ")", ";", "BufferedReader", "reader", "=", "null", ";", "try", "{", "StringBuilder", "sqlBuf", "=", "new", "StringBuilder", "(", ")", ";", "reader", "=", "new", "BufferedReader", "(", "new", "InputStreamReader", "(", "new", "FileInputStream", "(", "resource", ".", "getFile", "(", ")", ")", ",", "\"UTF-8\"", ")", ")", ";", "for", "(", "String", "line", "=", "reader", ".", "readLine", "(", ")", ";", "line", "!=", "null", ";", "line", "=", "reader", ".", "readLine", "(", ")", ")", "{", "sqlBuf", ".", "append", "(", "line", ")", ".", "append", "(", "\"n\"", ")", ";", "}", "String", "sql", "=", "sqlBuf", ".", "toString", "(", ")", ";", "for", "(", "Entry", "<", "String", ",", "Object", ">", "placeHolderEntry", ":", "parameters", ".", "entrySet", "(", ")", ")", "{", "String", "key", "=", "placeHolderEntry", ".", "getKey", "(", ")", ";", "String", "value", "=", "placeHolderEntry", ".", "getValue", "(", ")", ".", "toString", "(", ")", ";", "log", ".", "debug", "(", "\"\"", "+", "key", "+", "\"\"", "+", "value", ")", ";", "sql", "=", "sql", ".", "replaceAll", "(", "key", ",", "value", ")", ";", "}", "return", "sql", ";", "}", "catch", "(", "IOException", "e", ")", "{", "log", ".", "error", "(", "\"\"", ",", "e", ")", ";", "throw", "new", "FileAccessException", "(", "\"\"", ",", "e", ")", ";", "}", "finally", "{", "if", "(", "reader", "!=", "null", ")", "{", "try", "{", "reader", ".", "close", "(", ")", ";", "}", "catch", "(", "IOException", "ex", ")", "{", "java", ".", "util", ".", "logging", ".", "Logger", ".", "getLogger", "(", "DefaultAdministrationDao", ".", "class", ".", "getName", "(", ")", ")", ".", "log", "(", "Level", ".", "SEVERE", ",", "null", ",", "ex", ")", ";", "}", "}", "}", "}", "@", "Override", "public", "boolean", "executeSqlFromScript", "(", "String", "script", ")", "{", "return", "executeSqlFromScript", "(", "script", ",", "null", ")", ";", "}", "@", "Override", "public", "boolean", "executeSqlFromScript", "(", "String", "script", ",", "MapSqlParameterSource", "args", ")", "{", "File", "fScript", "=", "new", "File", "(", "scriptPath", ",", "script", ")", ";", "if", "(", "fScript", ".", "canRead", "(", ")", "&&", "fScript", ".", "isFile", "(", ")", ")", "{", "Resource", "resource", "=", "new", "FileSystemResource", "(", "fScript", ")", ";", "log", ".", "debug", "(", "\"\"", "+", "resource", ".", "getFilename", "(", ")", ")", ";", "String", "sql", "=", "readSqlFromResource", "(", "resource", ",", "args", ")", ";", "jdbcTemplate", ".", "getJdbcOperations", "(", ")", ".", "execute", "(", "sql", ")", ";", "return", "true", ";", "}", "else", "{", "log", ".", "debug", "(", "\"SQL", "script", "\"", "+", "fScript", ".", "getName", "(", ")", "+", "\"\"", ")", ";", "return", "false", ";", "}", "}", "private", "void", "bulkloadTableFromResource", "(", "String", "table", ",", "Resource", "resource", ")", "{", "log", ".", "debug", "(", "\"\"", "+", "resource", ".", "getFilename", "(", ")", "+", "\"\"", "+", "table", "+", "\"'\"", ")", ";", "String", "sql", "=", "\"COPY", "\"", "+", "table", "+", "\"\"", ";", "try", "{", "Connection", "con", "=", "DataSourceUtils", ".", "getConnection", "(", "dataSource", ")", ";", "PGConnection", "pgCon", "=", "(", "PGConnection", ")", "con", ";", "pgCon", ".", "getCopyAPI", "(", ")", ".", "copyIn", "(", "sql", ",", "resource", ".", "getInputStream", "(", ")", ")", ";", "DataSourceUtils", ".", "releaseConnection", "(", "con", ",", "dataSource", ")", ";", "}", "catch", "(", "SQLException", "e", ")", "{", "throw", "new", "DatabaseAccessException", "(", "e", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "throw", "new", "FileAccessException", "(", "e", ")", ";", "}", "}", "private", "List", "<", "String", ">", "listIndexesOnTables", "(", "List", "<", "String", ">", "tables", ")", "{", "String", "sql", "=", "\"\"", "+", "\"\"", "+", "\"\"", "+", "\"\"", "+", "\"\"", "+", "\"\"", ";", "SqlParameterSource", "args", "=", "makeArgs", "(", ")", ".", "addValue", "(", "\"tables\"", ",", "tables", ")", ";", "return", "jdbcTemplate", ".", "query", "(", "sql", ",", "args", ",", "stringRowMapper", "(", ")", ")", ";", "}", "private", "List", "<", "String", ">", "listIndexDefinitions", "(", "boolean", "used", ")", "{", "return", "listIndexDefinitions", "(", "used", ",", "allTables", "(", ")", ")", ";", "}", "public", "List", "<", "String", ">", "listIndexDefinitions", "(", "boolean", "used", ",", "List", "<", "String", ">", "tables", ")", "{", "String", "scansOp", "=", "used", "?", "\"!=\"", ":", "\"=\"", ";", "String", "sql", "=", "\"\"", "+", "\"\"", "+", "\"\"", "+", "\"\"", "+", "\"\"", "+", "scansOp", "+", "\"", "0\"", ";", "SqlParameterSource", "args", "=", "makeArgs", "(", ")", ".", "addValue", "(", "\"indexes\"", ",", "listIndexesOnTables", "(", "tables", ")", ")", ";", "return", "jdbcTemplate", ".", "query", "(", "sql", ",", "args", ",", "stringRowMapper", "(", ")", ")", ";", "}", "private", "List", "<", "String", ">", "quotedArray", "(", "String", "...", "values", ")", "{", "List", "<", "String", ">", "result", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "for", "(", "String", "value", ":", "values", ")", "{", "result", ".", "add", "(", "\"'\"", "+", "value", "+", "\"'\"", ")", ";", "}", "return", "result", ";", "}", "public", "List", "<", "String", ">", "listIndexDefinitions", "(", "String", "...", "tables", ")", "{", "String", "template", "=", "\"\"", "+", "\"\"", "+", "\"\"", "+", "\"\"", "+", "\"\"", "+", "\"\"", ";", "String", "sql", "=", "template", ".", "replaceAll", "(", "\":tables\"", ",", "StringUtils", ".", "join", "(", "quotedArray", "(", "tables", ")", ",", "\",", "\"", ")", ")", ";", "return", "jdbcTemplate", ".", "getJdbcOperations", "(", ")", ".", "query", "(", "sql", ",", "new", "ParameterizedSingleColumnRowMapper", "<", "String", ">", "(", ")", ")", ";", "}", "public", "List", "<", "String", ">", "listUsedIndexes", "(", "String", "...", "tables", ")", "{", "String", "template", "=", "\"\"", "+", "\"\"", "+", "\"\"", "+", "\"\"", "+", "\"\"", "+", "\"\"", "+", "\"\"", ";", "String", "sql", "=", "template", ".", "replaceAll", "(", "\":tables\"", ",", "StringUtils", ".", "join", "(", "quotedArray", "(", "tables", ")", ",", "\",", "\"", ")", ")", ";", "return", "jdbcTemplate", ".", "getJdbcOperations", "(", ")", ".", "query", "(", "sql", ",", "new", "ParameterizedSingleColumnRowMapper", "<", "String", ">", "(", ")", ")", ";", "}", "public", "boolean", "resetStatistics", "(", ")", "{", "try", "{", "jdbcTemplate", ".", "getJdbcOperations", "(", ")", ".", "queryForList", "(", "\"\"", ")", ";", "return", "true", ";", "}", "catch", "(", "DataAccessException", "e", ")", "{", "return", "false", ";", "}", "}", "@", "Override", "public", "void", "setDataSource", "(", "DataSource", "dataSource", ")", "{", "this", ".", "dataSource", "=", "dataSource", ";", "jdbcTemplate", "=", "new", "NamedParameterJdbcTemplate", "(", "dataSource", ")", ";", "}", "public", "NamedParameterJdbcTemplate", "getJdbcTemplate", "(", ")", "{", "return", "jdbcTemplate", ";", "}", "public", "String", "getScriptPath", "(", ")", "{", "return", "scriptPath", ";", "}", "public", "void", "setScriptPath", "(", "String", "scriptPath", ")", "{", "this", ".", "scriptPath", "=", "scriptPath", ";", "}", "public", "String", "getExternalFilesPath", "(", ")", "{", "return", "externalFilesPath", ";", "}", "public", "void", "setExternalFilesPath", "(", "String", "externalFilesPath", ")", "{", "this", ".", "externalFilesPath", "=", "externalFilesPath", ";", "}", "public", "String", "getDbLayout", "(", ")", "{", "return", "dbLayout", ";", "}", "public", "void", "setDbLayout", "(", "String", "dbLayout", ")", "{", "this", ".", "dbLayout", "=", "dbLayout", ";", "}", "public", "boolean", "isTemporaryStagingArea", "(", ")", "{", "return", "temporaryStagingArea", ";", "}", "public", "void", "setTemporaryStagingArea", "(", "boolean", "temporaryStagingArea", ")", "{", "this", ".", "temporaryStagingArea", "=", "temporaryStagingArea", ";", "}", "public", "String", "getSchemaVersion", "(", ")", "{", "return", "schemaVersion", ";", "}", "public", "void", "setSchemaVersion", "(", "String", "schemaVersion", ")", "{", "this", ".", "schemaVersion", "=", "schemaVersion", ";", "}", "public", "Map", "<", "String", ",", "String", ">", "getMimeTypeMapping", "(", ")", "{", "return", "mimeTypeMapping", ";", "}", "public", "void", "setMimeTypeMapping", "(", "Map", "<", "String", ",", "String", ">", "mimeTypeMapping", ")", "{", "this", ".", "mimeTypeMapping", "=", "mimeTypeMapping", ";", "}", "}", "</s>" ]
8,765
[ "<s>", "package", "annis", ".", "dao", ";", "import", "annis", ".", "model", ".", "QueryAnnotation", ";", "import", "annis", ".", "ql", ".", "parser", ".", "QueryData", ";", "import", "annis", ".", "sqlgen", ".", "SubQueryCorpusSelectionStrategy", ";", "import", "java", ".", "util", ".", "List", ";", "import", "org", ".", "springframework", ".", "jdbc", ".", "core", ".", "simple", ".", "ParameterizedSingleColumnRowMapper", ";", "import", "org", ".", "springframework", ".", "jdbc", ".", "core", ".", "simple", ".", "SimpleJdbcDaoSupport", ";", "public", "class", "MetaDataFilter", "extends", "SimpleJdbcDaoSupport", "{", "private", "SubQueryCorpusSelectionStrategy", "subQueryCorpusSelectionStrategy", ";", "public", "List", "<", "Long", ">", "getDocumentsForMetadata", "(", "QueryData", "queryData", ")", "{", "List", "<", "Long", ">", "corpusList", "=", "queryData", ".", "getCorpusList", "(", ")", ";", "if", "(", "!", "corpusList", ".", "isEmpty", "(", ")", ")", "{", "List", "<", "QueryAnnotation", ">", "metaData", "=", "queryData", ".", "getMetaData", "(", ")", ";", "if", "(", "!", "metaData", ".", "isEmpty", "(", ")", ")", "{", "String", "documentsWithMetaDataSql", "=", "subQueryCorpusSelectionStrategy", ".", "buildSubQuery", "(", "corpusList", ",", "metaData", ")", ";", "List", "<", "Long", ">", "documents", "=", "getSimpleJdbcTemplate", "(", ")", ".", "query", "(", "documentsWithMetaDataSql", ",", "ParameterizedSingleColumnRowMapper", ".", "newInstance", "(", "Long", ".", "class", ")", ")", ";", "return", "documents", ";", "}", "}", "return", "null", ";", "}", "public", "SubQueryCorpusSelectionStrategy", "getSubQueryCorpusSelectionStrategy", "(", ")", "{", "return", "subQueryCorpusSelectionStrategy", ";", "}", "public", "void", "setSubQueryCorpusSelectionStrategy", "(", "SubQueryCorpusSelectionStrategy", "subQueryCorpusSelectionStrategy", ")", "{", "this", ".", "subQueryCorpusSelectionStrategy", "=", "subQueryCorpusSelectionStrategy", ";", "}", "}", "</s>" ]
8,766
[ "<s>", "package", "annis", ".", "dao", ";", "import", "java", ".", "util", ".", "List", ";", "import", "org", ".", "apache", ".", "commons", ".", "lang3", ".", "StringUtils", ";", "import", "org", ".", "springframework", ".", "jdbc", ".", "core", ".", "JdbcTemplate", ";", "import", "org", ".", "springframework", ".", "jdbc", ".", "core", ".", "simple", ".", "ParameterizedSingleColumnRowMapper", ";", "public", "class", "CountExtractor", "{", "private", "String", "matchedNodesViewName", ";", "public", "String", "explain", "(", "JdbcTemplate", "jdbcTemplate", ",", "boolean", "analyze", ")", "{", "ParameterizedSingleColumnRowMapper", "<", "String", ">", "planRowMapper", "=", "new", "ParameterizedSingleColumnRowMapper", "<", "String", ">", "(", ")", ";", "List", "<", "String", ">", "plan", "=", "jdbcTemplate", ".", "query", "(", "(", "analyze", "?", "\"\"", ":", "\"EXPLAIN", "\"", ")", "+", "\"n\"", "+", "getCountQuery", "(", "jdbcTemplate", ")", ",", "planRowMapper", ")", ";", "return", "StringUtils", ".", "join", "(", "plan", ",", "\"n\"", ")", ";", "}", "public", "int", "queryCount", "(", "JdbcTemplate", "jdbcTemplate", ")", "{", "return", "jdbcTemplate", ".", "queryForInt", "(", "getCountQuery", "(", "jdbcTemplate", ")", ")", ";", "}", "private", "String", "getCountQuery", "(", "JdbcTemplate", "jdbcTemplate", ")", "{", "StringBuilder", "sql", "=", "new", "StringBuilder", "(", ")", ";", "sql", ".", "append", "(", "\"\"", ")", ";", "sql", ".", "append", "(", "matchedNodesViewName", ")", ";", "sql", ".", "append", "(", "\"\"", ")", ";", "return", "sql", ".", "toString", "(", ")", ";", "}", "public", "String", "getMatchedNodesViewName", "(", ")", "{", "return", "matchedNodesViewName", ";", "}", "public", "void", "setMatchedNodesViewName", "(", "String", "matchedNodesViewName", ")", "{", "this", ".", "matchedNodesViewName", "=", "matchedNodesViewName", ";", "}", "}", "</s>" ]
8,767
[ "<s>", "package", "annis", ".", "dao", ";", "import", "java", ".", "util", ".", "List", ";", "import", "annis", ".", "model", ".", "Annotation", ";", "import", "java", ".", "util", ".", "LinkedList", ";", "public", "class", "AnnotatedSpan", "{", "private", "long", "id", ";", "private", "String", "coveredText", ";", "private", "List", "<", "Annotation", ">", "annotations", ";", "private", "List", "<", "Annotation", ">", "metadata", ";", "public", "AnnotatedSpan", "(", "long", "id", ",", "String", "coveredText", ",", "List", "<", "Annotation", ">", "annotations", ")", "{", "this", "(", "id", ",", "coveredText", ",", "annotations", ",", "new", "LinkedList", "<", "Annotation", ">", "(", ")", ")", ";", "}", "public", "AnnotatedSpan", "(", "long", "id", ",", "String", "coveredText", ",", "List", "<", "Annotation", ">", "annotations", ",", "List", "<", "Annotation", ">", "metadata", ")", "{", "super", "(", ")", ";", "this", ".", "id", "=", "id", ";", "this", ".", "coveredText", "=", "coveredText", ";", "this", ".", "annotations", "=", "annotations", ";", "this", ".", "metadata", "=", "metadata", ";", "}", "public", "long", "getId", "(", ")", "{", "return", "id", ";", "}", "public", "void", "setId", "(", "long", "id", ")", "{", "this", ".", "id", "=", "id", ";", "}", "public", "String", "getCoveredText", "(", ")", "{", "return", "coveredText", ";", "}", "public", "void", "setCoveredText", "(", "String", "coveredText", ")", "{", "this", ".", "coveredText", "=", "coveredText", ";", "}", "public", "List", "<", "Annotation", ">", "getAnnotations", "(", ")", "{", "return", "annotations", ";", "}", "public", "void", "setAnnotations", "(", "List", "<", "Annotation", ">", "annotations", ")", "{", "this", ".", "annotations", "=", "annotations", ";", "}", "public", "List", "<", "Annotation", ">", "getMetadata", "(", ")", "{", "return", "metadata", ";", "}", "public", "void", "setMetadata", "(", "List", "<", "Annotation", ">", "metadata", ")", "{", "this", ".", "metadata", "=", "metadata", ";", "}", "}", "</s>" ]
8,768
[ "<s>", "package", "annis", ".", "dao", ";", "import", "java", ".", "sql", ".", "ResultSet", ";", "import", "java", ".", "sql", ".", "SQLException", ";", "import", "org", ".", "springframework", ".", "jdbc", ".", "core", ".", "simple", ".", "ParameterizedRowMapper", ";", "public", "class", "DocumentNameMapRow", "implements", "ParameterizedRowMapper", "<", "String", ">", "{", "@", "Override", "public", "String", "mapRow", "(", "ResultSet", "rs", ",", "int", "rowNum", ")", "throws", "SQLException", "{", "return", "rs", ".", "getString", "(", "\"\"", ")", ";", "}", "}", "</s>" ]
8,769
[ "<s>", "package", "annis", ".", "dao", ";", "import", "annis", ".", "exceptions", ".", "AnnisException", ";", "import", "annis", ".", "service", ".", "objects", ".", "Match", ";", "import", "java", ".", "util", ".", "HashMap", ";", "import", "java", ".", "util", ".", "List", ";", "import", "java", ".", "util", ".", "Properties", ";", "import", "annis", ".", "model", ".", "Annotation", ";", "import", "annis", ".", "ql", ".", "parser", ".", "QueryData", ";", "import", "annis", ".", "resolver", ".", "ResolverEntry", ";", "import", "annis", ".", "resolver", ".", "SingleResolverRequest", ";", "import", "annis", ".", "service", ".", "objects", ".", "AnnisAttribute", ";", "import", "annis", ".", "service", ".", "objects", ".", "AnnisBinary", ";", "import", "annis", ".", "service", ".", "objects", ".", "AnnisCorpus", ";", "import", "annis", ".", "sqlgen", ".", "SqlGenerator", ";", "import", "de", ".", "hu_berlin", ".", "german", ".", "korpling", ".", "saltnpepper", ".", "salt", ".", "saltCommon", ".", "SaltProject", ";", "import", "java", ".", "util", ".", "Map", ";", "import", "org", ".", "springframework", ".", "jdbc", ".", "core", ".", "ResultSetExtractor", ";", "public", "interface", "AnnisDao", "{", "public", "SaltProject", "retrieveAnnotationGraph", "(", "long", "textId", ")", ";", "public", "SaltProject", "retrieveAnnotationGraph", "(", "String", "toplevelCorpusName", ",", "String", "documentName", ")", ";", "public", "List", "<", "AnnisCorpus", ">", "listCorpora", "(", ")", ";", "public", "List", "<", "AnnisAttribute", ">", "listAnnotations", "(", "List", "<", "Long", ">", "corpusList", ",", "boolean", "listValues", ",", "boolean", "onlyMostFrequentValues", ")", ";", "public", "List", "<", "Annotation", ">", "listCorpusAnnotations", "(", "String", "toplevelCorpusName", ")", ";", "public", "List", "<", "Annotation", ">", "listCorpusAnnotations", "(", "String", "toplevelCorpusName", ",", "String", "documentName", ")", ";", "public", "AnnisBinary", "getBinary", "(", "String", "toplevelCorpusName", ",", "String", "corpusName", ",", "int", "offset", ",", "int", "length", ")", ";", "public", "List", "<", "ResolverEntry", ">", "getResolverEntries", "(", "SingleResolverRequest", "request", ")", ";", "public", "QueryData", "parseAQL", "(", "String", "aql", ",", "List", "<", "Long", ">", "corpusList", ")", ";", "int", "count", "(", "QueryData", "queryData", ")", ";", "List", "<", "Match", ">", "find", "(", "QueryData", "queryData", ")", ";", "SaltProject", "graph", "(", "QueryData", "queryData", ")", ";", "SaltProject", "annotate", "(", "QueryData", "queryData", ")", ";", "String", "explain", "(", "SqlGenerator", "<", "QueryData", ",", "?", ">", "generator", ",", "QueryData", "queryData", ",", "final", "boolean", "analyze", ")", ";", "List", "<", "AnnotatedMatch", ">", "matrix", "(", "QueryData", "queryData", ")", ";", "public", "<", "T", ">", "T", "executeQueryFunction", "(", "QueryData", "queryData", ",", "final", "SqlGenerator", "<", "QueryData", ",", "T", ">", "generator", ")", ";", "public", "<", "T", ">", "T", "executeQueryFunction", "(", "QueryData", "queryData", ",", "final", "SqlGenerator", "<", "QueryData", ",", "T", ">", "generator", ",", "final", "ResultSetExtractor", "<", "T", ">", "extractor", ")", ";", "public", "HashMap", "<", "Long", ",", "Properties", ">", "getCorpusConfiguration", "(", ")", ";", "public", "void", "setCorpusConfiguration", "(", "HashMap", "<", "Long", ",", "Properties", ">", "corpusConfiguration", ")", ";", "void", "setTimeout", "(", "int", "milliseconds", ")", ";", "int", "getTimeout", "(", ")", ";", "public", "List", "<", "String", ">", "mapCorpusIdsToNames", "(", "List", "<", "Long", ">", "ids", ")", ";", "public", "List", "<", "Long", ">", "mapCorpusNamesToIds", "(", "List", "<", "String", ">", "corpusNames", ")", ";", "public", "Map", "<", "String", ",", "String", ">", "getCorpusConfiguration", "(", "String", "corpusName", ")", ";", "public", "boolean", "checkDatabaseVersion", "(", ")", "throws", "AnnisException", ";", "}", "</s>" ]
8,770
[ "<s>", "package", "annis", ".", "dao", ";", "import", "annis", ".", "resolver", ".", "ResolverEntry", ";", "import", "annis", ".", "resolver", ".", "SingleResolverRequest", ";", "import", "java", ".", "sql", ".", "Connection", ";", "import", "java", ".", "sql", ".", "PreparedStatement", ";", "import", "java", ".", "sql", ".", "ResultSet", ";", "import", "java", ".", "sql", ".", "SQLException", ";", "import", "java", ".", "util", ".", "HashSet", ";", "import", "java", ".", "util", ".", "LinkedList", ";", "import", "java", ".", "util", ".", "List", ";", "import", "java", ".", "util", ".", "ListIterator", ";", "import", "java", ".", "util", ".", "Properties", ";", "import", "java", ".", "util", ".", "Set", ";", "import", "org", ".", "springframework", ".", "dao", ".", "DataAccessException", ";", "import", "org", ".", "springframework", ".", "jdbc", ".", "core", ".", "PreparedStatementCreator", ";", "import", "org", ".", "springframework", ".", "jdbc", ".", "core", ".", "ResultSetExtractor", ";", "public", "class", "ResolverDaoHelper", "implements", "ResultSetExtractor", ",", "PreparedStatementCreator", "{", "public", "ResolverDaoHelper", "(", ")", "{", "}", "@", "Override", "public", "PreparedStatement", "createPreparedStatement", "(", "Connection", "cnctn", ")", "throws", "SQLException", "{", "String", "select", "=", "\"\"", "+", "\"\"", "+", "\"\"", "+", "\"\"", "+", "\"\"", "+", "\"\"", "+", "\"\"", "+", "\"\"", "+", "\"\"", "+", "\"\"", ";", "String", "defaultFromWhere", "=", "\"\"", ";", "String", "firstUnion", "=", "select", "+", "defaultFromWhere", "+", "\"\"", "+", "\"\"", ";", "String", "secondUnion", "=", "select", "+", "defaultFromWhere", "+", "\"\"", "+", "\"?\"", "+", "\"\"", "+", "\"?\"", "+", "\"\"", "+", "\"\"", "+", "\"\"", "+", "\"?\"", "+", "\"\"", "+", "\"?\"", "+", "\")n\"", ";", "String", "thirdUnion", "=", "select", "+", "defaultFromWhere", "+", "\"\"", "+", "\"?\"", "+", "\"\"", "+", "\"?\"", "+", "\"\"", "+", "\"?\"", "+", "\"n\"", ";", "String", "fourthUnion", "=", "select", "+", "defaultFromWhere", "+", "\"\"", "+", "\"\"", "+", "\"?\"", "+", "\"n\"", ";", "StringBuilder", "result", "=", "new", "StringBuilder", "(", ")", ";", "result", ".", "append", "(", "firstUnion", ")", ";", "result", ".", "append", "(", "\"", "nUNION", "n\"", ")", ";", "result", ".", "append", "(", "secondUnion", ")", ";", "result", ".", "append", "(", "\"", "nUNION", "n\"", ")", ";", "result", ".", "append", "(", "thirdUnion", ")", ";", "result", ".", "append", "(", "\"", "nUNION", "n\"", ")", ";", "result", ".", "append", "(", "fourthUnion", ")", ";", "result", ".", "append", "(", "\"\"", ")", ";", "return", "cnctn", ".", "prepareStatement", "(", "result", ".", "toString", "(", ")", ")", ";", "}", "public", "void", "fillPreparedStatement", "(", "SingleResolverRequest", "resolverRequest", ",", "PreparedStatement", "stmt", ")", "throws", "SQLException", "{", "stmt", ".", "setString", "(", "1", ",", "resolverRequest", ".", "getNamespace", "(", ")", ")", ";", "stmt", ".", "setString", "(", "2", ",", "resolverRequest", ".", "getType", "(", ")", ".", "name", "(", ")", ")", ";", "stmt", ".", "setString", "(", "3", ",", "resolverRequest", ".", "getNamespace", "(", ")", ")", ";", "stmt", ".", "setString", "(", "4", ",", "resolverRequest", ".", "getCorpusName", "(", ")", ")", ";", "stmt", ".", "setString", "(", "5", ",", "resolverRequest", ".", "getNamespace", "(", ")", ")", ";", "stmt", ".", "setString", "(", "6", ",", "resolverRequest", ".", "getType", "(", ")", ".", "name", "(", ")", ")", ";", "stmt", ".", "setString", "(", "7", ",", "resolverRequest", ".", "getCorpusName", "(", ")", ")", ";", "stmt", ".", "setString", "(", "8", ",", "resolverRequest", ".", "getCorpusName", "(", ")", ")", ";", "}", "@", "Override", "public", "List", "<", "ResolverEntry", ">", "extractData", "(", "ResultSet", "rs", ")", "throws", "SQLException", ",", "DataAccessException", "{", "List", "<", "ResolverEntry", ">", "result", "=", "new", "LinkedList", "<", "ResolverEntry", ">", "(", ")", ";", "Set", "<", "RemoveIndexElement", ">", "removeEntries", "=", "new", "HashSet", "<", "RemoveIndexElement", ">", "(", ")", ";", "while", "(", "rs", ".", "next", "(", ")", ")", "{", "Properties", "mappings", "=", "new", "Properties", "(", ")", ";", "String", "mappingsAsString", "=", "rs", ".", "getString", "(", "\"mappings\"", ")", ";", "if", "(", "mappingsAsString", "!=", "null", ")", "{", "String", "[", "]", "entries", "=", "mappingsAsString", ".", "split", "(", "\";\"", ")", ";", "for", "(", "String", "e", ":", "entries", ")", "{", "String", "[", "]", "keyvalue", "=", "e", ".", "split", "(", "\":\"", ",", "2", ")", ";", "if", "(", "keyvalue", ".", "length", "==", "2", ")", "{", "mappings", ".", "put", "(", "keyvalue", "[", "0", "]", ".", "trim", "(", ")", ",", "keyvalue", "[", "1", "]", ".", "trim", "(", ")", ")", ";", "}", "}", "}", "String", "element", "=", "rs", ".", "getString", "(", "\"element\"", ")", ";", "ResolverEntry", "e", "=", "new", "ResolverEntry", "(", "rs", ".", "getLong", "(", "\"id\"", ")", ",", "rs", ".", "getString", "(", "\"corpus\"", ")", ",", "rs", ".", "getString", "(", "\"version\"", ")", ",", "rs", ".", "getString", "(", "\"namespace\"", ")", ",", "element", "==", "null", "?", "null", ":", "ResolverEntry", ".", "ElementType", ".", "valueOf", "(", "element", ")", ",", "rs", ".", "getString", "(", "\"vis_type\"", ")", ",", "rs", ".", "getString", "(", "\"display_name\"", ")", ",", "rs", ".", "getString", "(", "\"visibility\"", ")", ",", "mappings", ",", "rs", ".", "getInt", "(", "\"order\"", ")", ")", ";", "if", "(", "\"removed\"", ".", "equals", "(", "e", ".", "getVisibility", "(", ")", ")", ")", "{", "RemoveIndexElement", "r", "=", "new", "RemoveIndexElement", "(", "e", ")", ";", "removeEntries", ".", "add", "(", "r", ")", ";", "}", "else", "{", "result", ".", "add", "(", "e", ")", ";", "}", "}", "ListIterator", "<", "ResolverEntry", ">", "it", "=", "result", ".", "listIterator", "(", ")", ";", "while", "(", "it", ".", "hasNext", "(", ")", ")", "{", "ResolverEntry", "entry", "=", "it", ".", "next", "(", ")", ";", "RemoveIndexElement", "idx", "=", "new", "RemoveIndexElement", "(", "entry", ")", ";", "if", "(", "removeEntries", ".", "contains", "(", "idx", ")", ")", "{", "it", ".", "remove", "(", ")", ";", "}", "}", "return", "result", ";", "}", "private", "static", "class", "RemoveIndexElement", "{", "public", "String", "namespace", ";", "public", "ResolverEntry", ".", "ElementType", "element", ";", "public", "String", "vis_type", ";", "public", "String", "display_name", ";", "public", "RemoveIndexElement", "(", ")", "{", "}", "public", "RemoveIndexElement", "(", "ResolverEntry", "e", ")", "{", "namespace", "=", "e", ".", "getNamespace", "(", ")", ";", "element", "=", "e", ".", "getElement", "(", ")", ";", "vis_type", "=", "e", ".", "getVisType", "(", ")", ";", "display_name", "=", "e", ".", "getDisplayName", "(", ")", ";", "}", "@", "Override", "public", "int", "hashCode", "(", ")", "{", "int", "hash", "=", "5", ";", "hash", "=", "41", "*", "hash", "+", "(", "this", ".", "namespace", "!=", "null", "?", "this", ".", "namespace", ".", "hashCode", "(", ")", ":", "0", ")", ";", "hash", "=", "41", "*", "hash", "+", "(", "this", ".", "element", "!=", "null", "?", "this", ".", "element", ".", "hashCode", "(", ")", ":", "0", ")", ";", "hash", "=", "41", "*", "hash", "+", "(", "this", ".", "vis_type", "!=", "null", "?", "this", ".", "vis_type", ".", "hashCode", "(", ")", ":", "0", ")", ";", "hash", "=", "41", "*", "hash", "+", "(", "this", ".", "display_name", "!=", "null", "?", "this", ".", "display_name", ".", "hashCode", "(", ")", ":", "0", ")", ";", "return", "hash", ";", "}", "@", "Override", "public", "boolean", "equals", "(", "Object", "obj", ")", "{", "if", "(", "obj", "==", "null", ")", "{", "return", "false", ";", "}", "if", "(", "getClass", "(", ")", "!=", "obj", ".", "getClass", "(", ")", ")", "{", "return", "false", ";", "}", "final", "RemoveIndexElement", "other", "=", "(", "RemoveIndexElement", ")", "obj", ";", "if", "(", "(", "this", ".", "namespace", "==", "null", ")", "?", "(", "other", ".", "namespace", "!=", "null", ")", ":", "!", "this", ".", "namespace", ".", "equals", "(", "other", ".", "namespace", ")", ")", "{", "return", "false", ";", "}", "if", "(", "this", ".", "element", "!=", "other", ".", "element", ")", "{", "return", "false", ";", "}", "if", "(", "(", "this", ".", "vis_type", "==", "null", ")", "?", "(", "other", ".", "vis_type", "!=", "null", ")", ":", "!", "this", ".", "vis_type", ".", "equals", "(", "other", ".", "vis_type", ")", ")", "{", "return", "false", ";", "}", "if", "(", "(", "this", ".", "display_name", "==", "null", ")", "?", "(", "other", ".", "display_name", "!=", "null", ")", ":", "!", "this", ".", "display_name", ".", "equals", "(", "other", ".", "display_name", ")", ")", "{", "return", "false", ";", "}", "return", "true", ";", "}", "}", "}", "</s>" ]
8,771
[ "<s>", "package", "annis", ".", "dao", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "util", ".", "Arrays", ";", "import", "java", ".", "util", ".", "List", ";", "@", "SuppressWarnings", "(", "\"serial\"", ")", "public", "class", "AnnotatedMatch", "extends", "ArrayList", "<", "AnnotatedSpan", ">", "{", "public", "AnnotatedMatch", "(", ")", "{", "super", "(", ")", ";", "}", "public", "AnnotatedMatch", "(", "List", "<", "AnnotatedSpan", ">", "spans", ")", "{", "this", "(", ")", ";", "addAll", "(", "spans", ")", ";", "}", "public", "AnnotatedMatch", "(", "AnnotatedSpan", "...", "spans", ")", "{", "this", "(", "Arrays", ".", "asList", "(", "spans", ")", ")", ";", "}", "}", "</s>" ]
8,772
[ "<s>", "package", "annis", ".", "dao", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "util", ".", "List", ";", "import", "org", ".", "apache", ".", "commons", ".", "lang3", ".", "StringUtils", ";", "import", "org", ".", "apache", ".", "commons", ".", "lang3", ".", "Validate", ";", "import", "org", ".", "springframework", ".", "jdbc", ".", "core", ".", "simple", ".", "ParameterizedSingleColumnRowMapper", ";", "import", "static", "annis", ".", "sqlgen", ".", "SqlConstraints", ".", "sqlString", ";", "public", "class", "ListCorpusByNameDaoHelper", "extends", "ParameterizedSingleColumnRowMapper", "<", "Long", ">", "{", "public", "String", "createSql", "(", "List", "<", "String", ">", "corpusNames", ")", "{", "Validate", ".", "notEmpty", "(", "corpusNames", ",", "\"\"", ")", ";", "List", "<", "String", ">", "corpusNamesSqlStrings", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "for", "(", "String", "corpus", ":", "corpusNames", ")", "{", "corpusNamesSqlStrings", ".", "add", "(", "sqlString", "(", "corpus", ")", ")", ";", "}", "StringBuilder", "sb", "=", "new", "StringBuilder", "(", ")", ";", "sb", ".", "append", "(", "\"\"", ")", ";", "sb", ".", "append", "(", "StringUtils", ".", "join", "(", "corpusNamesSqlStrings", ",", "\",", "\"", ")", ")", ";", "sb", ".", "append", "(", "\"\"", ")", ";", "return", "sb", ".", "toString", "(", ")", ";", "}", "}", "</s>" ]
8,773
[ "<s>", "package", "annis", ".", "dao", ";", "import", "org", ".", "springframework", ".", "jdbc", ".", "core", ".", "JdbcTemplate", ";", "import", "annis", ".", "ql", ".", "parser", ".", "QueryData", ";", "public", "interface", "SqlSessionModifier", "{", "void", "modifySqlSession", "(", "JdbcTemplate", "simpleJdbcTemplate", ",", "QueryData", "queryData", ")", ";", "}", "</s>" ]
8,774
[ "<s>", "package", "annis", ".", "dao", ";", "import", "annis", ".", "exceptions", ".", "AnnisException", ";", "import", "annis", ".", "service", ".", "objects", ".", "Match", ";", "import", "java", ".", "io", ".", "File", ";", "import", "java", ".", "io", ".", "IOException", ";", "import", "java", ".", "io", ".", "UnsupportedEncodingException", ";", "import", "java", ".", "security", ".", "NoSuchAlgorithmException", ";", "import", "java", ".", "sql", ".", "PreparedStatement", ";", "import", "java", ".", "sql", ".", "ResultSet", ";", "import", "java", ".", "sql", ".", "SQLException", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "util", ".", "HashMap", ";", "import", "java", ".", "util", ".", "LinkedList", ";", "import", "java", ".", "util", ".", "List", ";", "import", "java", ".", "util", ".", "Map", ";", "import", "java", ".", "util", ".", "Properties", ";", "import", "java", ".", "util", ".", "TreeMap", ";", "import", "org", ".", "springframework", ".", "dao", ".", "DataAccessException", ";", "import", "org", ".", "springframework", ".", "jdbc", ".", "core", ".", "JdbcTemplate", ";", "import", "org", ".", "springframework", ".", "jdbc", ".", "core", ".", "simple", ".", "ParameterizedSingleColumnRowMapper", ";", "import", "org", ".", "springframework", ".", "jdbc", ".", "core", ".", "simple", ".", "SimpleJdbcDaoSupport", ";", "import", "org", ".", "springframework", ".", "transaction", ".", "annotation", ".", "Transactional", ";", "import", "annis", ".", "model", ".", "Annotation", ";", "import", "annis", ".", "ql", ".", "node", ".", "Start", ";", "import", "annis", ".", "ql", ".", "parser", ".", "AnnisParser", ";", "import", "annis", ".", "ql", ".", "parser", ".", "QueryAnalysis", ";", "import", "annis", ".", "ql", ".", "parser", ".", "QueryData", ";", "import", "annis", ".", "resolver", ".", "ResolverEntry", ";", "import", "annis", ".", "resolver", ".", "SingleResolverRequest", ";", "import", "annis", ".", "service", ".", "objects", ".", "AnnisBinary", ";", "import", "annis", ".", "service", ".", "objects", ".", "AnnisAttribute", ";", "import", "annis", ".", "service", ".", "objects", ".", "AnnisCorpus", ";", "import", "annis", ".", "sqlgen", ".", "AnnotateSqlGenerator", ";", "import", "annis", ".", "sqlgen", ".", "ByteHelper", ";", "import", "annis", ".", "sqlgen", ".", "CountSqlGenerator", ";", "import", "annis", ".", "sqlgen", ".", "FindSqlGenerator", ";", "import", "annis", ".", "sqlgen", ".", "ListAnnotationsSqlHelper", ";", "import", "annis", ".", "sqlgen", ".", "ListCorpusAnnotationsSqlHelper", ";", "import", "annis", ".", "sqlgen", ".", "ListCorpusSqlHelper", ";", "import", "annis", ".", "sqlgen", ".", "MatrixSqlGenerator", ";", "import", "annis", ".", "sqlgen", ".", "SaltAnnotateExtractor", ";", "import", "annis", ".", "sqlgen", ".", "SqlGenerator", ";", "import", "annis", ".", "utils", ".", "Utils", ";", "import", "de", ".", "hu_berlin", ".", "german", ".", "korpling", ".", "saltnpepper", ".", "salt", ".", "saltCommon", ".", "SaltProject", ";", "import", "java", ".", "io", ".", "FileInputStream", ";", "import", "java", ".", "sql", ".", "Connection", ";", "import", "java", ".", "sql", ".", "DatabaseMetaData", ";", "import", "org", ".", "slf4j", ".", "Logger", ";", "import", "org", ".", "slf4j", ".", "LoggerFactory", ";", "import", "org", ".", "springframework", ".", "jdbc", ".", "core", ".", "ResultSetExtractor", ";", "public", "class", "SpringAnnisDao", "extends", "SimpleJdbcDaoSupport", "implements", "AnnisDao", ",", "SqlSessionModifier", "{", "private", "FindSqlGenerator", "findSqlGenerator", ";", "private", "CountSqlGenerator", "countSqlGenerator", ";", "private", "AnnotateSqlGenerator", "<", "SaltProject", ">", "annotateSqlGenerator", ";", "private", "SaltAnnotateExtractor", "saltAnnotateExtractor", ";", "private", "MatrixSqlGenerator", "matrixSqlGenerator", ";", "private", "AnnotateSqlGenerator", "<", "SaltProject", ">", "graphSqlGenerator", ";", "private", "int", "timeout", ";", "private", "Map", "<", "Long", ",", "String", ">", "corpusNamesById", ";", "@", "Override", "@", "Transactional", "public", "SaltProject", "graph", "(", "QueryData", "data", ")", "{", "return", "executeQueryFunction", "(", "data", ",", "graphSqlGenerator", ",", "saltAnnotateExtractor", ")", ";", "}", "public", "AnnotateSqlGenerator", "getGraphSqlGenerator", "(", ")", "{", "return", "graphSqlGenerator", ";", "}", "public", "void", "setGraphSqlGenerator", "(", "AnnotateSqlGenerator", "graphSqlGenerator", ")", "{", "this", ".", "graphSqlGenerator", "=", "graphSqlGenerator", ";", "}", "private", "static", "final", "class", "ExplainSqlGenerator", "implements", "SqlGenerator", "<", "QueryData", ",", "String", ">", "{", "private", "final", "boolean", "analyze", ";", "private", "final", "SqlGenerator", "<", "QueryData", ",", "?", ">", "generator", ";", "private", "ExplainSqlGenerator", "(", "SqlGenerator", "<", "QueryData", ",", "?", ">", "generator", ",", "boolean", "analyze", ")", "{", "this", ".", "generator", "=", "generator", ";", "this", ".", "analyze", "=", "analyze", ";", "}", "@", "Override", "public", "String", "toSql", "(", "QueryData", "queryData", ")", "{", "StringBuilder", "sb", "=", "new", "StringBuilder", "(", ")", ";", "sb", ".", "append", "(", "\"EXPLAIN", "\"", ")", ";", "if", "(", "analyze", ")", "{", "sb", ".", "append", "(", "\"ANALYZE", "\"", ")", ";", "}", "sb", ".", "append", "(", "generator", ".", "toSql", "(", "queryData", ")", ")", ";", "return", "sb", ".", "toString", "(", ")", ";", "}", "@", "Override", "public", "String", "extractData", "(", "ResultSet", "rs", ")", "throws", "SQLException", ",", "DataAccessException", "{", "StringBuilder", "sb", "=", "new", "StringBuilder", "(", ")", ";", "while", "(", "rs", ".", "next", "(", ")", ")", "{", "sb", ".", "append", "(", "rs", ".", "getString", "(", "1", ")", ")", ";", "sb", ".", "append", "(", "\"n\"", ")", ";", "}", "return", "sb", ".", "toString", "(", ")", ";", "}", "@", "Override", "public", "String", "toSql", "(", "QueryData", "queryData", ",", "String", "indent", ")", "{", "return", "toSql", "(", "queryData", ")", ";", "}", "}", "private", "static", "final", "Logger", "log", "=", "LoggerFactory", ".", "getLogger", "(", "SpringAnnisDao", ".", "class", ")", ";", "private", "SqlGenerator", "sqlGenerator", ";", "private", "ListCorpusSqlHelper", "listCorpusSqlHelper", ";", "private", "ListAnnotationsSqlHelper", "listAnnotationsSqlHelper", ";", "private", "ListCorpusAnnotationsSqlHelper", "listCorpusAnnotationsSqlHelper", ";", "private", "List", "<", "SqlSessionModifier", ">", "sqlSessionModifiers", ";", "private", "CountExtractor", "countExtractor", ";", "private", "ParameterizedSingleColumnRowMapper", "<", "String", ">", "planRowMapper", ";", "private", "ListCorpusByNameDaoHelper", "listCorpusByNameDaoHelper", ";", "private", "AnnotateSqlGenerator", "graphExtractor", ";", "private", "MetaDataFilter", "metaDataFilter", ";", "private", "QueryAnalysis", "queryAnalysis", ";", "private", "AnnisParser", "aqlParser", ";", "private", "HashMap", "<", "Long", ",", "Properties", ">", "corpusConfiguration", ";", "private", "ByteHelper", "byteHelper", ";", "public", "SpringAnnisDao", "(", ")", "{", "planRowMapper", "=", "new", "ParameterizedSingleColumnRowMapper", "<", "String", ">", "(", ")", ";", "sqlSessionModifiers", "=", "new", "ArrayList", "<", "SqlSessionModifier", ">", "(", ")", ";", "}", "public", "void", "init", "(", ")", "{", "parseCorpusConfiguration", "(", ")", ";", "}", "@", "Override", "public", "<", "T", ">", "T", "executeQueryFunction", "(", "QueryData", "queryData", ",", "final", "SqlGenerator", "<", "QueryData", ",", "T", ">", "generator", ")", "{", "return", "executeQueryFunction", "(", "queryData", ",", "generator", ",", "generator", ")", ";", "}", "@", "Override", "public", "List", "<", "String", ">", "mapCorpusIdsToNames", "(", "List", "<", "Long", ">", "ids", ")", "{", "List", "<", "String", ">", "names", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "if", "(", "corpusNamesById", "==", "null", ")", "{", "corpusNamesById", "=", "new", "TreeMap", "<", "Long", ",", "String", ">", "(", ")", ";", "List", "<", "AnnisCorpus", ">", "corpora", "=", "listCorpora", "(", ")", ";", "for", "(", "AnnisCorpus", "corpus", ":", "corpora", ")", "{", "corpusNamesById", ".", "put", "(", "corpus", ".", "getId", "(", ")", ",", "corpus", ".", "getName", "(", ")", ")", ";", "}", "}", "for", "(", "Long", "id", ":", "ids", ")", "{", "names", ".", "add", "(", "corpusNamesById", ".", "get", "(", "id", ")", ")", ";", "}", "return", "names", ";", "}", "@", "Transactional", "@", "Override", "public", "<", "T", ">", "T", "executeQueryFunction", "(", "QueryData", "queryData", ",", "final", "SqlGenerator", "<", "QueryData", ",", "T", ">", "generator", ",", "final", "ResultSetExtractor", "<", "T", ">", "extractor", ")", "{", "JdbcTemplate", "jdbcTemplate", "=", "getJdbcTemplate", "(", ")", ";", "queryData", ".", "setCorpusConfiguration", "(", "corpusConfiguration", ")", ";", "queryData", ".", "setDocuments", "(", "metaDataFilter", ".", "getDocumentsForMetadata", "(", "queryData", ")", ")", ";", "for", "(", "SqlSessionModifier", "sqlSessionModifier", ":", "sqlSessionModifiers", ")", "{", "sqlSessionModifier", ".", "modifySqlSession", "(", "jdbcTemplate", ",", "queryData", ")", ";", "}", "return", "jdbcTemplate", ".", "query", "(", "generator", ".", "toSql", "(", "queryData", ")", ",", "extractor", ")", ";", "}", "@", "Override", "public", "void", "modifySqlSession", "(", "JdbcTemplate", "jdbcTemplate", ",", "QueryData", "queryData", ")", "{", "if", "(", "timeout", ">", "0", ")", "{", "jdbcTemplate", ".", "update", "(", "\"\"", "+", "timeout", ")", ";", "}", "}", "@", "Transactional", "(", "readOnly", "=", "true", ")", "@", "Override", "public", "List", "<", "Match", ">", "find", "(", "QueryData", "queryData", ")", "{", "return", "executeQueryFunction", "(", "queryData", ",", "findSqlGenerator", ")", ";", "}", "@", "Transactional", "(", "readOnly", "=", "true", ")", "@", "Override", "public", "int", "count", "(", "QueryData", "queryData", ")", "{", "return", "executeQueryFunction", "(", "queryData", ",", "countSqlGenerator", ")", ";", "}", "@", "Override", "@", "Transactional", "(", "readOnly", "=", "true", ")", "public", "SaltProject", "annotate", "(", "QueryData", "queryData", ")", "{", "return", "executeQueryFunction", "(", "queryData", ",", "annotateSqlGenerator", ",", "saltAnnotateExtractor", ")", ";", "}", "@", "Transactional", "(", "readOnly", "=", "true", ")", "@", "Override", "public", "List", "<", "AnnotatedMatch", ">", "matrix", "(", "QueryData", "queryData", ")", "{", "return", "executeQueryFunction", "(", "queryData", ",", "matrixSqlGenerator", ")", ";", "}", "@", "Override", "@", "Transactional", "(", "readOnly", "=", "true", ")", "public", "String", "explain", "(", "SqlGenerator", "<", "QueryData", ",", "?", ">", "generator", ",", "QueryData", "queryData", ",", "final", "boolean", "analyze", ")", "{", "return", "executeQueryFunction", "(", "queryData", ",", "new", "ExplainSqlGenerator", "(", "generator", ",", "analyze", ")", ")", ";", "}", "@", "Override", "public", "QueryData", "parseAQL", "(", "String", "aql", ",", "List", "<", "Long", ">", "corpusList", ")", "{", "Start", "statement", "=", "aqlParser", ".", "parse", "(", "aql", ")", ";", "return", "queryAnalysis", ".", "analyzeQuery", "(", "statement", ",", "corpusList", ")", ";", "}", "@", "Override", "@", "Transactional", "(", "readOnly", "=", "true", ")", "public", "List", "<", "AnnisCorpus", ">", "listCorpora", "(", ")", "{", "return", "(", "List", "<", "AnnisCorpus", ">", ")", "getJdbcTemplate", "(", ")", ".", "query", "(", "listCorpusSqlHelper", ".", "createSqlQuery", "(", ")", ",", "listCorpusSqlHelper", ")", ";", "}", "@", "Override", "@", "Transactional", "(", "readOnly", "=", "true", ")", "public", "List", "<", "AnnisAttribute", ">", "listAnnotations", "(", "List", "<", "Long", ">", "corpusList", ",", "boolean", "listValues", ",", "boolean", "onlyMostFrequentValues", ")", "{", "return", "(", "List", "<", "AnnisAttribute", ">", ")", "getJdbcTemplate", "(", ")", ".", "query", "(", "listAnnotationsSqlHelper", ".", "createSqlQuery", "(", "corpusList", ",", "listValues", ",", "onlyMostFrequentValues", ")", ",", "listAnnotationsSqlHelper", ")", ";", "}", "@", "Override", "@", "Transactional", "(", "readOnly", "=", "true", ")", "public", "SaltProject", "retrieveAnnotationGraph", "(", "long", "textId", ")", "{", "SaltProject", "p", "=", "annotateSqlGenerator", ".", "queryAnnotationGraph", "(", "getJdbcTemplate", "(", ")", ",", "textId", ")", ";", "return", "p", ";", "}", "@", "Override", "@", "Transactional", "(", "readOnly", "=", "true", ")", "public", "SaltProject", "retrieveAnnotationGraph", "(", "String", "toplevelCorpusName", ",", "String", "documentName", ")", "{", "SaltProject", "p", "=", "annotateSqlGenerator", ".", "queryAnnotationGraph", "(", "getJdbcTemplate", "(", ")", ",", "toplevelCorpusName", ",", "documentName", ")", ";", "return", "p", ";", "}", "@", "Override", "@", "Transactional", "(", "readOnly", "=", "true", ")", "public", "List", "<", "Annotation", ">", "listCorpusAnnotations", "(", "String", "toplevelCorpusName", ")", "{", "final", "String", "sql", "=", "listCorpusAnnotationsSqlHelper", ".", "createSqlQuery", "(", "toplevelCorpusName", ",", "toplevelCorpusName", ")", ";", "final", "List", "<", "Annotation", ">", "corpusAnnotations", "=", "(", "List", "<", "Annotation", ">", ")", "getJdbcTemplate", "(", ")", ".", "query", "(", "sql", ",", "listCorpusAnnotationsSqlHelper", ")", ";", "return", "corpusAnnotations", ";", "}", "@", "Override", "@", "Transactional", "(", "readOnly", "=", "true", ")", "public", "List", "<", "Annotation", ">", "listCorpusAnnotations", "(", "String", "toplevelCorpusName", ",", "String", "documentName", ")", "{", "final", "String", "sql", "=", "listCorpusAnnotationsSqlHelper", ".", "createSqlQuery", "(", "toplevelCorpusName", ",", "documentName", ")", ";", "final", "List", "<", "Annotation", ">", "corpusAnnotations", "=", "(", "List", "<", "Annotation", ">", ")", "getJdbcTemplate", "(", ")", ".", "query", "(", "sql", ",", "listCorpusAnnotationsSqlHelper", ")", ";", "return", "corpusAnnotations", ";", "}", "@", "Override", "@", "Transactional", "(", "readOnly", "=", "true", ")", "public", "List", "<", "Long", ">", "mapCorpusNamesToIds", "(", "List", "<", "String", ">", "corpusNames", ")", "{", "final", "String", "sql", "=", "listCorpusByNameDaoHelper", ".", "createSql", "(", "corpusNames", ")", ";", "final", "List", "<", "Long", ">", "result", "=", "getJdbcTemplate", "(", ")", ".", "query", "(", "sql", ",", "listCorpusByNameDaoHelper", ")", ";", "return", "result", ";", "}", "@", "Override", "@", "Transactional", "(", "readOnly", "=", "true", ")", "public", "List", "<", "ResolverEntry", ">", "getResolverEntries", "(", "SingleResolverRequest", "request", ")", "{", "try", "{", "ResolverDaoHelper", "helper", "=", "new", "ResolverDaoHelper", "(", ")", ";", "PreparedStatement", "stmt", "=", "helper", ".", "createPreparedStatement", "(", "getConnection", "(", ")", ")", ";", "helper", ".", "fillPreparedStatement", "(", "request", ",", "stmt", ")", ";", "List", "<", "ResolverEntry", ">", "result", "=", "helper", ".", "extractData", "(", "stmt", ".", "executeQuery", "(", ")", ")", ";", "return", "result", ";", "}", "catch", "(", "SQLException", "ex", ")", "{", "log", ".", "error", "(", "\"\"", ",", "ex", ")", ";", "return", "new", "LinkedList", "<", "ResolverEntry", ">", "(", ")", ";", "}", "}", "@", "Override", "public", "Map", "<", "String", ",", "String", ">", "getCorpusConfiguration", "(", "String", "corpusName", ")", "{", "Map", "<", "String", ",", "String", ">", "result", "=", "new", "TreeMap", "<", "String", ",", "String", ">", "(", ")", ";", "if", "(", "System", ".", "getProperty", "(", "\"annis.home\"", ")", "!=", "null", ")", "{", "File", "confFolder", "=", "new", "File", "(", "System", ".", "getProperty", "(", "\"annis.home\"", ")", "+", "\"\"", ")", ";", "if", "(", "confFolder", ".", "isDirectory", "(", ")", ")", "{", "File", "conf", "=", "null", ";", "try", "{", "conf", "=", "new", "File", "(", "confFolder", ",", "Utils", ".", "calculateSHAHash", "(", "corpusName", ")", ")", ";", "}", "catch", "(", "NoSuchAlgorithmException", "ex", ")", "{", "log", ".", "warn", "(", "null", ",", "ex", ")", ";", "}", "catch", "(", "UnsupportedEncodingException", "ex", ")", "{", "log", ".", "warn", "(", "null", ",", "ex", ")", ";", "}", "if", "(", "conf", "==", "null", "||", "!", "conf", ".", "isFile", "(", ")", ")", "{", "conf", "=", "new", "File", "(", "confFolder", ",", "corpusName", "+", "\".properties\"", ")", ";", "}", "if", "(", "conf", ".", "isFile", "(", ")", ")", "{", "Properties", "p", "=", "new", "Properties", "(", ")", ";", "FileInputStream", "confStream", "=", "null", ";", "try", "{", "confStream", "=", "new", "FileInputStream", "(", "conf", ")", ";", "p", ".", "load", "(", "confStream", ")", ";", "for", "(", "Map", ".", "Entry", "<", "Object", ",", "Object", ">", "e", ":", "p", ".", "entrySet", "(", ")", ")", "{", "result", ".", "put", "(", "e", ".", "getKey", "(", ")", ".", "toString", "(", ")", ",", "e", ".", "getValue", "(", ")", ".", "toString", "(", ")", ")", ";", "}", "}", "catch", "(", "IOException", "ex", ")", "{", "log", ".", "warn", "(", "\"\"", "+", "conf", ".", "getAbsolutePath", "(", ")", ",", "ex", ")", ";", "}", "finally", "{", "if", "(", "confStream", "!=", "null", ")", "{", "try", "{", "confStream", ".", "close", "(", ")", ";", "}", "catch", "(", "IOException", "ex", ")", "{", "log", ".", "warn", "(", "null", ",", "ex", ")", ";", "}", "}", "}", "}", "}", "}", "return", "result", ";", "}", "private", "void", "parseCorpusConfiguration", "(", ")", "{", "corpusConfiguration", "=", "new", "HashMap", "<", "Long", ",", "Properties", ">", "(", ")", ";", "try", "{", "List", "<", "AnnisCorpus", ">", "corpora", "=", "listCorpora", "(", ")", ";", "for", "(", "AnnisCorpus", "c", ":", "corpora", ")", "{", "Properties", "p", "=", "new", "Properties", "(", ")", ";", "Map", "<", "String", ",", "String", ">", "map", "=", "getCorpusConfiguration", "(", "c", ".", "getName", "(", ")", ")", ";", "for", "(", "Map", ".", "Entry", "<", "String", ",", "String", ">", "e", ":", "map", ".", "entrySet", "(", ")", ")", "{", "p", ".", "setProperty", "(", "e", ".", "getKey", "(", ")", ",", "e", ".", "getValue", "(", ")", ")", ";", "}", "corpusConfiguration", ".", "put", "(", "c", ".", "getId", "(", ")", ",", "p", ")", ";", "}", "}", "catch", "(", "org", ".", "springframework", ".", "jdbc", ".", "CannotGetJdbcConnectionException", "ex", ")", "{", "log", ".", "warn", "(", "\"\"", ")", ";", "}", "}", "@", "Override", "public", "boolean", "checkDatabaseVersion", "(", ")", "throws", "AnnisException", "{", "Connection", "conn", "=", "null", ";", "try", "{", "conn", "=", "getJdbcTemplate", "(", ")", ".", "getDataSource", "(", ")", ".", "getConnection", "(", ")", ";", "DatabaseMetaData", "meta", "=", "conn", ".", "getMetaData", "(", ")", ";", "log", ".", "info", "(", "\"major:", "\"", "+", "meta", ".", "getDatabaseMajorVersion", "(", ")", "+", "\"", "minor:", "\"", "+", "meta", ".", "getDatabaseMinorVersion", "(", ")", "+", "\"", "complete:", "\"", "+", "meta", ".", "getDatabaseProductVersion", "(", ")", "+", "\"", "name:", "\"", "+", "meta", ".", "getDatabaseProductName", "(", ")", ")", ";", "}", "catch", "(", "SQLException", "ex", ")", "{", "log", ".", "error", "(", "\"\"", ",", "ex", ")", ";", "}", "finally", "{", "if", "(", "conn", "!=", "null", ")", "{", "try", "{", "conn", ".", "close", "(", ")", ";", "}", "catch", "(", "SQLException", "ex", ")", "{", "log", ".", "error", "(", "null", ",", "ex", ")", ";", "}", "}", "}", "return", "false", ";", "}", "public", "AnnisParser", "getAqlParser", "(", ")", "{", "return", "aqlParser", ";", "}", "public", "void", "setAqlParser", "(", "AnnisParser", "aqlParser", ")", "{", "this", ".", "aqlParser", "=", "aqlParser", ";", "}", "public", "SqlGenerator", "getSqlGenerator", "(", ")", "{", "return", "sqlGenerator", ";", "}", "public", "void", "setSqlGenerator", "(", "SqlGenerator", "sqlGenerator", ")", "{", "this", ".", "sqlGenerator", "=", "sqlGenerator", ";", "}", "public", "ParameterizedSingleColumnRowMapper", "<", "String", ">", "getPlanRowMapper", "(", ")", "{", "return", "planRowMapper", ";", "}", "public", "void", "setPlanRowMapper", "(", "ParameterizedSingleColumnRowMapper", "<", "String", ">", "planRowMapper", ")", "{", "this", ".", "planRowMapper", "=", "planRowMapper", ";", "}", "public", "ListCorpusSqlHelper", "getListCorpusSqlHelper", "(", ")", "{", "return", "listCorpusSqlHelper", ";", "}", "public", "void", "setListCorpusSqlHelper", "(", "ListCorpusSqlHelper", "listCorpusHelper", ")", "{", "this", ".", "listCorpusSqlHelper", "=", "listCorpusHelper", ";", "}", "public", "ListAnnotationsSqlHelper", "getListAnnotationsSqlHelper", "(", ")", "{", "return", "listAnnotationsSqlHelper", ";", "}", "public", "void", "setListAnnotationsSqlHelper", "(", "ListAnnotationsSqlHelper", "listNodeAnnotationsSqlHelper", ")", "{", "this", ".", "listAnnotationsSqlHelper", "=", "listNodeAnnotationsSqlHelper", ";", "}", "public", "ListCorpusAnnotationsSqlHelper", "getListCorpusAnnotationsSqlHelper", "(", ")", "{", "return", "listCorpusAnnotationsSqlHelper", ";", "}", "public", "void", "setListCorpusAnnotationsSqlHelper", "(", "ListCorpusAnnotationsSqlHelper", "listCorpusAnnotationsHelper", ")", "{", "this", ".", "listCorpusAnnotationsSqlHelper", "=", "listCorpusAnnotationsHelper", ";", "}", "public", "List", "<", "SqlSessionModifier", ">", "getSqlSessionModifiers", "(", ")", "{", "return", "sqlSessionModifiers", ";", "}", "public", "void", "setSqlSessionModifiers", "(", "List", "<", "SqlSessionModifier", ">", "sqlSessionModifiers", ")", "{", "this", ".", "sqlSessionModifiers", "=", "sqlSessionModifiers", ";", "}", "public", "FindSqlGenerator", "getFindSqlGenerator", "(", ")", "{", "return", "findSqlGenerator", ";", "}", "public", "void", "setFindSqlGenerator", "(", "FindSqlGenerator", "findSqlGenerator", ")", "{", "this", ".", "findSqlGenerator", "=", "findSqlGenerator", ";", "}", "public", "QueryAnalysis", "getQueryAnalysis", "(", ")", "{", "return", "queryAnalysis", ";", "}", "public", "void", "setQueryAnalysis", "(", "QueryAnalysis", "queryAnalysis", ")", "{", "this", ".", "queryAnalysis", "=", "queryAnalysis", ";", "}", "public", "ListCorpusByNameDaoHelper", "getListCorpusByNameDaoHelper", "(", ")", "{", "return", "listCorpusByNameDaoHelper", ";", "}", "public", "void", "setListCorpusByNameDaoHelper", "(", "ListCorpusByNameDaoHelper", "listCorpusByNameDaoHelper", ")", "{", "this", ".", "listCorpusByNameDaoHelper", "=", "listCorpusByNameDaoHelper", ";", "}", "public", "CountExtractor", "getCountExtractor", "(", ")", "{", "return", "countExtractor", ";", "}", "public", "void", "setCountExtractor", "(", "CountExtractor", "countExtractor", ")", "{", "this", ".", "countExtractor", "=", "countExtractor", ";", "}", "public", "AnnotateSqlGenerator", "getGraphExtractor", "(", ")", "{", "return", "graphExtractor", ";", "}", "public", "void", "setGraphExtractor", "(", "AnnotateSqlGenerator", "graphExtractor", ")", "{", "this", ".", "graphExtractor", "=", "graphExtractor", ";", "}", "public", "MetaDataFilter", "getMetaDataFilter", "(", ")", "{", "return", "metaDataFilter", ";", "}", "public", "void", "setMetaDataFilter", "(", "MetaDataFilter", "metaDataFilter", ")", "{", "this", ".", "metaDataFilter", "=", "metaDataFilter", ";", "}", "public", "CountSqlGenerator", "getCountSqlGenerator", "(", ")", "{", "return", "countSqlGenerator", ";", "}", "public", "void", "setCountSqlGenerator", "(", "CountSqlGenerator", "countSqlGenerator", ")", "{", "this", ".", "countSqlGenerator", "=", "countSqlGenerator", ";", "}", "@", "Override", "public", "HashMap", "<", "Long", ",", "Properties", ">", "getCorpusConfiguration", "(", ")", "{", "return", "corpusConfiguration", ";", "}", "@", "Override", "public", "void", "setCorpusConfiguration", "(", "HashMap", "<", "Long", ",", "Properties", ">", "corpusConfiguration", ")", "{", "this", ".", "corpusConfiguration", "=", "corpusConfiguration", ";", "}", "@", "Override", "public", "int", "getTimeout", "(", ")", "{", "return", "timeout", ";", "}", "@", "Override", "public", "void", "setTimeout", "(", "int", "timeout", ")", "{", "this", ".", "timeout", "=", "timeout", ";", "}", "public", "MatrixSqlGenerator", "getMatrixSqlGenerator", "(", ")", "{", "return", "matrixSqlGenerator", ";", "}", "public", "void", "setMatrixSqlGenerator", "(", "MatrixSqlGenerator", "matrixSqlGenerator", ")", "{", "this", ".", "matrixSqlGenerator", "=", "matrixSqlGenerator", ";", "}", "public", "SaltAnnotateExtractor", "getSaltAnnotateExtractor", "(", ")", "{", "return", "saltAnnotateExtractor", ";", "}", "public", "void", "setSaltAnnotateExtractor", "(", "SaltAnnotateExtractor", "saltAnnotateExtractor", ")", "{", "this", ".", "saltAnnotateExtractor", "=", "saltAnnotateExtractor", ";", "}", "public", "ByteHelper", "getByteHelper", "(", ")", "{", "return", "byteHelper", ";", "}", "public", "void", "setByteHelper", "(", "ByteHelper", "byteHelper", ")", "{", "this", ".", "byteHelper", "=", "byteHelper", ";", "}", "@", "Override", "public", "AnnisBinary", "getBinary", "(", "String", "toplevelCorpusName", ",", "String", "corpusName", ",", "int", "offset", ",", "int", "length", ")", "{", "return", "(", "AnnisBinary", ")", "getJdbcTemplate", "(", ")", ".", "query", "(", "ByteHelper", ".", "SQL", ",", "byteHelper", ".", "getArgs", "(", "toplevelCorpusName", ",", "corpusName", ",", "offset", ",", "length", ")", ",", "ByteHelper", ".", "getArgTypes", "(", ")", ",", "byteHelper", ")", ";", "}", "public", "AnnotateSqlGenerator", "<", "SaltProject", ">", "getAnnotateSqlGenerator", "(", ")", "{", "return", "annotateSqlGenerator", ";", "}", "public", "void", "setAnnotateSqlGenerator", "(", "AnnotateSqlGenerator", "<", "SaltProject", ">", "annotateSqlGenerator", ")", "{", "this", ".", "annotateSqlGenerator", "=", "annotateSqlGenerator", ";", "}", "}", "</s>" ]
8,775
[ "<s>", "package", "annis", ".", "dao", ";", "import", "java", ".", "sql", ".", "ResultSet", ";", "@", "Deprecated", "public", "interface", "ResultSetConverter", "<", "T", ">", "{", "public", "T", "convertResultSet", "(", "ResultSet", "resultSet", ")", ";", "}", "</s>" ]
8,776
[ "<s>", "package", "annis", ".", "dao", ";", "import", "annis", ".", "administration", ".", "AdministrationDao", ";", "import", "org", ".", "springframework", ".", "jdbc", ".", "core", ".", "JdbcTemplate", ";", "import", "annis", ".", "ql", ".", "parser", ".", "QueryData", ";", "public", "class", "ScriptFileSqlSessionModifier", "implements", "SqlSessionModifier", "{", "private", "String", "scriptFile", ";", "private", "AdministrationDao", "administrationDao", ";", "public", "void", "modifySqlSession", "(", "JdbcTemplate", "jdbcTemplate", ",", "QueryData", "queryData", ")", "{", "administrationDao", ".", "executeSqlFromScript", "(", "scriptFile", ")", ";", "}", "public", "String", "getScriptFile", "(", ")", "{", "return", "scriptFile", ";", "}", "public", "void", "setScriptFile", "(", "String", "scriptFile", ")", "{", "this", ".", "scriptFile", "=", "scriptFile", ";", "}", "public", "AdministrationDao", "getAdministrationDao", "(", ")", "{", "return", "administrationDao", ";", "}", "public", "void", "setAdministrationDao", "(", "AdministrationDao", "administrationDao", ")", "{", "this", ".", "administrationDao", "=", "administrationDao", ";", "}", "}", "</s>" ]
8,777
[ "<s>", "package", "annis", ".", "dao", ";", "import", "org", ".", "springframework", ".", "jdbc", ".", "core", ".", "JdbcTemplate", ";", "import", "annis", ".", "ql", ".", "parser", ".", "QueryData", ";", "public", "class", "TimeOutSqlSessionModifier", "implements", "SqlSessionModifier", "{", "private", "int", "timeout", ";", "public", "void", "modifySqlSession", "(", "JdbcTemplate", "jdbcTemplate", ",", "QueryData", "queryData", ")", "{", "if", "(", "timeout", ">", "0", ")", "jdbcTemplate", ".", "update", "(", "\"\"", "+", "timeout", ")", ";", "}", "public", "int", "getTimeout", "(", ")", "{", "return", "timeout", ";", "}", "public", "void", "setTimeout", "(", "int", "timeout", ")", "{", "this", ".", "timeout", "=", "timeout", ";", "}", "}", "</s>" ]
8,778
[ "<s>", "package", "annis", ".", "dao", ";", "import", "java", ".", "util", ".", "List", ";", "import", "annis", ".", "model", ".", "Annotation", ";", "import", "annis", ".", "sqlgen", ".", "NodeSqlAdapter", ";", "public", "interface", "CorpusSelectionStrategy", "{", "boolean", "usesViews", "(", ")", ";", "void", "registerNodeAdapter", "(", "NodeSqlAdapter", "adapter", ")", ";", "String", "createViewSql", "(", ")", ";", "String", "whereClauseForNode", "(", "String", "docRefColumn", ")", ";", "String", "viewName", "(", "String", "table", ")", ";", "void", "addMetaAnnotations", "(", "List", "<", "Annotation", ">", "annotations", ")", ";", "}", "</s>" ]
8,779
[ "<s>", "package", "annis", ";", "import", "org", ".", "slf4j", ".", "Logger", ";", "import", "org", ".", "slf4j", ".", "LoggerFactory", ";", "public", "class", "MemoryUsage", "{", "private", "static", "final", "Logger", "log", "=", "LoggerFactory", ".", "getLogger", "(", "MemoryUsage", ".", "class", ")", ";", "public", "static", "void", "logMemoryUsage", "(", ")", "{", "Runtime", "runtime", "=", "Runtime", ".", "getRuntime", "(", ")", ";", "String", "total", "=", "String", ".", "valueOf", "(", "runtime", ".", "totalMemory", "(", ")", "/", "1024", ")", "+", "\"k\"", ";", "String", "free", "=", "String", ".", "valueOf", "(", "runtime", ".", "freeMemory", "(", ")", "/", "1024", ")", "+", "\"k\"", ";", "String", "max", "=", "String", ".", "valueOf", "(", "runtime", ".", "maxMemory", "(", ")", "/", "1024", ")", "+", "\"k\"", ";", "log", ".", "debug", "(", "\"total:", "\"", "+", "total", "+", "\";", "free:", "\"", "+", "free", "+", "\";", "max:", "\"", "+", "max", ")", ";", "}", "}", "</s>" ]
8,780
[ "<s>", "package", "annis", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "util", ".", "Collections", ";", "import", "java", ".", "util", ".", "Date", ";", "import", "java", ".", "util", ".", "LinkedList", ";", "import", "java", ".", "util", ".", "Set", ";", "import", "org", ".", "apache", ".", "commons", ".", "lang3", ".", "StringUtils", ";", "import", "org", ".", "apache", ".", "commons", ".", "lang3", ".", "Validate", ";", "import", "annis", ".", "dao", ".", "AnnisDao", ";", "import", "annis", ".", "dao", ".", "AnnotatedMatch", ";", "import", "annis", ".", "service", ".", "objects", ".", "Match", ";", "import", "annis", ".", "dao", ".", "MetaDataFilter", ";", "import", "annis", ".", "model", ".", "Annotation", ";", "import", "annis", ".", "model", ".", "QueryAnnotation", ";", "import", "annis", ".", "model", ".", "QueryNode", ";", "import", "annis", ".", "ql", ".", "parser", ".", "AnnisParser", ";", "import", "annis", ".", "ql", ".", "parser", ".", "QueryAnalysis", ";", "import", "annis", ".", "ql", ".", "parser", ".", "QueryData", ";", "import", "annis", ".", "service", ".", "objects", ".", "AnnisAttribute", ";", "import", "annis", ".", "service", ".", "objects", ".", "AnnisCorpus", ";", "import", "annis", ".", "sqlgen", ".", "*", ";", "import", "annis", ".", "sqlgen", ".", "AnnotateQueryData", ";", "import", "annis", ".", "sqlgen", ".", "AnnotateSqlGenerator", ";", "import", "annis", ".", "sqlgen", ".", "LimitOffsetQueryData", ";", "import", "annis", ".", "sqlgen", ".", "SqlGenerator", ";", "import", "annis", ".", "utils", ".", "Utils", ";", "import", "au", ".", "com", ".", "bytecode", ".", "opencsv", ".", "CSVWriter", ";", "import", "de", ".", "hu_berlin", ".", "german", ".", "korpling", ".", "saltnpepper", ".", "salt", ".", "saltCommon", ".", "SaltProject", ";", "import", "de", ".", "hu_berlin", ".", "german", ".", "korpling", ".", "saltnpepper", ".", "salt", ".", "saltCommon", ".", "sCorpusStructure", ".", "SCorpusGraph", ";", "import", "de", ".", "hu_berlin", ".", "german", ".", "korpling", ".", "saltnpepper", ".", "salt", ".", "saltCommon", ".", "sCorpusStructure", ".", "SDocument", ";", "import", "java", ".", "io", ".", "*", ";", "import", "java", ".", "net", ".", "URISyntaxException", ";", "import", "java", ".", "util", ".", "List", ";", "import", "java", ".", "util", ".", "TreeSet", ";", "import", "javax", ".", "xml", ".", "bind", ".", "JAXBContext", ";", "import", "javax", ".", "xml", ".", "bind", ".", "JAXBException", ";", "import", "org", ".", "apache", ".", "commons", ".", "io", ".", "output", ".", "FileWriterWithEncoding", ";", "import", "org", ".", "codehaus", ".", "jackson", ".", "map", ".", "AnnotationIntrospector", ";", "import", "org", ".", "codehaus", ".", "jackson", ".", "map", ".", "DeserializationConfig", ";", "import", "org", ".", "codehaus", ".", "jackson", ".", "map", ".", "ObjectMapper", ";", "import", "org", ".", "codehaus", ".", "jackson", ".", "map", ".", "SerializationConfig", ";", "import", "org", ".", "codehaus", ".", "jackson", ".", "xc", ".", "JaxbAnnotationIntrospector", ";", "import", "org", ".", "eclipse", ".", "emf", ".", "common", ".", "util", ".", "URI", ";", "import", "org", ".", "eclipse", ".", "emf", ".", "ecore", ".", "resource", ".", "Resource", ";", "import", "org", ".", "eclipse", ".", "emf", ".", "ecore", ".", "xmi", ".", "impl", ".", "XMIResourceImpl", ";", "import", "org", ".", "slf4j", ".", "Logger", ";", "import", "org", ".", "slf4j", ".", "LoggerFactory", ";", "public", "class", "AnnisRunner", "extends", "AnnisBaseRunner", "{", "private", "static", "final", "Logger", "log", "=", "LoggerFactory", ".", "getLogger", "(", "AnnisRunner", ".", "class", ")", ";", "private", "SqlGenerator", "<", "QueryData", ",", "List", "<", "Match", ">", ">", "findSqlGenerator", ";", "private", "SqlGenerator", "<", "QueryData", ",", "Integer", ">", "countSqlGenerator", ";", "private", "AnnotateSqlGenerator", "<", "SaltProject", ">", "annotateSqlGenerator", ";", "private", "SqlGenerator", "<", "QueryData", ",", "List", "<", "AnnotatedMatch", ">", ">", "matrixSqlGenerator", ";", "private", "AnnotateSqlGenerator", "graphSqlGenerator", ";", "private", "AnnisDao", "annisDao", ";", "private", "AnnisParser", "annisParser", ";", "private", "QueryAnalysis", "aqlAnalysis", ";", "private", "int", "context", ";", "private", "int", "matchLimit", ";", "private", "QueryAnalysis", "queryAnalysis", ";", "private", "int", "limit", "=", "10", ";", "private", "int", "offset", ";", "private", "int", "left", "=", "5", ";", "private", "int", "right", "=", "5", ";", "private", "String", "segmentationLayer", "=", "null", ";", "private", "List", "<", "Long", ">", "corpusList", ";", "private", "boolean", "clearCaches", ";", "private", "MetaDataFilter", "metaDataFilter", ";", "public", "AnnotateSqlGenerator", "getGraphSqlGenerator", "(", ")", "{", "return", "graphSqlGenerator", ";", "}", "public", "void", "setGraphSqlGenerator", "(", "AnnotateSqlGenerator", "graphSqlGenerator", ")", "{", "this", ".", "graphSqlGenerator", "=", "graphSqlGenerator", ";", "}", "public", "enum", "OS", "{", "linux", ",", "other", "}", "private", "static", "class", "Benchmark", "{", "private", "String", "functionCall", ";", "private", "QueryData", "queryData", ";", "private", "long", "avgTimeInMilliseconds", ";", "private", "long", "bestTimeInMilliseconds", ";", "private", "long", "worstTimeInMilliseconds", ";", "private", "String", "sql", ";", "private", "String", "plan", ";", "private", "int", "runs", ";", "private", "int", "errors", ";", "public", "Benchmark", "(", "String", "functionCall", ",", "QueryData", "queryData", ")", "{", "super", "(", ")", ";", "this", ".", "functionCall", "=", "functionCall", ";", "this", ".", "queryData", "=", "queryData", ";", "}", "}", "private", "List", "<", "AnnisRunner", ".", "Benchmark", ">", "benchmarks", ";", "private", "static", "final", "int", "SEQUENTIAL_RUNS", "=", "5", ";", "public", "static", "void", "main", "(", "String", "[", "]", "args", ")", "{", "String", "path", "=", "Utils", ".", "getAnnisFile", "(", "\"\"", ")", ".", "getAbsolutePath", "(", ")", ";", "AnnisBaseRunner", ".", "getInstance", "(", "\"annisRunner\"", ",", "\"file:\"", "+", "path", ")", ".", "run", "(", "args", ")", ";", "}", "public", "AnnisRunner", "(", ")", "{", "corpusList", "=", "new", "LinkedList", "<", "Long", ">", "(", ")", ";", "benchmarks", "=", "new", "ArrayList", "<", "AnnisRunner", ".", "Benchmark", ">", "(", ")", ";", "}", "public", "void", "doDebug", "(", "String", "ignore", ")", "{", "doDoc", "(", "\"\"", ")", ";", "}", "public", "void", "doParse", "(", "String", "annisQuery", ")", "{", "out", ".", "println", "(", "annisParser", ".", "dumpTree", "(", "annisQuery", ")", ")", ";", "}", "public", "void", "doSql", "(", "String", "funcCall", ")", "{", "String", "doSqlFunctionName", "=", "\"sql_\"", "+", "funcCall", ".", "split", "(", "\"\\\\s\"", ",", "2", ")", "[", "0", "]", ";", "SqlGenerator", "<", "QueryData", ",", "?", ">", "gen", "=", "getGeneratorForQueryFunction", "(", "funcCall", ")", ";", "String", "annisQuery", "=", "getAnnisQueryFromFunctionCall", "(", "funcCall", ")", ";", "QueryData", "queryData", "=", "analyzeQuery", "(", "annisQuery", ",", "doSqlFunctionName", ")", ";", "out", ".", "println", "(", "\"\"", "+", "left", "+", "\";", "right", "=", "\"", "+", "right", "+", "\";", "limit", "=", "\"", "+", "limit", "+", "\";", "offset", "=", "\"", "+", "offset", ")", ";", "out", ".", "println", "(", "gen", ".", "toSql", "(", "queryData", ")", ")", ";", "}", "public", "void", "doExplain", "(", "String", "functionCall", ",", "boolean", "analyze", ")", "{", "SqlGenerator", "<", "QueryData", ",", "?", ">", "generator", "=", "getGeneratorForQueryFunction", "(", "functionCall", ")", ";", "String", "function", "=", "getAnnisQueryFromFunctionCall", "(", "functionCall", ")", ";", "String", "annisQuery", "=", "getAnnisQueryFromFunctionCall", "(", "functionCall", ")", ";", "QueryData", "queryData", "=", "analyzeQuery", "(", "annisQuery", ",", "function", ")", ";", "out", ".", "println", "(", "\"\"", "+", "left", "+", "\";", "right", "=", "\"", "+", "right", "+", "\";", "limit", "=", "\"", "+", "limit", "+", "\";", "offset", "=", "\"", "+", "offset", ")", ";", "out", ".", "println", "(", "annisDao", ".", "explain", "(", "generator", ",", "queryData", ",", "analyze", ")", ")", ";", "}", "public", "void", "doPlan", "(", "String", "functionCall", ")", "{", "doExplain", "(", "functionCall", ",", "false", ")", ";", "}", "public", "void", "doAnalyze", "(", "String", "functionCall", ")", "{", "doExplain", "(", "functionCall", ",", "true", ")", ";", "}", "private", "SqlGenerator", "<", "QueryData", ",", "?", ">", "getGeneratorForQueryFunction", "(", "String", "funcCall", ")", "{", "String", "[", "]", "split", "=", "funcCall", ".", "split", "(", "\"", "\"", ",", "2", ")", ";", "Validate", ".", "isTrue", "(", "split", ".", "length", "==", "2", ",", "\"\"", ")", ";", "String", "function", "=", "split", "[", "0", "]", ";", "SqlGenerator", "<", "QueryData", ",", "?", ">", "generator", "=", "null", ";", "if", "(", "\"count\"", ".", "equals", "(", "function", ")", ")", "{", "generator", "=", "countSqlGenerator", ";", "}", "else", "if", "(", "\"find\"", ".", "equals", "(", "function", ")", ")", "{", "generator", "=", "findSqlGenerator", ";", "}", "else", "if", "(", "\"annotate\"", ".", "equals", "(", "function", ")", ")", "{", "generator", "=", "annotateSqlGenerator", ";", "}", "else", "if", "(", "\"matrix\"", ".", "equals", "(", "function", ")", ")", "{", "generator", "=", "matrixSqlGenerator", ";", "}", "else", "if", "(", "\"subgraph\"", ".", "equals", "(", "function", ")", ")", "{", "generator", "=", "getGraphSqlGenerator", "(", ")", ";", "}", "Validate", ".", "notNull", "(", "generator", ",", "\"\"", "+", "function", ")", ";", "return", "generator", ";", "}", "private", "String", "getAnnisQueryFromFunctionCall", "(", "String", "functionCall", ")", "{", "String", "[", "]", "split", "=", "functionCall", ".", "split", "(", "\"", "\"", ",", "2", ")", ";", "Validate", ".", "isTrue", "(", "split", ".", "length", "==", "2", ",", "\"\"", ")", ";", "return", "split", "[", "1", "]", ";", "}", "public", "void", "doRecord", "(", "String", "dummy", ")", "{", "out", ".", "println", "(", "\"\"", ")", ";", "benchmarks", ".", "clear", "(", ")", ";", "}", "public", "void", "doBenchmark", "(", "String", "benchmarkCount", ")", "{", "int", "count", "=", "Integer", ".", "parseInt", "(", "benchmarkCount", ")", ";", "out", ".", "println", "(", "\"\"", "+", "benchmarks", ".", "size", "(", ")", "+", "\"", "queries", "\"", "+", "count", "+", "\"", "times\"", ")", ";", "AnnisRunner", ".", "OS", "currentOS", "=", "AnnisRunner", ".", "OS", ".", "other", ";", "try", "{", "currentOS", "=", "AnnisRunner", ".", "OS", ".", "valueOf", "(", "System", ".", "getProperty", "(", "\"os.name\"", ")", ".", "toLowerCase", "(", ")", ")", ";", "}", "catch", "(", "IllegalArgumentException", "ex", ")", "{", "}", "List", "<", "AnnisRunner", ".", "Benchmark", ">", "session", "=", "new", "ArrayList", "<", "AnnisRunner", ".", "Benchmark", ">", "(", ")", ";", "for", "(", "AnnisRunner", ".", "Benchmark", "benchmark", ":", "benchmarks", ")", "{", "if", "(", "clearCaches", ")", "{", "resetCaches", "(", "currentOS", ")", ";", "}", "SqlGenerator", "<", "QueryData", ",", "?", ">", "generator", "=", "getGeneratorForQueryFunction", "(", "benchmark", ".", "functionCall", ")", ";", "benchmark", ".", "sql", "=", "getGeneratorForQueryFunction", "(", "benchmark", ".", "functionCall", ")", ".", "toSql", "(", "benchmark", ".", "queryData", ")", ";", "out", ".", "println", "(", "\"\"", "+", "benchmark", ".", "functionCall", ")", ";", "out", ".", "println", "(", "benchmark", ".", "sql", ")", ";", "try", "{", "benchmark", ".", "plan", "=", "annisDao", ".", "explain", "(", "generator", ",", "benchmark", ".", "queryData", ",", "false", ")", ";", "out", ".", "println", "(", "\"\"", "+", "benchmark", ".", "functionCall", ")", ";", "out", ".", "println", "(", "benchmark", ".", "plan", ")", ";", "}", "catch", "(", "RuntimeException", "e", ")", "{", "out", ".", "println", "(", "\"\"", "+", "benchmark", ".", "functionCall", ")", ";", "}", "benchmark", ".", "bestTimeInMilliseconds", "=", "Long", ".", "MAX_VALUE", ";", "benchmark", ".", "worstTimeInMilliseconds", "=", "Long", ".", "MIN_VALUE", ";", "out", ".", "println", "(", "\"\"", "+", "SEQUENTIAL_RUNS", "+", "\"", "times\"", ")", ";", "String", "options", "=", "benchmarkOptions", "(", "benchmark", ".", "queryData", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "SEQUENTIAL_RUNS", ";", "++", "i", ")", "{", "if", "(", "i", ">", "0", ")", "{", "out", ".", "print", "(", "\",", "\"", ")", ";", "}", "long", "start", "=", "new", "Date", "(", ")", ".", "getTime", "(", ")", ";", "try", "{", "annisDao", ".", "executeQueryFunction", "(", "benchmark", ".", "queryData", ",", "generator", ")", ";", "}", "catch", "(", "RuntimeException", "e", ")", "{", "}", "long", "end", "=", "new", "Date", "(", ")", ".", "getTime", "(", ")", ";", "long", "runtime", "=", "end", "-", "start", ";", "benchmark", ".", "bestTimeInMilliseconds", "=", "Math", ".", "min", "(", "benchmark", ".", "bestTimeInMilliseconds", ",", "runtime", ")", ";", "benchmark", ".", "worstTimeInMilliseconds", "=", "Math", ".", "max", "(", "benchmark", ".", "worstTimeInMilliseconds", ",", "runtime", ")", ";", "out", ".", "print", "(", "runtime", "+", "\"", "ms\"", ")", ";", "}", "out", ".", "println", "(", ")", ";", "out", ".", "println", "(", "benchmark", ".", "bestTimeInMilliseconds", "+", "\"\"", "+", "benchmark", ".", "functionCall", "+", "(", "\"\"", ".", "equals", "(", "options", ")", "?", "\"'\"", ":", "\"'", "with", "\"", "+", "options", ")", ")", ";", "session", ".", "addAll", "(", "Collections", ".", "nCopies", "(", "count", ",", "benchmark", ")", ")", ";", "}", "if", "(", "clearCaches", ")", "{", "resetCaches", "(", "currentOS", ")", ";", "}", "Collections", ".", "shuffle", "(", "session", ")", ";", "out", ".", "println", "(", ")", ";", "out", ".", "println", "(", "\"\"", ")", ";", "for", "(", "AnnisRunner", ".", "Benchmark", "benchmark", ":", "session", ")", "{", "if", "(", "benchmark", ".", "errors", ">=", "3", ")", "{", "continue", ";", "}", "boolean", "error", "=", "false", ";", "SqlGenerator", "<", "QueryData", ",", "?", ">", "generator", "=", "getGeneratorForQueryFunction", "(", "benchmark", ".", "functionCall", ")", ";", "long", "start", "=", "new", "Date", "(", ")", ".", "getTime", "(", ")", ";", "try", "{", "annisDao", ".", "executeQueryFunction", "(", "benchmark", ".", "queryData", ",", "generator", ")", ";", "}", "catch", "(", "RuntimeException", "e", ")", "{", "error", "=", "true", ";", "}", "long", "end", "=", "new", "Date", "(", ")", ".", "getTime", "(", ")", ";", "long", "runtime", "=", "end", "-", "start", ";", "benchmark", ".", "avgTimeInMilliseconds", "+=", "runtime", ";", "++", "benchmark", ".", "runs", ";", "if", "(", "error", ")", "{", "++", "benchmark", ".", "errors", ";", "}", "String", "options", "=", "benchmarkOptions", "(", "benchmark", ".", "queryData", ")", ";", "out", ".", "println", "(", "runtime", "+", "\"", "ms", "for", "'\"", "+", "benchmark", ".", "functionCall", "+", "(", "\"\"", ".", "equals", "(", "options", ")", "?", "\"'\"", ":", "\"'", "with", "\"", "+", "options", ")", "+", "(", "error", "?", "\"", "ERROR\"", ":", "\"\"", ")", ")", ";", "}", "out", ".", "println", "(", ")", ";", "out", ".", "println", "(", "\"\"", ")", ";", "for", "(", "AnnisRunner", ".", "Benchmark", "benchmark", ":", "benchmarks", ")", "{", "benchmark", ".", "avgTimeInMilliseconds", "=", "Math", ".", "round", "(", "(", "double", ")", "benchmark", ".", "avgTimeInMilliseconds", "/", "(", "double", ")", "benchmark", ".", "runs", ")", ";", "String", "options", "=", "benchmarkOptions", "(", "benchmark", ".", "queryData", ")", ";", "out", ".", "println", "(", "benchmark", ".", "avgTimeInMilliseconds", "+", "\"\"", "+", "benchmark", ".", "runs", "+", "\"", "runs\"", "+", "(", "benchmark", ".", "errors", ">", "0", "?", "\",", "\"", "+", "benchmark", ".", "errors", "+", "\"", "errors)\"", ":", "\")\"", ")", "+", "\"", "for", "'\"", "+", "benchmark", ".", "functionCall", "+", "(", "\"\"", ".", "equals", "(", "options", ")", "?", "\"'\"", ":", "\"'", "with", "\"", "+", "options", ")", ")", ";", "}", "out", ".", "println", "(", ")", ";", "out", ".", "println", "(", "\"\"", ")", ";", "for", "(", "AnnisRunner", ".", "Benchmark", "benchmark", ":", "benchmarks", ")", "{", "String", "options", "=", "benchmarkOptions", "(", "benchmark", ".", "queryData", ")", ";", "out", ".", "println", "(", "benchmark", ".", "worstTimeInMilliseconds", "+", "\"", "ms", "(\"", "+", "(", "benchmark", ".", "errors", ">", "0", "?", "\"?\"", "+", "benchmark", ".", "errors", "+", "\"", "errors)\"", ":", "\")\"", ")", "+", "\"", "for", "'\"", "+", "benchmark", ".", "functionCall", "+", "(", "\"\"", ".", "equals", "(", "options", ")", "?", "\"'\"", ":", "\"'", "with", "\"", "+", "options", ")", ")", ";", "}", "out", ".", "println", "(", ")", ";", "out", ".", "println", "(", "\"\"", ")", ";", "for", "(", "AnnisRunner", ".", "Benchmark", "benchmark", ":", "benchmarks", ")", "{", "String", "options", "=", "benchmarkOptions", "(", "benchmark", ".", "queryData", ")", ";", "out", ".", "println", "(", "benchmark", ".", "bestTimeInMilliseconds", "+", "\"", "ms", "(\"", "+", "(", "benchmark", ".", "errors", ">", "0", "?", "\"?\"", "+", "benchmark", ".", "errors", "+", "\"", "errors)\"", ":", "\")\"", ")", "+", "\"", "for", "'\"", "+", "benchmark", ".", "functionCall", "+", "(", "\"\"", ".", "equals", "(", "options", ")", "?", "\"'\"", ":", "\"'", "with", "\"", "+", "options", ")", ")", ";", "}", "out", ".", "println", "(", ")", ";", "try", "{", "CSVWriter", "csv", "=", "new", "CSVWriter", "(", "new", "FileWriterWithEncoding", "(", "new", "File", "(", "\"\"", ")", ",", "\"UTF-8\"", ")", ")", ";", "String", "[", "]", "header", "=", "new", "String", "[", "]", "{", "\"corpora\"", ",", "\"query\"", ",", "\"avg\"", ",", "\"diff-best\"", ",", "\"diff-worst\"", "}", ";", "csv", ".", "writeNext", "(", "header", ")", ";", "for", "(", "AnnisRunner", ".", "Benchmark", "benchmark", ":", "benchmarks", ")", "{", "String", "[", "]", "line", "=", "new", "String", "[", "5", "]", ";", "line", "[", "0", "]", "=", "StringUtils", ".", "join", "(", "benchmark", ".", "queryData", ".", "getCorpusList", "(", ")", ",", "\",\"", ")", ";", "line", "[", "1", "]", "=", "benchmark", ".", "functionCall", ";", "line", "[", "2", "]", "=", "\"\"", "+", "benchmark", ".", "avgTimeInMilliseconds", ";", "line", "[", "3", "]", "=", "\"\"", "+", "Math", ".", "abs", "(", "benchmark", ".", "bestTimeInMilliseconds", "-", "benchmark", ".", "avgTimeInMilliseconds", ")", ";", "line", "[", "4", "]", "=", "\"\"", "+", "Math", ".", "abs", "(", "benchmark", ".", "avgTimeInMilliseconds", "-", "benchmark", ".", "worstTimeInMilliseconds", ")", ";", "csv", ".", "writeNext", "(", "line", ")", ";", "}", "csv", ".", "close", "(", ")", ";", "}", "catch", "(", "IOException", "ex", ")", "{", "log", ".", "error", "(", "null", ",", "ex", ")", ";", "}", "}", "public", "String", "benchmarkOptions", "(", "QueryData", "queryData", ")", "{", "List", "<", "Long", ">", "corpusList", "=", "queryData", ".", "getCorpusList", "(", ")", ";", "List", "<", "QueryAnnotation", ">", "metaData", "=", "queryData", ".", "getMetaData", "(", ")", ";", "Set", "<", "Object", ">", "extensions", "=", "queryData", ".", "getExtensions", "(", ")", ";", "List", "<", "String", ">", "fields", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "if", "(", "!", "corpusList", ".", "isEmpty", "(", ")", ")", "{", "fields", ".", "add", "(", "\"corpus", "=", "\"", "+", "corpusList", ")", ";", "}", "if", "(", "!", "metaData", ".", "isEmpty", "(", ")", ")", "{", "fields", ".", "add", "(", "\"meta", "=", "\"", "+", "metaData", ")", ";", "}", "for", "(", "Object", "extension", ":", "extensions", ")", "{", "String", "toString", "=", "extension", ".", "toString", "(", ")", ";", "if", "(", "!", "\"\"", ".", "equals", "(", "toString", ")", ")", "{", "fields", ".", "add", "(", "toString", ")", ";", "}", "}", "return", "StringUtils", ".", "join", "(", "fields", ",", "\",", "\"", ")", ";", "}", "private", "void", "resetCaches", "(", "AnnisRunner", ".", "OS", "currentOS", ")", "{", "switch", "(", "currentOS", ")", "{", "case", "linux", ":", "try", "{", "log", ".", "info", "(", "\"\"", ")", ";", "log", ".", "debug", "(", "\"syncing\"", ")", ";", "Runtime", ".", "getRuntime", "(", ")", ".", "exec", "(", "\"sync\"", ")", ".", "waitFor", "(", ")", ";", "File", "dropCaches", "=", "new", "File", "(", "\"\"", ")", ";", "if", "(", "dropCaches", ".", "canWrite", "(", ")", ")", "{", "log", ".", "debug", "(", "\"\"", ")", ";", "Writer", "w", "=", "new", "FileWriterWithEncoding", "(", "dropCaches", ",", "\"UTF-8\"", ")", ";", "w", ".", "write", "(", "\"3\"", ")", ";", "w", ".", "close", "(", ")", ";", "}", "else", "{", "log", ".", "warn", "(", "\"\"", ")", ";", "}", "File", "postgresScript", "=", "new", "File", "(", "\"\"", ")", ";", "if", "(", "postgresScript", ".", "exists", "(", ")", "&&", "postgresScript", ".", "isFile", "(", ")", ")", "{", "log", ".", "debug", "(", "\"\"", ")", ";", "Runtime", ".", "getRuntime", "(", ")", ".", "exec", "(", "postgresScript", ".", "getAbsolutePath", "(", ")", "+", "\"", "restart\"", ")", ".", "waitFor", "(", ")", ";", "}", "else", "{", "log", ".", "warn", "(", "\"\"", ")", ";", "}", "}", "catch", "(", "Exception", "ex", ")", "{", "log", ".", "error", "(", "null", ",", "ex", ")", ";", "}", "break", ";", "default", ":", "log", ".", "warn", "(", "\"\"", ")", ";", "}", "}", "public", "void", "doSet", "(", "String", "callToSet", ")", "{", "String", "[", "]", "split", "=", "callToSet", ".", "split", "(", "\"", "\"", ",", "3", ")", ";", "Validate", ".", "isTrue", "(", "split", ".", "length", ">", "0", ",", "\"\"", "+", "callToSet", ")", ";", "String", "setting", "=", "split", "[", "0", "]", ";", "String", "value", "=", "null", ";", "boolean", "show", "=", "split", ".", "length", "==", "1", "&&", "setting", ".", "startsWith", "(", "\"?\"", ")", ";", "if", "(", "show", ")", "{", "setting", "=", "setting", ".", "substring", "(", "1", ")", ";", "}", "else", "{", "Validate", ".", "isTrue", "(", "split", ".", "length", "==", "3", "&&", "\"TO\"", ".", "toLowerCase", "(", ")", ".", "equals", "(", "split", "[", "1", "]", ")", ",", "\"\"", "+", "callToSet", ")", ";", "value", "=", "split", "[", "2", "]", ";", "}", "if", "(", "\"limit\"", ".", "equals", "(", "setting", ")", ")", "{", "if", "(", "show", ")", "{", "value", "=", "String", ".", "valueOf", "(", "limit", ")", ";", "}", "else", "{", "limit", "=", "Integer", ".", "parseInt", "(", "value", ")", ";", "}", "}", "else", "if", "(", "\"offset\"", ".", "equals", "(", "setting", ")", ")", "{", "if", "(", "show", ")", "{", "value", "=", "String", ".", "valueOf", "(", "offset", ")", ";", "}", "else", "{", "offset", "=", "Integer", ".", "parseInt", "(", "value", ")", ";", "}", "}", "else", "if", "(", "\"left\"", ".", "equals", "(", "setting", ")", ")", "{", "if", "(", "show", ")", "{", "value", "=", "String", ".", "valueOf", "(", "left", ")", ";", "}", "else", "{", "left", "=", "Integer", ".", "parseInt", "(", "value", ")", ";", "}", "}", "else", "if", "(", "\"right\"", ".", "equals", "(", "setting", ")", ")", "{", "if", "(", "show", ")", "{", "value", "=", "String", ".", "valueOf", "(", "right", ")", ";", "}", "else", "{", "right", "=", "Integer", ".", "parseInt", "(", "value", ")", ";", "}", "}", "else", "if", "(", "\"context\"", ".", "equals", "(", "setting", ")", ")", "{", "if", "(", "show", ")", "{", "if", "(", "left", "!=", "right", ")", "{", "value", "=", "\"\"", ";", "}", "else", "{", "value", "=", "String", ".", "valueOf", "(", "left", ")", ";", "}", "}", "else", "{", "left", "=", "Integer", ".", "parseInt", "(", "value", ")", ";", "right", "=", "left", ";", "}", "}", "else", "if", "(", "\"timeout\"", ".", "equals", "(", "setting", ")", ")", "{", "if", "(", "show", ")", "{", "value", "=", "String", ".", "valueOf", "(", "annisDao", ".", "getTimeout", "(", ")", ")", ";", "}", "else", "{", "annisDao", ".", "setTimeout", "(", "Integer", ".", "parseInt", "(", "value", ")", ")", ";", "}", "}", "else", "if", "(", "\"clear-caches\"", ".", "equals", "(", "setting", ")", ")", "{", "if", "(", "show", ")", "{", "value", "=", "String", ".", "valueOf", "(", "clearCaches", ")", ";", "}", "else", "{", "clearCaches", "=", "Boolean", ".", "parseBoolean", "(", "value", ")", ";", "}", "}", "else", "if", "(", "\"corpus-list\"", ".", "equals", "(", "setting", ")", ")", "{", "corpusList", ".", "clear", "(", ")", ";", "if", "(", "!", "\"all\"", ".", "equals", "(", "value", ")", ")", "{", "String", "[", "]", "list", "=", "value", ".", "split", "(", "\"", "\"", ")", ";", "for", "(", "String", "corpus", ":", "list", ")", "{", "corpusList", ".", "add", "(", "Long", ".", "parseLong", "(", "corpus", ")", ")", ";", "}", "}", "}", "else", "if", "(", "\"seg\"", ".", "equals", "(", "setting", ")", ")", "{", "if", "(", "show", ")", "{", "value", "=", "segmentationLayer", ";", "}", "else", "{", "segmentationLayer", "=", "value", ";", "}", "}", "else", "{", "out", ".", "println", "(", "\"\"", "+", "setting", ")", ";", "}", "out", ".", "println", "(", "setting", "+", "\":", "\"", "+", "value", ")", ";", "}", "public", "void", "doShow", "(", "String", "setting", ")", "{", "doSet", "(", "\"?\"", "+", "setting", ")", ";", "}", "private", "QueryData", "analyzeQuery", "(", "String", "annisQuery", ",", "String", "queryFunction", ")", "{", "QueryData", "queryData", ";", "log", ".", "debug", "(", "\"\"", "+", "queryFunction", "+", "\"", "function\"", ")", ";", "if", "(", "queryFunction", "!=", "null", "&&", "!", "queryFunction", ".", "matches", "(", "\"\"", ")", ")", "{", "queryData", "=", "annisDao", ".", "parseAQL", "(", "annisQuery", ",", "corpusList", ")", ";", "}", "else", "{", "queryData", "=", "extractSaltIds", "(", "annisQuery", ")", ";", "}", "queryData", ".", "setCorpusConfiguration", "(", "annisDao", ".", "getCorpusConfiguration", "(", ")", ")", ";", "queryData", ".", "setDocuments", "(", "metaDataFilter", ".", "getDocumentsForMetadata", "(", "queryData", ")", ")", ";", "if", "(", "queryFunction", "!=", "null", "&&", "queryFunction", ".", "matches", "(", "\"\"", ")", ")", "{", "queryData", ".", "addExtension", "(", "new", "AnnotateQueryData", "(", "left", ",", "right", ",", "segmentationLayer", ")", ")", ";", "queryData", ".", "addExtension", "(", "new", "LimitOffsetQueryData", "(", "offset", ",", "limit", ")", ")", ";", "}", "else", "if", "(", "queryFunction", "!=", "null", "&&", "queryFunction", ".", "matches", "(", "\"\"", ")", ")", "{", "queryData", ".", "addExtension", "(", "new", "AnnotateQueryData", "(", "left", ",", "right", ",", "segmentationLayer", ")", ")", ";", "}", "if", "(", "annisQuery", "!=", "null", ")", "{", "benchmarks", ".", "add", "(", "new", "AnnisRunner", ".", "Benchmark", "(", "queryFunction", "+", "\"", "\"", "+", "annisQuery", ",", "queryData", ")", ")", ";", "}", "out", ".", "println", "(", "\"\"", "+", "queryData", ".", "getCorpusList", "(", ")", ")", ";", "return", "queryData", ";", "}", "public", "void", "doCount", "(", "String", "annisQuery", ")", "{", "out", ".", "println", "(", "annisDao", ".", "count", "(", "analyzeQuery", "(", "annisQuery", ",", "\"count\"", ")", ")", ")", ";", "}", "public", "void", "doMatrix", "(", "String", "annisQuery", ")", "{", "List", "<", "AnnotatedMatch", ">", "matches", "=", "annisDao", ".", "matrix", "(", "analyzeQuery", "(", "annisQuery", ",", "\"matrix\"", ")", ")", ";", "if", "(", "matches", ".", "isEmpty", "(", ")", ")", "{", "out", ".", "println", "(", "\"(empty\"", ")", ";", "}", "else", "{", "WekaHelper", "helper", "=", "new", "WekaHelper", "(", ")", ";", "out", ".", "println", "(", "helper", ".", "exportAsArff", "(", "matches", ")", ")", ";", "}", "}", "public", "void", "doFind", "(", "String", "annisQuery", ")", "{", "List", "<", "Match", ">", "matches", "=", "annisDao", ".", "find", "(", "analyzeQuery", "(", "annisQuery", ",", "\"find\"", ")", ")", ";", "JAXBContext", "jc", "=", "null", ";", "try", "{", "jc", "=", "JAXBContext", ".", "newInstance", "(", "annis", ".", "service", ".", "objects", ".", "Match", ".", "class", ")", ";", "}", "catch", "(", "JAXBException", "ex", ")", "{", "log", ".", "error", "(", "\"\"", ",", "ex", ")", ";", "}", "for", "(", "int", "i", "=", "0", ";", "i", "<", "matches", ".", "size", "(", ")", ";", "i", "++", ")", "{", "try", "{", "jc", ".", "createMarshaller", "(", ")", ".", "marshal", "(", "matches", ".", "get", "(", "i", ")", ",", "out", ")", ";", "}", "catch", "(", "JAXBException", "ex", ")", "{", "log", ".", "error", "(", "\"\"", ",", "ex", ")", ";", "}", "out", ".", "println", "(", ")", ";", "}", "}", "public", "void", "doSubgraph", "(", "String", "saltIds", ")", "{", "QueryData", "queryData", "=", "analyzeQuery", "(", "saltIds", ",", "\"subgraph\"", ")", ";", "out", ".", "println", "(", "\"\"", "+", "left", "+", "\";", "right", "=", "\"", "+", "right", "+", "\";", "limit", "=", "\"", "+", "limit", "+", "\";", "offset", "=", "\"", "+", "offset", ")", ";", "SaltProject", "result", "=", "annisDao", ".", "graph", "(", "queryData", ")", ";", "URI", "path", "=", "URI", ".", "createFileURI", "(", "\"\"", ")", ";", "result", ".", "saveSaltProject_DOT", "(", "path", ")", ";", "System", ".", "out", ".", "println", "(", "\"\"", ")", ";", "}", "public", "void", "doAnnotate", "(", "String", "annisQuery", ")", "{", "QueryData", "queryData", "=", "analyzeQuery", "(", "annisQuery", ",", "\"annotate\"", ")", ";", "out", ".", "println", "(", "\"\"", "+", "left", "+", "\";", "right", "=", "\"", "+", "right", "+", "\";", "limit", "=", "\"", "+", "limit", "+", "\";", "offset", "=", "\"", "+", "offset", ")", ";", "SaltProject", "result", "=", "annisDao", ".", "annotate", "(", "queryData", ")", ";", "URI", "uri", "=", "URI", ".", "createFileURI", "(", "\"\"", ")", ";", "result", ".", "saveSaltProject_DOT", "(", "uri", ")", ";", "System", ".", "out", ".", "println", "(", "\"\"", ")", ";", "}", "public", "void", "doCorpus", "(", "String", "list", ")", "{", "corpusList", "=", "new", "LinkedList", "<", "Long", ">", "(", ")", ";", "String", "[", "]", "splits", "=", "StringUtils", ".", "split", "(", "list", ",", "\"", "\"", ")", ";", "for", "(", "String", "split", ":", "splits", ")", "{", "try", "{", "corpusList", ".", "add", "(", "Long", ".", "parseLong", "(", "split", ")", ")", ";", "}", "catch", "(", "NumberFormatException", "e", ")", "{", "LinkedList", "<", "String", ">", "splitList", "=", "new", "LinkedList", "<", "String", ">", "(", ")", ";", "splitList", ".", "add", "(", "split", ")", ";", "corpusList", ".", "addAll", "(", "annisDao", ".", "mapCorpusNamesToIds", "(", "splitList", ")", ")", ";", "}", "}", "if", "(", "corpusList", ".", "isEmpty", "(", ")", ")", "{", "setPrompt", "(", "\"no", "corpus>\"", ")", ";", "}", "else", "{", "setPrompt", "(", "StringUtils", ".", "join", "(", "corpusList", ",", "\",\"", ")", "+", "\">\"", ")", ";", "}", "}", "public", "void", "doList", "(", "String", "unused", ")", "{", "List", "<", "AnnisCorpus", ">", "corpora", "=", "annisDao", ".", "listCorpora", "(", ")", ";", "printAsTable", "(", "corpora", ",", "\"id\"", ",", "\"name\"", ",", "\"textCount\"", ",", "\"tokenCount\"", ")", ";", "}", "public", "void", "doAnnotations", "(", "String", "doListValues", ")", "{", "boolean", "listValues", "=", "\"values\"", ".", "equals", "(", "doListValues", ")", ";", "List", "<", "AnnisAttribute", ">", "annotations", "=", "annisDao", ".", "listAnnotations", "(", "getCorpusList", "(", ")", ",", "listValues", ",", "true", ")", ";", "try", "{", "ObjectMapper", "om", "=", "new", "ObjectMapper", "(", ")", ";", "AnnotationIntrospector", "ai", "=", "new", "JaxbAnnotationIntrospector", "(", ")", ";", "DeserializationConfig", "config", "=", "om", ".", "getDeserializationConfig", "(", ")", ".", "withAnnotationIntrospector", "(", "ai", ")", ";", "om", ".", "setDeserializationConfig", "(", "config", ")", ";", "om", ".", "configure", "(", "SerializationConfig", ".", "Feature", ".", "INDENT_OUTPUT", ",", "true", ")", ";", "System", ".", "out", ".", "println", "(", "om", ".", "writeValueAsString", "(", "annotations", ")", ")", ";", "}", "catch", "(", "IOException", "ex", ")", "{", "log", ".", "error", "(", "\"\"", ",", "ex", ")", ";", "}", "}", "public", "void", "doMeta", "(", "String", "corpusId", ")", "{", "LinkedList", "<", "Long", ">", "corpusIdAsList", "=", "new", "LinkedList", "<", "Long", ">", "(", ")", ";", "try", "{", "corpusIdAsList", ".", "add", "(", "Long", ".", "parseLong", "(", "corpusId", ")", ")", ";", "List", "<", "String", ">", "toplevelNames", "=", "annisDao", ".", "mapCorpusIdsToNames", "(", "corpusIdAsList", ")", ";", "List", "<", "Annotation", ">", "corpusAnnotations", "=", "annisDao", ".", "listCorpusAnnotations", "(", "toplevelNames", ".", "get", "(", "0", ")", ")", ";", "printAsTable", "(", "corpusAnnotations", ",", "\"namespace\"", ",", "\"name\"", ",", "\"value\"", ")", ";", "}", "catch", "(", "NumberFormatException", "ex", ")", "{", "System", ".", "out", ".", "print", "(", "\"\"", "+", "corpusId", ")", ";", "}", "}", "public", "void", "doSqlText", "(", "String", "textID", ")", "{", "long", "l", "=", "Long", ".", "parseLong", "(", "textID", ")", ";", "System", ".", "out", ".", "println", "(", "annotateSqlGenerator", ".", "getTextQuery", "(", "l", ")", ")", ";", "}", "public", "void", "doText", "(", "String", "textID", ")", "{", "SaltProject", "p", "=", "annisDao", ".", "retrieveAnnotationGraph", "(", "Long", ".", "parseLong", "(", "textID", ")", ")", ";", "System", ".", "out", ".", "println", "(", "printSaltAsXMI", "(", "p", ")", ")", ";", "}", "public", "void", "doSqlDoc", "(", "String", "docCall", ")", "{", "String", "[", "]", "splitted", "=", "docCall", ".", "split", "(", "\"(", ")+\"", ")", ";", "Validate", ".", "isTrue", "(", "splitted", ".", "length", ">", "1", ",", "\"\"", ")", ";", "System", ".", "out", ".", "println", "(", "annotateSqlGenerator", ".", "getDocumentQuery", "(", "splitted", "[", "0", "]", ",", "splitted", "[", "1", "]", ")", ")", ";", "}", "public", "void", "doDoc", "(", "String", "docCall", ")", "{", "String", "[", "]", "splitted", "=", "docCall", ".", "split", "(", "\"(", ")+\"", ")", ";", "Validate", ".", "isTrue", "(", "splitted", ".", "length", ">", "1", ",", "\"\"", ")", ";", "SaltProject", "p", "=", "annisDao", ".", "retrieveAnnotationGraph", "(", "splitted", "[", "0", "]", ",", "splitted", "[", "1", "]", ")", ";", "System", ".", "out", ".", "println", "(", "printSaltAsXMI", "(", "p", ")", ")", ";", "}", "public", "void", "doQuit", "(", "String", "dummy", ")", "{", "System", ".", "out", ".", "println", "(", "\"bye", "bye!\"", ")", ";", "System", ".", "exit", "(", "0", ")", ";", "}", "private", "void", "printAsTable", "(", "List", "<", "?", "extends", "Object", ">", "list", ",", "String", "...", "fields", ")", "{", "out", ".", "println", "(", "new", "TableFormatter", "(", ")", ".", "formatAsTable", "(", "list", ",", "fields", ")", ")", ";", "}", "private", "QueryData", "parse", "(", "String", "input", ")", "{", "return", "annisDao", ".", "parseAQL", "(", "input", ",", "getCorpusList", "(", ")", ")", ";", "}", "private", "String", "printSaltAsXMI", "(", "SaltProject", "project", ")", "{", "try", "{", "Resource", "resource", "=", "new", "XMIResourceImpl", "(", ")", ";", "resource", ".", "getContents", "(", ")", ".", "add", "(", "project", ")", ";", "for", "(", "SCorpusGraph", "corpusGraph", ":", "project", ".", "getSCorpusGraphs", "(", ")", ")", "{", "for", "(", "SDocument", "doc", ":", "corpusGraph", ".", "getSDocuments", "(", ")", ")", "{", "if", "(", "doc", ".", "getSDocumentGraph", "(", ")", "!=", "null", ")", "{", "resource", ".", "getContents", "(", ")", ".", "add", "(", "doc", ".", "getSDocumentGraph", "(", ")", ")", ";", "}", "}", "}", "ByteArrayOutputStream", "outStream", "=", "new", "ByteArrayOutputStream", "(", ")", ";", "resource", ".", "save", "(", "outStream", ",", "null", ")", ";", "return", "new", "String", "(", "outStream", ".", "toByteArray", "(", ")", ",", "\"UTF-8\"", ")", ";", "}", "catch", "(", "IOException", "ex", ")", "{", "log", ".", "error", "(", "null", ",", "ex", ")", ";", "}", "return", "\"\"", ";", "}", "public", "AnnisParser", "getAnnisParser", "(", ")", "{", "return", "annisParser", ";", "}", "public", "void", "setAnnisParser", "(", "AnnisParser", "annisParser", ")", "{", "this", ".", "annisParser", "=", "annisParser", ";", "}", "public", "AnnisDao", "getAnnisDao", "(", ")", "{", "return", "annisDao", ";", "}", "public", "void", "setAnnisDao", "(", "AnnisDao", "annisDao", ")", "{", "this", ".", "annisDao", "=", "annisDao", ";", "}", "public", "QueryAnalysis", "getAqlAnalysis", "(", ")", "{", "return", "aqlAnalysis", ";", "}", "public", "void", "setAqlAnalysis", "(", "QueryAnalysis", "aqlAnalysis", ")", "{", "this", ".", "aqlAnalysis", "=", "aqlAnalysis", ";", "}", "public", "List", "<", "Long", ">", "getCorpusList", "(", ")", "{", "return", "corpusList", ";", "}", "public", "void", "setCorpusList", "(", "List", "<", "Long", ">", "corpusList", ")", "{", "this", ".", "corpusList", "=", "corpusList", ";", "}", "public", "int", "getContext", "(", ")", "{", "return", "context", ";", "}", "public", "void", "setContext", "(", "int", "context", ")", "{", "this", ".", "context", "=", "context", ";", "}", "public", "int", "getMatchLimit", "(", ")", "{", "return", "matchLimit", ";", "}", "public", "void", "setMatchLimit", "(", "int", "matchLimit", ")", "{", "this", ".", "matchLimit", "=", "matchLimit", ";", "}", "public", "QueryAnalysis", "getQueryAnalysis", "(", ")", "{", "return", "queryAnalysis", ";", "}", "public", "void", "setQueryAnalysis", "(", "QueryAnalysis", "queryAnalysis", ")", "{", "this", ".", "queryAnalysis", "=", "queryAnalysis", ";", "}", "public", "SqlGenerator", "<", "QueryData", ",", "Integer", ">", "getCountSqlGenerator", "(", ")", "{", "return", "countSqlGenerator", ";", "}", "public", "void", "setCountSqlGenerator", "(", "SqlGenerator", "<", "QueryData", ",", "Integer", ">", "countSqlGenerator", ")", "{", "this", ".", "countSqlGenerator", "=", "countSqlGenerator", ";", "}", "public", "AnnotateSqlGenerator", "<", "SaltProject", ">", "getAnnotateSqlGenerator", "(", ")", "{", "return", "annotateSqlGenerator", ";", "}", "public", "void", "setAnnotateSqlGenerator", "(", "AnnotateSqlGenerator", "<", "SaltProject", ">", "annotateSqlGenerator", ")", "{", "this", ".", "annotateSqlGenerator", "=", "annotateSqlGenerator", ";", "}", "public", "SqlGenerator", "<", "QueryData", ",", "List", "<", "Match", ">", ">", "getFindSqlGenerator", "(", ")", "{", "return", "findSqlGenerator", ";", "}", "public", "void", "setFindSqlGenerator", "(", "SqlGenerator", "<", "QueryData", ",", "List", "<", "Match", ">", ">", "findSqlGenerator", ")", "{", "this", ".", "findSqlGenerator", "=", "findSqlGenerator", ";", "}", "public", "SqlGenerator", "<", "QueryData", ",", "List", "<", "AnnotatedMatch", ">", ">", "getMatrixSqlGenerator", "(", ")", "{", "return", "matrixSqlGenerator", ";", "}", "public", "void", "setMatrixSqlGenerator", "(", "SqlGenerator", "<", "QueryData", ",", "List", "<", "AnnotatedMatch", ">", ">", "matrixSqlGenerator", ")", "{", "this", ".", "matrixSqlGenerator", "=", "matrixSqlGenerator", ";", "}", "public", "MetaDataFilter", "getMetaDataFilter", "(", ")", "{", "return", "metaDataFilter", ";", "}", "public", "void", "setMetaDataFilter", "(", "MetaDataFilter", "metaDataFilter", ")", "{", "this", ".", "metaDataFilter", "=", "metaDataFilter", ";", "}", "private", "QueryData", "extractSaltIds", "(", "String", "saltIds", ")", "{", "QueryData", "queryData", "=", "new", "QueryData", "(", ")", ";", "SaltURIs", "uris", "=", "new", "SaltURIs", "(", ")", ";", "for", "(", "String", "id", ":", "saltIds", ".", "split", "(", "\"\\\\s\"", ")", ")", "{", "java", ".", "net", ".", "URI", "uri", ";", "try", "{", "uri", "=", "new", "java", ".", "net", ".", "URI", "(", "id", ")", ";", "if", "(", "!", "\"salt\"", ".", "equals", "(", "uri", ".", "getScheme", "(", ")", ")", "||", "uri", ".", "getFragment", "(", ")", "==", "null", ")", "{", "throw", "new", "URISyntaxException", "(", "\"\"", ",", "uri", ".", "toString", "(", ")", ")", ";", "}", "}", "catch", "(", "URISyntaxException", "ex", ")", "{", "log", ".", "error", "(", "null", ",", "ex", ")", ";", "continue", ";", "}", "uris", ".", "add", "(", "uri", ")", ";", "}", "Set", "<", "String", ">", "corpusNames", "=", "new", "TreeSet", "<", "String", ">", "(", ")", ";", "List", "<", "QueryNode", ">", "pseudoNodes", "=", "new", "ArrayList", "<", "QueryNode", ">", "(", "uris", ".", "size", "(", ")", ")", ";", "for", "(", "java", ".", "net", ".", "URI", "u", ":", "uris", ")", "{", "pseudoNodes", ".", "add", "(", "new", "QueryNode", "(", ")", ")", ";", "corpusNames", ".", "add", "(", "CommonHelper", ".", "getCorpusPath", "(", "u", ")", ".", "get", "(", "0", ")", ")", ";", "}", "List", "<", "Long", ">", "corpusIDs", "=", "annisDao", ".", "mapCorpusNamesToIds", "(", "new", "LinkedList", "<", "String", ">", "(", "corpusNames", ")", ")", ";", "queryData", ".", "setCorpusList", "(", "corpusIDs", ")", ";", "queryData", ".", "addAlternative", "(", "pseudoNodes", ")", ";", "log", ".", "debug", "(", "uris", ".", "toString", "(", ")", ")", ";", "queryData", ".", "addExtension", "(", "uris", ")", ";", "return", "queryData", ";", "}", "}", "</s>" ]
8,781
[ "<s>", "package", "annis", ";", "import", "annis", ".", "dao", ".", "AnnotatedMatch", ";", "import", "annis", ".", "dao", ".", "AnnotatedSpan", ";", "import", "annis", ".", "model", ".", "Annotation", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "util", ".", "HashMap", ";", "import", "java", ".", "util", ".", "List", ";", "import", "java", ".", "util", ".", "Map", ";", "import", "java", ".", "util", ".", "SortedMap", ";", "import", "java", ".", "util", ".", "SortedSet", ";", "import", "java", ".", "util", ".", "TreeMap", ";", "import", "java", ".", "util", ".", "TreeSet", ";", "import", "org", ".", "apache", ".", "commons", ".", "lang3", ".", "StringUtils", ";", "public", "class", "WekaHelper", "{", "public", "static", "String", "exportAsArff", "(", "List", "<", "AnnotatedMatch", ">", "annotatedMatches", ")", "{", "StringBuilder", "sb", "=", "new", "StringBuilder", "(", ")", ";", "sb", ".", "append", "(", "\"\"", ")", ";", "sb", ".", "append", "(", "\"n\"", ")", ";", "SortedMap", "<", "Integer", ",", "SortedSet", "<", "String", ">", ">", "columnsByNodePos", "=", "new", "TreeMap", "<", "Integer", ",", "SortedSet", "<", "String", ">", ">", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "annotatedMatches", ".", "size", "(", ")", ";", "++", "i", ")", "{", "AnnotatedMatch", "match", "=", "annotatedMatches", ".", "get", "(", "i", ")", ";", "for", "(", "int", "j", "=", "0", ";", "j", "<", "match", ".", "size", "(", ")", ";", "++", "j", ")", "{", "AnnotatedSpan", "span", "=", "match", ".", "get", "(", "j", ")", ";", "if", "(", "columnsByNodePos", ".", "get", "(", "j", ")", "==", "null", ")", "{", "columnsByNodePos", ".", "put", "(", "j", ",", "new", "TreeSet", "<", "String", ">", "(", ")", ")", ";", "}", "for", "(", "Annotation", "annotation", ":", "span", ".", "getAnnotations", "(", ")", ")", "{", "columnsByNodePos", ".", "get", "(", "j", ")", ".", "add", "(", "\"anno_\"", "+", "annotation", ".", "getQualifiedName", "(", ")", ")", ";", "}", "for", "(", "Annotation", "meta", ":", "span", ".", "getMetadata", "(", ")", ")", "{", "columnsByNodePos", ".", "get", "(", "j", ")", ".", "add", "(", "\"meta_\"", "+", "meta", ".", "getQualifiedName", "(", ")", ")", ";", "}", "}", "}", "int", "count", "=", "columnsByNodePos", ".", "keySet", "(", ")", ".", "size", "(", ")", ";", "for", "(", "int", "j", "=", "0", ";", "j", "<", "count", ";", "++", "j", ")", "{", "sb", ".", "append", "(", "\"@attribute", "\"", ")", ".", "append", "(", "fullColumnName", "(", "j", "+", "1", ",", "\"id\"", ")", ")", ".", "append", "(", "\"", "stringn\"", ")", ";", "sb", ".", "append", "(", "\"@attribute", "\"", ")", ".", "append", "(", "fullColumnName", "(", "j", "+", "1", ",", "\"span\"", ")", ")", ".", "append", "(", "\"", "stringn\"", ")", ";", "SortedSet", "<", "String", ">", "annotationNames", "=", "columnsByNodePos", ".", "get", "(", "j", ")", ";", "for", "(", "String", "name", ":", "annotationNames", ")", "{", "sb", ".", "append", "(", "\"@attribute", "\"", ")", ".", "append", "(", "fullColumnName", "(", "j", "+", "1", ",", "name", ")", ")", ".", "append", "(", "\"", "stringn\"", ")", ";", "}", "}", "sb", ".", "append", "(", "\"n@datann\"", ")", ";", "for", "(", "AnnotatedMatch", "match", ":", "annotatedMatches", ")", "{", "List", "<", "String", ">", "line", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "int", "k", "=", "0", ";", "for", "(", ";", "k", "<", "match", ".", "size", "(", ")", ";", "++", "k", ")", "{", "AnnotatedSpan", "span", "=", "match", ".", "get", "(", "k", ")", ";", "Map", "<", "String", ",", "String", ">", "valueByName", "=", "new", "HashMap", "<", "String", ",", "String", ">", "(", ")", ";", "if", "(", "span", "!=", "null", ")", "{", "if", "(", "span", ".", "getAnnotations", "(", ")", "!=", "null", ")", "{", "for", "(", "Annotation", "annotation", ":", "span", ".", "getAnnotations", "(", ")", ")", "{", "valueByName", ".", "put", "(", "\"anno_\"", "+", "annotation", ".", "getQualifiedName", "(", ")", ",", "annotation", ".", "getValue", "(", ")", ")", ";", "}", "}", "if", "(", "span", ".", "getMetadata", "(", ")", "!=", "null", ")", "{", "for", "(", "Annotation", "meta", ":", "span", ".", "getMetadata", "(", ")", ")", "{", "valueByName", ".", "put", "(", "\"meta_\"", "+", "meta", ".", "getQualifiedName", "(", ")", ",", "meta", ".", "getValue", "(", ")", ")", ";", "}", "}", "line", ".", "add", "(", "\"'\"", "+", "span", ".", "getId", "(", ")", "+", "\"'\"", ")", ";", "line", ".", "add", "(", "\"'\"", "+", "span", ".", "getCoveredText", "(", ")", ".", "replace", "(", "\"'\"", ",", "\"\\\\'\"", ")", "+", "\"'\"", ")", ";", "}", "for", "(", "String", "name", ":", "columnsByNodePos", ".", "get", "(", "k", ")", ")", "{", "if", "(", "valueByName", ".", "containsKey", "(", "name", ")", ")", "{", "line", ".", "add", "(", "\"'\"", "+", "valueByName", ".", "get", "(", "name", ")", ".", "replace", "(", "\"'\"", ",", "\"\\\\'\"", ")", "+", "\"'\"", ")", ";", "}", "else", "{", "line", ".", "add", "(", "\"'NULL'\"", ")", ";", "}", "}", "}", "for", "(", "int", "l", "=", "k", ";", "l", "<", "count", ";", "++", "l", ")", "{", "line", ".", "add", "(", "\"'NULL'\"", ")", ";", "for", "(", "int", "m", "=", "0", ";", "m", "<=", "columnsByNodePos", ".", "get", "(", "l", ")", ".", "size", "(", ")", ";", "++", "m", ")", "{", "line", ".", "add", "(", "\"'NULL'\"", ")", ";", "}", "}", "sb", ".", "append", "(", "StringUtils", ".", "join", "(", "line", ",", "\",\"", ")", ")", ";", "sb", ".", "append", "(", "\"n\"", ")", ";", "}", "return", "sb", ".", "toString", "(", ")", ";", "}", "private", "static", "String", "fullColumnName", "(", "int", "i", ",", "String", "name", ")", "{", "return", "\"#\"", "+", "i", "+", "\"_\"", "+", "name", ";", "}", "}", "</s>" ]
8,782
[ "<s>", "package", "annis", ".", "sqlgen", ";", "import", "java", ".", "sql", ".", "ResultSet", ";", "import", "java", ".", "util", ".", "List", ";", "public", "interface", "SolutionKey", "<", "KeyType", ">", "{", "public", "abstract", "List", "<", "String", ">", "generateInnerQueryColumns", "(", "TableAccessStrategy", "tableAccessStrategy", ",", "int", "index", ")", ";", "public", "abstract", "List", "<", "String", ">", "generateOuterQueryColumns", "(", "TableAccessStrategy", "tableAccessStrategy", ",", "int", "size", ")", ";", "public", "abstract", "KeyType", "retrieveKey", "(", "ResultSet", "resultSet", ")", ";", "public", "abstract", "boolean", "isNewKey", "(", ")", ";", "public", "abstract", "Integer", "getMatchedNodeIndex", "(", "Object", "id", ")", ";", "public", "abstract", "List", "<", "String", ">", "getKeyColumns", "(", "int", "size", ")", ";", "public", "abstract", "Object", "getNodeId", "(", "ResultSet", "resultSet", ",", "TableAccessStrategy", "tableAccessStrategy", ")", ";", "public", "abstract", "int", "getKeySize", "(", ")", ";", "public", "abstract", "String", "getCurrentKeyAsString", "(", ")", ";", "}", "</s>" ]
8,783
[ "<s>", "package", "annis", ".", "sqlgen", ";", "import", "static", "annis", ".", "sqlgen", ".", "SqlConstraints", ".", "in", ";", "import", "static", "annis", ".", "sqlgen", ".", "TableAccessStrategy", ".", "NODE_TABLE", ";", "import", "static", "annis", ".", "sqlgen", ".", "TableAccessStrategy", ".", "RANK_TABLE", ";", "import", "java", ".", "util", ".", "HashSet", ";", "import", "java", ".", "util", ".", "List", ";", "import", "java", ".", "util", ".", "Set", ";", "import", "annis", ".", "model", ".", "QueryNode", ";", "import", "annis", ".", "ql", ".", "parser", ".", "QueryData", ";", "import", "java", ".", "util", ".", "LinkedList", ";", "public", "class", "MetaDataAndCorpusWhereClauseGenerator", "extends", "TableAccessStrategyFactory", "implements", "WhereClauseSqlGenerator", "<", "QueryData", ">", "{", "@", "Override", "public", "Set", "<", "String", ">", "whereConditions", "(", "QueryData", "queryData", ",", "List", "<", "QueryNode", ">", "alternative", ",", "String", "indent", ")", "{", "Set", "<", "String", ">", "conditions", "=", "new", "HashSet", "<", "String", ">", "(", ")", ";", "List", "<", "Long", ">", "corpusList", "=", "queryData", ".", "getCorpusList", "(", ")", ";", "List", "<", "Long", ">", "documents", "=", "queryData", ".", "getDocuments", "(", ")", ";", "if", "(", "documents", "==", "null", "&&", "corpusList", "==", "null", ")", "{", "return", "new", "HashSet", "<", "String", ">", "(", ")", ";", "}", "for", "(", "QueryNode", "node", ":", "alternative", ")", "{", "if", "(", "documents", "!=", "null", ")", "{", "List", "<", "String", ">", "emptyList", "=", "new", "LinkedList", "<", "String", ">", "(", ")", ";", "emptyList", ".", "add", "(", "\"NULL\"", ")", ";", "conditions", ".", "add", "(", "in", "(", "tables", "(", "node", ")", ".", "aliasedColumn", "(", "NODE_TABLE", ",", "\"corpus_ref\"", ")", ",", "documents", ".", "isEmpty", "(", ")", "?", "emptyList", ":", "documents", ")", ")", ";", "}", "if", "(", "corpusList", "!=", "null", "&&", "!", "corpusList", ".", "isEmpty", "(", ")", ")", "{", "conditions", ".", "add", "(", "in", "(", "tables", "(", "node", ")", ".", "aliasedColumn", "(", "NODE_TABLE", ",", "\"\"", ")", ",", "corpusList", ")", ")", ";", "if", "(", "tables", "(", "node", ")", ".", "usesRankTable", "(", ")", "&&", "!", "tables", "(", "node", ")", ".", "isMaterialized", "(", "RANK_TABLE", ",", "NODE_TABLE", ")", ")", "{", "conditions", ".", "add", "(", "in", "(", "tables", "(", "node", ")", ".", "aliasedColumn", "(", "RANK_TABLE", ",", "\"\"", ")", ",", "corpusList", ")", ")", ";", "}", "}", "}", "return", "conditions", ";", "}", "}", "</s>" ]
8,784
[ "<s>", "package", "annis", ".", "sqlgen", ";", "import", "java", ".", "sql", ".", "ResultSet", ";", "import", "java", ".", "sql", ".", "SQLException", ";", "import", "java", ".", "util", ".", "List", ";", "public", "interface", "CorpusPathExtractor", "{", "public", "List", "<", "String", ">", "extractCorpusPath", "(", "ResultSet", "resultSet", ",", "String", "columnName", ")", "throws", "SQLException", ";", "}", "</s>" ]
8,785
[ "<s>", "package", "annis", ".", "sqlgen", ";", "import", "annis", ".", "service", ".", "objects", ".", "AnnisBinary", ";", "import", "java", ".", "sql", ".", "ResultSet", ";", "import", "java", ".", "sql", ".", "SQLException", ";", "import", "java", ".", "sql", ".", "Types", ";", "import", "java", ".", "util", ".", "Arrays", ";", "import", "org", ".", "slf4j", ".", "LoggerFactory", ";", "import", "org", ".", "springframework", ".", "dao", ".", "DataAccessException", ";", "import", "org", ".", "springframework", ".", "jdbc", ".", "core", ".", "ResultSetExtractor", ";", "public", "class", "ByteHelper", "implements", "ResultSetExtractor", "<", "AnnisBinary", ">", "{", "private", "static", "final", "org", ".", "slf4j", ".", "Logger", "log", "=", "LoggerFactory", ".", "getLogger", "(", "ByteHelper", ".", "class", ")", ";", "private", "static", "final", "int", "[", "]", "ARG_TYPES", "=", "new", "int", "[", "]", "{", "Types", ".", "INTEGER", ",", "Types", ".", "INTEGER", ",", "Types", ".", "VARCHAR", ",", "Types", ".", "VARCHAR", "}", ";", "public", "static", "final", "String", "SQL", "=", "\"SELECTn\"", "+", "\"\"", "+", "\"\"", "+", "\"\"", "+", "\"WHEREn\"", "+", "\"\"", "+", "\"\"", "+", "\"\"", "+", "\"\"", "+", "\"\"", ";", ";", "public", "static", "int", "[", "]", "getArgTypes", "(", ")", "{", "return", "Arrays", ".", "copyOf", "(", "ARG_TYPES", ",", "ARG_TYPES", ".", "length", ")", ";", "}", "public", "Object", "[", "]", "getArgs", "(", "String", "toplevelCorpusName", ",", "String", "corpusName", ",", "int", "offset", ",", "int", "length", ")", "{", "return", "new", "Object", "[", "]", "{", "offset", ",", "length", ",", "toplevelCorpusName", ",", "corpusName", "}", ";", "}", "@", "Override", "public", "AnnisBinary", "extractData", "(", "ResultSet", "rs", ")", "throws", "DataAccessException", "{", "AnnisBinary", "ab", "=", "new", "AnnisBinary", "(", ")", ";", "try", "{", "while", "(", "rs", ".", "next", "(", ")", ")", "{", "ab", ".", "setBytes", "(", "rs", ".", "getBytes", "(", "\"partfile\"", ")", ")", ";", "ab", ".", "setFileName", "(", "rs", ".", "getString", "(", "\"title\"", ")", ")", ";", "ab", ".", "setCorpusName", "(", "rs", ".", "getString", "(", "\"corpus_name\"", ")", ")", ";", "ab", ".", "setMimeType", "(", "rs", ".", "getString", "(", "\"mime_type\"", ")", ")", ";", "ab", ".", "setLength", "(", "rs", ".", "getInt", "(", "\"bytes\"", ")", ")", ";", "break", ";", "}", "}", "catch", "(", "SQLException", "ex", ")", "{", "log", ".", "error", "(", "null", ",", "ex", ")", ";", "}", "return", "ab", ";", "}", "}", "</s>" ]
8,786
[ "<s>", "package", "annis", ".", "sqlgen", ";", "import", "org", ".", "springframework", ".", "jdbc", ".", "core", ".", "ResultSetExtractor", ";", "public", "interface", "SqlGenerator", "<", "QueryType", ",", "ResultType", ">", "extends", "ResultSetExtractor", "<", "ResultType", ">", "{", "String", "toSql", "(", "QueryType", "queryData", ")", ";", "String", "toSql", "(", "QueryType", "queryData", ",", "String", "indent", ")", ";", "}", "</s>" ]
8,787
[ "<s>", "package", "annis", ".", "sqlgen", ";", "import", "static", "annis", ".", "sqlgen", ".", "SqlConstraints", ".", "bitSelect", ";", "import", "static", "annis", ".", "sqlgen", ".", "SqlConstraints", ".", "join", ";", "import", "static", "annis", ".", "sqlgen", ".", "SqlConstraints", ".", "isTrue", ";", "import", "static", "annis", ".", "sqlgen", ".", "TableAccessStrategy", ".", "NODE_TABLE", ";", "import", "static", "annis", ".", "sqlgen", ".", "TableAccessStrategy", ".", "COMPONENT_TABLE", ";", "import", "static", "annis", ".", "sqlgen", ".", "TableAccessStrategy", ".", "EDGE_ANNOTATION_TABLE", ";", "import", "static", "annis", ".", "sqlgen", ".", "TableAccessStrategy", ".", "RANK_TABLE", ";", "import", "static", "annis", ".", "sqlgen", ".", "TableAccessStrategy", ".", "NODE_ANNOTATION_TABLE", ";", "import", "static", "annis", ".", "sqlgen", ".", "TableAccessStrategy", ".", "FACTS_TABLE", ";", "import", "annis", ".", "model", ".", "QueryNode", ";", "import", "annis", ".", "ql", ".", "parser", ".", "QueryData", ";", "import", "java", ".", "util", ".", "HashSet", ";", "import", "java", ".", "util", ".", "LinkedList", ";", "import", "java", ".", "util", ".", "List", ";", "import", "java", ".", "util", ".", "Set", ";", "public", "class", "SampleWhereClause", "extends", "TableAccessStrategyFactory", "implements", "WhereClauseSqlGenerator", "<", "QueryData", ">", "{", "@", "Override", "public", "Set", "<", "String", ">", "whereConditions", "(", "QueryData", "queryData", ",", "List", "<", "QueryNode", ">", "alternative", ",", "String", "indent", ")", "{", "Set", "<", "String", ">", "conditions", "=", "new", "HashSet", "<", "String", ">", "(", ")", ";", "List", "<", "Long", ">", "corpusList", "=", "queryData", ".", "getCorpusList", "(", ")", ";", "List", "<", "Long", ">", "documents", "=", "queryData", ".", "getDocuments", "(", ")", ";", "for", "(", "QueryNode", "node", ":", "alternative", ")", "{", "conditions", ".", "addAll", "(", "whereConditions", "(", "node", ",", "corpusList", ",", "documents", ")", ")", ";", "}", "return", "conditions", ";", "}", "@", "Deprecated", "public", "List", "<", "String", ">", "whereConditions", "(", "QueryNode", "node", ",", "List", "<", "Long", ">", "corpusList", ",", "List", "<", "Long", ">", "documents", ")", "{", "LinkedList", "<", "String", ">", "conditions", "=", "new", "LinkedList", "<", "String", ">", "(", ")", ";", "TableAccessStrategy", "t", "=", "tables", "(", "node", ")", ";", "if", "(", "t", ".", "isMaterialized", "(", "NODE_TABLE", ",", "FACTS_TABLE", ")", "&&", "t", ".", "isMaterialized", "(", "NODE_ANNOTATION_TABLE", ",", "FACTS_TABLE", ")", "&&", "t", ".", "isMaterialized", "(", "EDGE_ANNOTATION_TABLE", ",", "FACTS_TABLE", ")", "&&", "t", ".", "isMaterialized", "(", "RANK_TABLE", ",", "FACTS_TABLE", ")", "&&", "t", ".", "isMaterialized", "(", "COMPONENT_TABLE", ",", "FACTS_TABLE", ")", ")", "{", "if", "(", "!", "t", ".", "usesRankTable", "(", ")", "&&", "!", "t", ".", "usesComponentTable", "(", ")", "&&", "!", "t", ".", "usesNodeAnnotationTable", "(", ")", "&&", "!", "t", ".", "usesEdgeAnnotationTable", "(", ")", ")", "{", "conditions", ".", "add", "(", "\"\"", ")", ";", "conditions", ".", "add", "(", "isTrue", "(", "t", ".", "aliasedColumn", "(", "FACTS_TABLE", ",", "\"n_sample\"", ")", ")", ")", ";", "}", "else", "if", "(", "!", "t", ".", "usesNodeAnnotationTable", "(", ")", "&&", "!", "t", ".", "usesEdgeAnnotationTable", "(", ")", ")", "{", "conditions", ".", "add", "(", "\"\"", ")", ";", "conditions", ".", "add", "(", "isTrue", "(", "t", ".", "aliasedColumn", "(", "FACTS_TABLE", ",", "\"n_r_c_sample\"", ")", ")", ")", ";", "}", "else", "if", "(", "!", "t", ".", "usesRankTable", "(", ")", "&&", "!", "t", ".", "usesComponentTable", "(", ")", "&&", "!", "t", ".", "usesEdgeAnnotationTable", "(", ")", ")", "{", "conditions", ".", "add", "(", "\"\"", ")", ";", "conditions", ".", "add", "(", "isTrue", "(", "t", ".", "aliasedColumn", "(", "FACTS_TABLE", ",", "\"n_na_sample\"", ")", ")", ")", ";", "}", "else", "if", "(", "!", "t", ".", "usesNodeAnnotationTable", "(", ")", ")", "{", "conditions", ".", "add", "(", "\"\"", ")", ";", "conditions", ".", "add", "(", "isTrue", "(", "t", ".", "aliasedColumn", "(", "FACTS_TABLE", ",", "\"\"", ")", ")", ")", ";", "}", "else", "if", "(", "!", "t", ".", "usesEdgeAnnotationTable", "(", ")", ")", "{", "conditions", ".", "add", "(", "\"\"", ")", ";", "conditions", ".", "add", "(", "isTrue", "(", "t", ".", "aliasedColumn", "(", "FACTS_TABLE", ",", "\"\"", ")", ")", ")", ";", "}", "}", "else", "if", "(", "t", ".", "isMaterialized", "(", "NODE_TABLE", ",", "NODE_ANNOTATION_TABLE", ")", "&&", "t", ".", "isMaterialized", "(", "RANK_TABLE", ",", "EDGE_ANNOTATION_TABLE", ")", "&&", "!", "t", ".", "isMaterialized", "(", "NODE_TABLE", ",", "RANK_TABLE", ")", ")", "{", "if", "(", "!", "t", ".", "usesRankTable", "(", ")", "&&", "!", "t", ".", "usesComponentTable", "(", ")", "&&", "!", "t", ".", "usesNodeAnnotationTable", "(", ")", "&&", "!", "t", ".", "usesEdgeAnnotationTable", "(", ")", ")", "{", "conditions", ".", "add", "(", "\"\"", ")", ";", "conditions", ".", "add", "(", "isTrue", "(", "t", ".", "aliasedColumn", "(", "NODE_TABLE", ",", "\"n_sample\"", ")", ")", ")", ";", "}", "else", "if", "(", "!", "t", ".", "usesNodeAnnotationTable", "(", ")", "&&", "!", "t", ".", "usesEdgeAnnotationTable", "(", ")", ")", "{", "conditions", ".", "add", "(", "\"\"", ")", ";", "conditions", ".", "add", "(", "isTrue", "(", "t", ".", "aliasedColumn", "(", "RANK_TABLE", ",", "\"r_c_sample\"", ")", ")", ")", ";", "}", "}", "return", "conditions", ";", "}", "}", "</s>" ]
8,788
[ "<s>", "package", "annis", ".", "sqlgen", ".", "fullfacts", ";", "import", "static", "annis", ".", "sqlgen", ".", "SqlConstraints", ".", "sqlString", ";", "import", "static", "annis", ".", "sqlgen", ".", "SqlConstraints", ".", "join", ";", "import", "annis", ".", "model", ".", "QueryAnnotation", ";", "import", "annis", ".", "model", ".", "QueryNode", ";", "import", "annis", ".", "model", ".", "QueryNode", ".", "TextMatching", ";", "import", "annis", ".", "ql", ".", "parser", ".", "QueryData", ";", "import", "annis", ".", "sqlgen", ".", "AnnotationConditionProvider", ";", "import", "annis", ".", "sqlgen", ".", "TableAccessStrategy", ";", "import", "java", ".", "util", ".", "List", ";", "public", "class", "FfAnnotateConditionProvider", "implements", "AnnotationConditionProvider", "{", "@", "Override", "public", "void", "addAnnotationConditions", "(", "List", "<", "String", ">", "conditions", ",", "QueryNode", "node", ",", "int", "index", ",", "QueryAnnotation", "annotation", ",", "String", "table", ",", "QueryData", "queryData", ",", "TableAccessStrategy", "tas", ")", "{", "if", "(", "annotation", ".", "getNamespace", "(", ")", "!=", "null", ")", "{", "conditions", ".", "add", "(", "join", "(", "\"=\"", ",", "tas", ".", "aliasedColumn", "(", "table", ",", "\"namespace\"", ",", "index", ")", ",", "sqlString", "(", "annotation", ".", "getNamespace", "(", ")", ")", ")", ")", ";", "}", "conditions", ".", "add", "(", "join", "(", "\"=\"", ",", "tas", ".", "aliasedColumn", "(", "table", ",", "\"name\"", ",", "index", ")", ",", "sqlString", "(", "annotation", ".", "getName", "(", ")", ")", ")", ")", ";", "if", "(", "annotation", ".", "getValue", "(", ")", "!=", "null", ")", "{", "TextMatching", "textMatching", "=", "annotation", ".", "getTextMatching", "(", ")", ";", "conditions", ".", "add", "(", "join", "(", "textMatching", ".", "sqlOperator", "(", ")", ",", "tas", ".", "aliasedColumn", "(", "table", ",", "\"value\"", ",", "index", ")", ",", "sqlString", "(", "annotation", ".", "getValue", "(", ")", ",", "textMatching", ")", ")", ")", ";", "}", "}", "}", "</s>" ]
8,789
[ "<s>", "package", "annis", ".", "sqlgen", ".", "fullfacts", ";", "import", "annis", ".", "model", ".", "QueryNode", ";", "import", "annis", ".", "ql", ".", "parser", ".", "QueryData", ";", "import", "annis", ".", "sqlgen", ".", "AnnotateSqlGenerator", ";", "import", "annis", ".", "sqlgen", ".", "LimitOffsetQueryData", ";", "import", "annis", ".", "sqlgen", ".", "SolutionKey", ";", "import", "annis", ".", "sqlgen", ".", "TableAccessStrategy", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "util", ".", "List", ";", "import", "org", ".", "apache", ".", "commons", ".", "lang3", ".", "StringUtils", ";", "import", "org", ".", "apache", ".", "commons", ".", "lang3", ".", "Validate", ";", "import", "static", "annis", ".", "sqlgen", ".", "TableAccessStrategy", ".", "COMPONENT_TABLE", ";", "import", "static", "annis", ".", "sqlgen", ".", "TableAccessStrategy", ".", "NODE_TABLE", ";", "import", "static", "annis", ".", "sqlgen", ".", "TableAccessStrategy", ".", "RANK_TABLE", ";", "import", "static", "annis", ".", "sqlgen", ".", "TableAccessStrategy", ".", "NODE_ANNOTATION_TABLE", ";", "import", "static", "annis", ".", "sqlgen", ".", "TableAccessStrategy", ".", "EDGE_ANNOTATION_TABLE", ";", "import", "static", "annis", ".", "sqlgen", ".", "SqlConstraints", ".", "sqlString", ";", "public", "class", "FfAnnotateSqlGenerator", "<", "T", ">", "extends", "AnnotateSqlGenerator", "<", "T", ">", "{", "@", "Override", "public", "String", "getTextQuery", "(", "long", "textID", ")", "{", "String", "template", "=", "\"\"", "+", "\"\"", "+", "\"FROMn\"", "+", "\"\"", "+", "\"WHEREn\"", "+", "\"\"", "+", "\"\"", ";", "String", "sql", "=", "template", ".", "replace", "(", "\":text_id\"", ",", "String", ".", "valueOf", "(", "textID", ")", ")", ";", "return", "sql", ";", "}", "@", "Override", "public", "String", "getDocumentQuery", "(", "String", "toplevelCorpusName", ",", "String", "documentName", ")", "{", "String", "template", "=", "\"\"", "+", "\"\"", "+", "\"FROMn\"", "+", "\"\"", "+", "\"WHEREn\"", "+", "\"\"", "+", "\"\"", "+", "\"\"", ";", "String", "sql", "=", "template", ".", "replace", "(", "\"\"", ",", "sqlString", "(", "toplevelCorpusName", ")", ")", ".", "replace", "(", "\"\"", ",", "sqlString", "(", "documentName", ")", ")", ";", "return", "sql", ";", "}", "@", "Override", "public", "String", "selectClause", "(", "QueryData", "queryData", ",", "List", "<", "QueryNode", ">", "alternative", ",", "String", "indent", ")", "{", "String", "innerIndent", "=", "indent", "+", "TABSTOP", ";", "StringBuilder", "sb", "=", "new", "StringBuilder", "(", ")", ";", "sb", ".", "append", "(", "\"DISTINCTn\"", ")", ";", "sb", ".", "append", "(", "innerIndent", ")", ".", "append", "(", "\"\"", ")", ";", "sb", ".", "append", "(", "innerIndent", ")", ";", "List", "<", "LimitOffsetQueryData", ">", "extension", "=", "queryData", ".", "getExtensions", "(", "LimitOffsetQueryData", ".", "class", ")", ";", "Validate", ".", "isTrue", "(", "extension", ".", "size", "(", ")", ">", "0", ")", ";", "sb", ".", "append", "(", "innerIndent", ")", ".", "append", "(", "extension", ".", "get", "(", "0", ")", ".", "getOffset", "(", ")", ")", ".", "append", "(", "\"\"", ")", ";", "sb", ".", "append", "(", "indent", ")", ".", "append", "(", "TABSTOP", "+", "\"\"", ")", ";", "List", "<", "String", ">", "fields", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "addSelectClauseAttribute", "(", "fields", ",", "NODE_TABLE", ",", "\"id\"", ")", ";", "addSelectClauseAttribute", "(", "fields", ",", "NODE_TABLE", ",", "\"text_ref\"", ")", ";", "addSelectClauseAttribute", "(", "fields", ",", "NODE_TABLE", ",", "\"corpus_ref\"", ")", ";", "addSelectClauseAttribute", "(", "fields", ",", "NODE_TABLE", ",", "\"\"", ")", ";", "addSelectClauseAttribute", "(", "fields", ",", "NODE_TABLE", ",", "\"namespace\"", ")", ";", "addSelectClauseAttribute", "(", "fields", ",", "NODE_TABLE", ",", "\"name\"", ")", ";", "addSelectClauseAttribute", "(", "fields", ",", "NODE_TABLE", ",", "\"left\"", ")", ";", "addSelectClauseAttribute", "(", "fields", ",", "NODE_TABLE", ",", "\"right\"", ")", ";", "addSelectClauseAttribute", "(", "fields", ",", "NODE_TABLE", ",", "\"token_index\"", ")", ";", "if", "(", "isIncludeIsTokenColumn", "(", ")", ")", "{", "addSelectClauseAttribute", "(", "fields", ",", "NODE_TABLE", ",", "\"is_token\"", ")", ";", "}", "addSelectClauseAttribute", "(", "fields", ",", "NODE_TABLE", ",", "\"continuous\"", ")", ";", "addSelectClauseAttribute", "(", "fields", ",", "NODE_TABLE", ",", "\"span\"", ")", ";", "addSelectClauseAttribute", "(", "fields", ",", "NODE_TABLE", ",", "\"left_token\"", ")", ";", "addSelectClauseAttribute", "(", "fields", ",", "NODE_TABLE", ",", "\"right_token\"", ")", ";", "addSelectClauseAttribute", "(", "fields", ",", "NODE_TABLE", ",", "\"seg_name\"", ")", ";", "addSelectClauseAttribute", "(", "fields", ",", "NODE_TABLE", ",", "\"seg_left\"", ")", ";", "addSelectClauseAttribute", "(", "fields", ",", "NODE_TABLE", ",", "\"seg_right\"", ")", ";", "addSelectClauseAttribute", "(", "fields", ",", "RANK_TABLE", ",", "\"pre\"", ")", ";", "addSelectClauseAttribute", "(", "fields", ",", "RANK_TABLE", ",", "\"post\"", ")", ";", "addSelectClauseAttribute", "(", "fields", ",", "RANK_TABLE", ",", "\"parent\"", ")", ";", "addSelectClauseAttribute", "(", "fields", ",", "RANK_TABLE", ",", "\"root\"", ")", ";", "addSelectClauseAttribute", "(", "fields", ",", "RANK_TABLE", ",", "\"level\"", ")", ";", "addSelectClauseAttribute", "(", "fields", ",", "COMPONENT_TABLE", ",", "\"id\"", ")", ";", "addSelectClauseAttribute", "(", "fields", ",", "COMPONENT_TABLE", ",", "\"type\"", ")", ";", "addSelectClauseAttribute", "(", "fields", ",", "COMPONENT_TABLE", ",", "\"name\"", ")", ";", "addSelectClauseAttribute", "(", "fields", ",", "COMPONENT_TABLE", ",", "\"namespace\"", ")", ";", "addSelectClauseAttribute", "(", "fields", ",", "NODE_ANNOTATION_TABLE", ",", "\"namespace\"", ")", ";", "addSelectClauseAttribute", "(", "fields", ",", "NODE_ANNOTATION_TABLE", ",", "\"name\"", ")", ";", "addSelectClauseAttribute", "(", "fields", ",", "NODE_ANNOTATION_TABLE", ",", "\"value\"", ")", ";", "addSelectClauseAttribute", "(", "fields", ",", "EDGE_ANNOTATION_TABLE", ",", "\"namespace\"", ")", ";", "addSelectClauseAttribute", "(", "fields", ",", "EDGE_ANNOTATION_TABLE", ",", "\"name\"", ")", ";", "addSelectClauseAttribute", "(", "fields", ",", "EDGE_ANNOTATION_TABLE", ",", "\"value\"", ")", ";", "sb", ".", "append", "(", "innerIndent", ")", ".", "append", "(", "StringUtils", ".", "join", "(", "fields", ",", "\",n\"", "+", "indent", "+", "TABSTOP", ")", ")", ";", "sb", ".", "append", "(", "\",n\"", ")", ";", "sb", ".", "append", "(", "innerIndent", ")", ".", "append", "(", "\"\"", ")", ";", "if", "(", "isIncludeDocumentNameInAnnotateQuery", "(", ")", ")", "{", "sb", ".", "append", "(", "\",n\"", ")", ";", "sb", ".", "append", "(", "innerIndent", ")", ".", "append", "(", "\"\"", ")", ";", "}", "return", "sb", ".", "toString", "(", ")", ";", "}", "@", "Override", "public", "String", "fromClause", "(", "QueryData", "queryData", ",", "List", "<", "QueryNode", ">", "alternative", ",", "String", "indent", ")", "{", "StringBuffer", "sb", "=", "new", "StringBuffer", "(", ")", ";", "sb", ".", "append", "(", "indent", ")", ".", "append", "(", "\"solutions,n\"", ")", ";", "sb", ".", "append", "(", "indent", ")", ".", "append", "(", "TABSTOP", ")", ".", "append", "(", "getTableJoinsInFromClauseSqlGenerator", "(", ")", ".", "fromClauseForNode", "(", "null", ",", "true", ")", ")", ";", "sb", ".", "append", "(", "\",n\"", ")", ";", "sb", ".", "append", "(", "indent", ")", ".", "append", "(", "TABSTOP", ")", ".", "append", "(", "TableAccessStrategy", ".", "CORPUS_TABLE", ")", ";", "return", "sb", ".", "toString", "(", ")", ";", "}", "}", "</s>" ]
8,790
[ "<s>", "package", "annis", ".", "sqlgen", ";", "import", "annis", ".", "model", ".", "QueryAnnotation", ";", "import", "annis", ".", "model", ".", "QueryNode", ";", "import", "annis", ".", "ql", ".", "parser", ".", "QueryData", ";", "import", "java", ".", "util", ".", "List", ";", "public", "interface", "AnnotationConditionProvider", "{", "public", "void", "addAnnotationConditions", "(", "List", "<", "String", ">", "conditions", ",", "QueryNode", "node", ",", "int", "index", ",", "QueryAnnotation", "annotation", ",", "String", "table", ",", "QueryData", "queryData", ",", "TableAccessStrategy", "tas", ")", ";", "}", "</s>" ]
8,791
[ "<s>", "package", "annis", ".", "sqlgen", ";", "public", "class", "LimitOffsetQueryData", "{", "private", "int", "offset", ";", "private", "int", "limit", ";", "public", "LimitOffsetQueryData", "(", "int", "offset", ",", "int", "limit", ")", "{", "this", ".", "offset", "=", "offset", ";", "this", ".", "limit", "=", "limit", ";", "}", "public", "int", "getLimit", "(", ")", "{", "return", "limit", ";", "}", "public", "int", "getOffset", "(", ")", "{", "return", "offset", ";", "}", "public", "boolean", "isPaged", "(", ")", "{", "return", "offset", "!=", "0", "||", "limit", "!=", "0", ";", "}", "}", "</s>" ]
8,792
[ "<s>", "package", "annis", ".", "sqlgen", ";", "import", "static", "annis", ".", "sqlgen", ".", "AbstractSqlGenerator", ".", "TABSTOP", ";", "import", "static", "annis", ".", "sqlgen", ".", "SqlConstraints", ".", "join", ";", "import", "static", "annis", ".", "sqlgen", ".", "TableAccessStrategy", ".", "COMPONENT_TABLE", ";", "import", "static", "annis", ".", "sqlgen", ".", "TableAccessStrategy", ".", "EDGE_ANNOTATION_TABLE", ";", "import", "static", "annis", ".", "sqlgen", ".", "TableAccessStrategy", ".", "NODE_ANNOTATION_TABLE", ";", "import", "static", "annis", ".", "sqlgen", ".", "TableAccessStrategy", ".", "NODE_TABLE", ";", "import", "static", "annis", ".", "sqlgen", ".", "TableAccessStrategy", ".", "RANK_TABLE", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "util", ".", "HashSet", ";", "import", "java", ".", "util", ".", "List", ";", "import", "java", ".", "util", ".", "Set", ";", "import", "org", ".", "apache", ".", "commons", ".", "lang3", ".", "StringUtils", ";", "import", "annis", ".", "model", ".", "QueryNode", ";", "import", "annis", ".", "ql", ".", "parser", ".", "QueryData", ";", "public", "class", "TableJoinsInWhereClauseGenerator", "extends", "AbstractFromClauseGenerator", "implements", "WhereClauseSqlGenerator", "<", "QueryData", ">", "{", "@", "Override", "public", "String", "fromClause", "(", "QueryData", "queryData", ",", "List", "<", "QueryNode", ">", "alternative", ",", "String", "indent", ")", "{", "List", "<", "String", ">", "tables", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "for", "(", "QueryNode", "node", ":", "alternative", ")", "tables", ".", "add", "(", "fromClauseForNode", "(", "node", ",", "false", ")", ")", ";", "return", "StringUtils", ".", "join", "(", "tables", ",", "\",n\"", "+", "indent", "+", "TABSTOP", ")", ";", "}", "@", "Override", "public", "Set", "<", "String", ">", "whereConditions", "(", "QueryData", "queryData", ",", "List", "<", "QueryNode", ">", "alternative", ",", "String", "indent", ")", "{", "Set", "<", "String", ">", "conditions", "=", "new", "HashSet", "<", "String", ">", "(", ")", ";", "for", "(", "QueryNode", "node", ":", "alternative", ")", "{", "conditions", ".", "addAll", "(", "whereConditionsForNode", "(", "node", ")", ")", ";", "}", "return", "conditions", ";", "}", "public", "String", "fromClauseForNode", "(", "QueryNode", "node", ")", "{", "return", "fromClauseForNode", "(", "node", ",", "false", ")", ";", "}", "public", "String", "fromClauseForNode", "(", "QueryNode", "node", ",", "boolean", "leftJoin", ")", "{", "List", "<", "String", ">", "tables", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "tables", ".", "add", "(", "tableAliasDefinition", "(", "node", ",", "NODE_TABLE", ",", "1", ")", ")", ";", "if", "(", "tables", "(", "node", ")", ".", "usesRankTable", "(", ")", "&&", "!", "tables", "(", "node", ")", ".", "isMaterialized", "(", "RANK_TABLE", ",", "NODE_TABLE", ")", ")", "{", "tables", ".", "add", "(", "tableAliasDefinition", "(", "node", ",", "RANK_TABLE", ",", "1", ")", ")", ";", "}", "if", "(", "tables", "(", "node", ")", ".", "usesRankTable", "(", ")", "&&", "!", "tables", "(", "node", ")", ".", "isMaterialized", "(", "COMPONENT_TABLE", ",", "RANK_TABLE", ")", ")", "{", "tables", ".", "add", "(", "tableAliasDefinition", "(", "node", ",", "COMPONENT_TABLE", ",", "1", ")", ")", ";", "}", "if", "(", "tables", "(", "node", ")", ".", "usesNodeAnnotationTable", "(", ")", ")", "{", "int", "start", "=", "tables", "(", "node", ")", ".", "isMaterialized", "(", "NODE_ANNOTATION_TABLE", ",", "NODE_TABLE", ")", "?", "2", ":", "1", ";", "for", "(", "int", "i", "=", "start", ";", "i", "<=", "node", ".", "getNodeAnnotations", "(", ")", ".", "size", "(", ")", ";", "++", "i", ")", "{", "tables", ".", "add", "(", "tableAliasDefinition", "(", "node", ",", "NODE_ANNOTATION_TABLE", ",", "i", ")", ")", ";", "}", "}", "if", "(", "tables", "(", "node", ")", ".", "usesEdgeAnnotationTable", "(", ")", ")", "{", "int", "start", "=", "tables", "(", "node", ")", ".", "isMaterialized", "(", "EDGE_ANNOTATION_TABLE", ",", "RANK_TABLE", ")", "?", "2", ":", "1", ";", "for", "(", "int", "i", "=", "start", ";", "i", "<=", "node", ".", "getEdgeAnnotations", "(", ")", ".", "size", "(", ")", ";", "++", "i", ")", "{", "tables", ".", "add", "(", "tableAliasDefinition", "(", "node", ",", "EDGE_ANNOTATION_TABLE", ",", "i", ")", ")", ";", "}", "}", "return", "StringUtils", ".", "join", "(", "tables", ",", "\",", "\"", ")", ";", "}", "public", "Set", "<", "String", ">", "whereConditionsForNode", "(", "QueryNode", "node", ")", "{", "Set", "<", "String", ">", "conditions", "=", "new", "HashSet", "<", "String", ">", "(", ")", ";", "if", "(", "tables", "(", "node", ")", ".", "usesRankTable", "(", ")", "&&", "!", "tables", "(", "node", ")", ".", "isMaterialized", "(", "RANK_TABLE", ",", "NODE_TABLE", ")", ")", "{", "conditions", ".", "add", "(", "join", "(", "\"=\"", ",", "tables", "(", "node", ")", ".", "aliasedColumn", "(", "RANK_TABLE", ",", "\"node_ref\"", ")", ",", "tables", "(", "node", ")", ".", "aliasedColumn", "(", "NODE_TABLE", ",", "\"id\"", ")", ")", ")", ";", "}", "if", "(", "tables", "(", "node", ")", ".", "usesRankTable", "(", ")", "&&", "!", "tables", "(", "node", ")", ".", "isMaterialized", "(", "COMPONENT_TABLE", ",", "RANK_TABLE", ")", ")", "{", "conditions", ".", "add", "(", "join", "(", "\"=\"", ",", "tables", "(", "node", ")", ".", "aliasedColumn", "(", "RANK_TABLE", ",", "\"\"", ")", ",", "tables", "(", "node", ")", ".", "aliasedColumn", "(", "COMPONENT_TABLE", ",", "\"id\"", ")", ")", ")", ";", "}", "if", "(", "tables", "(", "node", ")", ".", "usesNodeAnnotationTable", "(", ")", ")", "{", "int", "start", "=", "tables", "(", "node", ")", ".", "isMaterialized", "(", "NODE_ANNOTATION_TABLE", ",", "NODE_TABLE", ")", "?", "2", ":", "1", ";", "for", "(", "int", "i", "=", "start", ";", "i", "<=", "node", ".", "getNodeAnnotations", "(", ")", ".", "size", "(", ")", ";", "++", "i", ")", "{", "conditions", ".", "add", "(", "join", "(", "\"=\"", ",", "tables", "(", "node", ")", ".", "aliasedColumn", "(", "NODE_ANNOTATION_TABLE", ",", "\"node_ref\"", ",", "i", ")", ",", "tables", "(", "node", ")", ".", "aliasedColumn", "(", "NODE_TABLE", ",", "\"id\"", ")", ")", ")", ";", "}", "}", "if", "(", "tables", "(", "node", ")", ".", "usesEdgeAnnotationTable", "(", ")", ")", "{", "int", "start", "=", "tables", "(", "node", ")", ".", "isMaterialized", "(", "EDGE_ANNOTATION_TABLE", ",", "RANK_TABLE", ")", "?", "2", ":", "1", ";", "for", "(", "int", "i", "=", "start", ";", "i", "<=", "node", ".", "getEdgeAnnotations", "(", ")", ".", "size", "(", ")", ";", "++", "i", ")", "{", "conditions", ".", "add", "(", "join", "(", "\"=\"", ",", "tables", "(", "node", ")", ".", "aliasedColumn", "(", "EDGE_ANNOTATION_TABLE", ",", "\"rank_ref\"", ",", "i", ")", ",", "tables", "(", "node", ")", ".", "aliasedColumn", "(", "RANK_TABLE", ",", "\"pre\"", ")", ")", ")", ";", "}", "}", "return", "conditions", ";", "}", "}", "</s>" ]
8,793
[ "<s>", "package", "annis", ".", "sqlgen", ";", "import", "static", "annis", ".", "sqlgen", ".", "AbstractSqlGenerator", ".", "TABSTOP", ";", "import", "static", "annis", ".", "sqlgen", ".", "SqlConstraints", ".", "join", ";", "import", "annis", ".", "model", ".", "QueryNode", ";", "import", "annis", ".", "ql", ".", "parser", ".", "QueryData", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "util", ".", "HashSet", ";", "import", "java", ".", "util", ".", "List", ";", "import", "java", ".", "util", ".", "Set", ";", "import", "org", ".", "apache", ".", "commons", ".", "lang3", ".", "StringUtils", ";", "public", "class", "CorpusPathWhereClauseGenerator", "extends", "AbstractFromClauseGenerator", "implements", "WhereClauseSqlGenerator", "<", "QueryData", ">", "{", "@", "Override", "public", "String", "fromClause", "(", "QueryData", "queryData", ",", "List", "<", "QueryNode", ">", "alternative", ",", "String", "indent", ")", "{", "List", "<", "String", ">", "tables", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "alternative", ".", "size", "(", ")", ";", "i", "++", ")", "{", "QueryNode", "n", "=", "alternative", ".", "get", "(", "i", ")", ";", "tables", ".", "add", "(", "\"corpus\"", "+", "\"", "AS", "corpus\"", "+", "(", "i", "+", "1", ")", ")", ";", "}", "return", "StringUtils", ".", "join", "(", "tables", ",", "\",", "\"", "+", "indent", "+", "TABSTOP", ")", ";", "}", "@", "Override", "public", "Set", "<", "String", ">", "whereConditions", "(", "QueryData", "queryData", ",", "List", "<", "QueryNode", ">", "alternative", ",", "String", "indent", ")", "{", "Set", "<", "String", ">", "conditions", "=", "new", "HashSet", "<", "String", ">", "(", ")", ";", "int", "i", "=", "0", ";", "for", "(", "QueryNode", "n", ":", "alternative", ")", "{", "i", "++", ";", "String", "factTable", "=", "tables", "(", "n", ")", ".", "aliasedTable", "(", "\"node\"", ",", "1", ")", "+", "\".corpus_ref\"", ";", "String", "corpusTable", "=", "tables", "(", "n", ")", ".", "aliasedTable", "(", "\"corpus\"", ",", "i", ")", "+", "\".id\"", ";", "conditions", ".", "add", "(", "join", "(", "\"=\"", ",", "factTable", ",", "corpusTable", ")", ")", ";", "}", "return", "conditions", ";", "}", "}", "</s>" ]
8,794
[ "<s>", "package", "annis", ".", "sqlgen", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "util", ".", "List", ";", "import", "org", ".", "apache", ".", "commons", ".", "lang3", ".", "StringUtils", ";", "import", "org", ".", "springframework", ".", "util", ".", "Assert", ";", "import", "annis", ".", "model", ".", "QueryNode", ";", "import", "annis", ".", "ql", ".", "parser", ".", "QueryData", ";", "public", "abstract", "class", "AbstractUnionSqlGenerator", "<", "T", ">", "extends", "AbstractSqlGenerator", "<", "T", ">", "{", "@", "Override", "public", "String", "toSql", "(", "QueryData", "queryData", ",", "String", "indent", ")", "{", "Assert", ".", "notEmpty", "(", "queryData", ".", "getAlternatives", "(", ")", ",", "\"\"", ")", ";", "StringBuffer", "sb", "=", "new", "StringBuffer", "(", ")", ";", "sb", ".", "append", "(", "indent", ")", ";", "List", "<", "String", ">", "alternatives", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "for", "(", "List", "<", "QueryNode", ">", "alternative", ":", "queryData", ".", "getAlternatives", "(", ")", ")", "{", "alternatives", ".", "add", "(", "createSqlForAlternative", "(", "queryData", ",", "alternative", ",", "indent", ")", ")", ";", "}", "sb", ".", "append", "(", "StringUtils", ".", "join", "(", "alternatives", ",", "\"n\"", "+", "indent", "+", "\"UNION", "\"", ")", ")", ";", "appendOrderByClause", "(", "sb", ",", "queryData", ",", "null", ",", "indent", ")", ";", "appendLimitOffsetClause", "(", "sb", ",", "queryData", ",", "null", ",", "indent", ")", ";", "return", "sb", ".", "toString", "(", ")", ";", "}", "}", "</s>" ]
8,795
[ "<s>", "package", "annis", ".", "sqlgen", ";", "import", "annis", ".", "model", ".", "QueryNode", ";", "import", "annis", ".", "ql", ".", "parser", ".", "QueryData", ";", "import", "java", ".", "util", ".", "HashMap", ";", "import", "java", ".", "util", ".", "LinkedList", ";", "import", "java", ".", "util", ".", "List", ";", "import", "java", ".", "util", ".", "Properties", ";", "import", "org", ".", "apache", ".", "commons", ".", "lang3", ".", "StringUtils", ";", "import", "static", "annis", ".", "sqlgen", ".", "TableAccessStrategy", ".", "*", ";", "import", "static", "annis", ".", "sqlgen", ".", "AbstractSqlGenerator", ".", "TABSTOP", ";", "import", "static", "annis", ".", "sqlgen", ".", "SqlConstraints", ".", "sqlString", ";", "public", "class", "CommonAnnotateWithClauseGenerator", "extends", "TableAccessStrategyFactory", "implements", "WithClauseSqlGenerator", "<", "QueryData", ">", "{", "private", "AnnotateInnerQuerySqlGenerator", "innerQuerySqlGenerator", ";", "private", "IslandsPolicy", "islandsPolicy", ";", "protected", "SolutionKey", "<", "?", ">", "createSolutionKey", "(", ")", "{", "throw", "new", "UnsupportedOperationException", "(", "\"\"", ")", ";", "}", "@", "Override", "public", "List", "<", "String", ">", "withClauses", "(", "QueryData", "queryData", ",", "List", "<", "QueryNode", ">", "alternative", ",", "String", "indent", ")", "{", "List", "<", "Long", ">", "corpusList", "=", "queryData", ".", "getCorpusList", "(", ")", ";", "HashMap", "<", "Long", ",", "Properties", ">", "corpusProperties", "=", "queryData", ".", "getCorpusConfiguration", "(", ")", ";", "IslandsPolicy", ".", "IslandPolicies", "policy", "=", "getIslandsPolicy", "(", ")", ".", "getMostRestrictivePolicy", "(", "corpusList", ",", "corpusProperties", ")", ";", "List", "<", "String", ">", "result", "=", "new", "LinkedList", "<", "String", ">", "(", ")", ";", "List", "<", "AnnotateQueryData", ">", "ext", "=", "queryData", ".", "getExtensions", "(", "AnnotateQueryData", ".", "class", ")", ";", "if", "(", "!", "ext", ".", "isEmpty", "(", ")", ")", "{", "AnnotateQueryData", "annoQueryData", "=", "ext", ".", "get", "(", "0", ")", ";", "if", "(", "annoQueryData", ".", "getSegmentationLayer", "(", ")", "==", "null", ")", "{", "result", ".", "add", "(", "getMatchesWithClause", "(", "queryData", ",", "alternative", ",", "indent", ")", ")", ";", "result", ".", "add", "(", "getSolutionFromMatchesWithClause", "(", "queryData", ",", "policy", ",", "alternative", ",", "\"matches\"", ",", "indent", ")", ")", ";", "}", "else", "{", "result", ".", "add", "(", "getMatchesWithClause", "(", "queryData", ",", "alternative", ",", "indent", ")", ")", ";", "result", ".", "add", "(", "getNearestSeqWithClause", "(", "queryData", ",", "annoQueryData", ",", "alternative", ",", "\"matches\"", ",", "indent", ")", ")", ";", "result", ".", "add", "(", "getSolutionFromNearestSegWithClause", "(", "queryData", ",", "annoQueryData", ",", "alternative", ",", "policy", ",", "\"nearestseg\"", ",", "indent", ")", ")", ";", "}", "}", "return", "result", ";", "}", "protected", "String", "getMatchesWithClause", "(", "QueryData", "queryData", ",", "List", "<", "QueryNode", ">", "alternative", ",", "String", "indent", ")", "{", "StringBuilder", "sb", "=", "new", "StringBuilder", "(", ")", ";", "sb", ".", "append", "(", "indent", ")", ".", "append", "(", "\"matches", "ASn\"", ")", ";", "sb", ".", "append", "(", "indent", ")", ".", "append", "(", "\"(n\"", ")", ";", "sb", ".", "append", "(", "indent", ")", ".", "append", "(", "getInnerQuerySqlGenerator", "(", ")", ".", "toSql", "(", "queryData", ",", "indent", "+", "TABSTOP", ")", ")", ";", "sb", ".", "append", "(", "\"n\"", ")", ".", "append", "(", "indent", ")", ".", "append", "(", "\")\"", ")", ";", "return", "sb", ".", "toString", "(", ")", ";", "}", "protected", "String", "getSolutionFromMatchesWithClause", "(", "QueryData", "queryData", ",", "IslandsPolicy", ".", "IslandPolicies", "islandPolicies", ",", "List", "<", "QueryNode", ">", "alternative", ",", "String", "matchesName", ",", "String", "indent", ")", "{", "StringBuilder", "sb", "=", "new", "StringBuilder", "(", ")", ";", "sb", ".", "append", "(", "indent", ")", ".", "append", "(", "\"\"", ")", ";", "sb", ".", "append", "(", "indent", ")", ".", "append", "(", "\"(n\"", ")", ";", "String", "innerIndent", "=", "indent", "+", "TABSTOP", ";", "if", "(", "islandPolicies", "==", "IslandsPolicy", ".", "IslandPolicies", ".", "none", ")", "{", "innerIndent", "=", "indent", "+", "TABSTOP", "+", "TABSTOP", ";", "sb", ".", "append", "(", "indent", ")", ".", "append", "(", "\"\"", "+", "\"\"", "+", "\"\"", ")", ";", "}", "SolutionKey", "<", "?", ">", "key", "=", "createSolutionKey", "(", ")", ";", "TableAccessStrategy", "tas", "=", "new", "TableAccessStrategy", "(", "createTableAccessStrategy", "(", ")", ")", ";", "tas", ".", "addTableAlias", "(", "\"solutions\"", ",", "matchesName", ")", ";", "List", "<", "String", ">", "keyColumns", "=", "key", ".", "generateOuterQueryColumns", "(", "tas", ",", "alternative", ".", "size", "(", ")", ")", ";", "for", "(", "int", "i", "=", "1", ";", "i", "<=", "alternative", ".", "size", "(", ")", ";", "i", "++", ")", "{", "if", "(", "i", ">=", "2", ")", "{", "sb", ".", "append", "(", "innerIndent", ")", ".", "append", "(", "\"UNION", "ALLn\"", ")", ";", "}", "sb", ".", "append", "(", "innerIndent", ")", ".", "append", "(", "\"SELECT", "\"", ")", ".", "append", "(", "StringUtils", ".", "join", "(", "keyColumns", ",", "\",", "\"", ")", ")", ".", "append", "(", "\",", "n,", "text\"", ")", ".", "append", "(", "i", ")", ".", "append", "(", "\"\"", ")", ".", "append", "(", "i", ")", ".", "append", "(", "\"\"", ")", ".", "append", "(", "i", ")", ".", "append", "(", "\"\"", ")", ".", "append", "(", "i", ")", ".", "append", "(", "\"", "AS", "corpus", "\"", ")", ".", "append", "(", "\"FROM", "\"", ")", ".", "append", "(", "matchesName", ")", ".", "append", "(", "\"n\"", ")", ";", "}", "if", "(", "islandPolicies", "==", "IslandsPolicy", ".", "IslandPolicies", ".", "none", ")", "{", "sb", ".", "append", "(", "indent", ")", ".", "append", "(", "\"\"", ")", ";", "}", "if", "(", "islandPolicies", "==", "IslandsPolicy", ".", "IslandPolicies", ".", "none", ")", "{", "sb", ".", "append", "(", "indent", ")", ".", "append", "(", "\"\"", ")", ";", "}", "sb", ".", "append", "(", "indent", ")", ".", "append", "(", "\")\"", ")", ";", "return", "sb", ".", "toString", "(", ")", ";", "}", "protected", "String", "getNearestSeqWithClause", "(", "QueryData", "queryData", ",", "AnnotateQueryData", "annoQueryData", ",", "List", "<", "QueryNode", ">", "alternative", ",", "String", "matchesName", ",", "String", "indent", ")", "{", "String", "indent2", "=", "indent", "+", "TABSTOP", ";", "String", "indent3", "=", "indent2", "+", "TABSTOP", ";", "SolutionKey", "<", "?", ">", "key", "=", "createSolutionKey", "(", ")", ";", "TableAccessStrategy", "tas", "=", "new", "TableAccessStrategy", "(", "createTableAccessStrategy", "(", ")", ")", ";", "tas", ".", "addTableAlias", "(", "\"solutions\"", ",", "matchesName", ")", ";", "List", "<", "String", ">", "keyColumns", "=", "key", ".", "generateOuterQueryColumns", "(", "tas", ",", "alternative", ".", "size", "(", ")", ")", ";", "StringBuilder", "sb", "=", "new", "StringBuilder", "(", ")", ";", "sb", ".", "append", "(", "indent", ")", ".", "append", "(", "\"\"", ")", ";", "sb", ".", "append", "(", "indent", ")", ".", "append", "(", "\"(n\"", ")", ";", "for", "(", "int", "i", "=", "1", ";", "i", "<=", "alternative", ".", "size", "(", ")", ";", "i", "++", ")", "{", "sb", ".", "append", "(", "indent2", ")", ".", "append", "(", "\"SELECTn\"", ")", ";", "sb", ".", "append", "(", "indent3", ")", ";", "for", "(", "String", "k", ":", "keyColumns", ")", "{", "sb", ".", "append", "(", "k", ")", ";", "}", "sb", ".", "append", "(", "\"\"", ")", ";", "sb", ".", "append", "(", "indent3", ")", ".", "append", "(", "tas", ".", "aliasedColumn", "(", "NODE_TABLE", ",", "\"seg_left\"", ")", ")", ".", "append", "(", "\"", "-", "\"", ")", ".", "append", "(", "annoQueryData", ".", "getLeft", "(", ")", ")", ".", "append", "(", "\"", "AS", "\\\"min\\\",n\"", ")", ";", "sb", ".", "append", "(", "indent3", ")", ".", "append", "(", "tas", ".", "aliasedColumn", "(", "NODE_TABLE", ",", "\"seg_right\"", ")", ")", ".", "append", "(", "\"", "+", "\"", ")", ".", "append", "(", "annoQueryData", ".", "getRight", "(", ")", ")", ".", "append", "(", "\"", "AS", "\\\"max\\\",n\"", ")", ";", "sb", ".", "append", "(", "indent3", ")", ".", "append", "(", "tas", ".", "aliasedColumn", "(", "NODE_TABLE", ",", "\"text_ref\"", ")", ")", ".", "append", "(", "\"\"", ")", ";", "sb", ".", "append", "(", "indent3", ")", ".", "append", "(", "tas", ".", "aliasedColumn", "(", "NODE_TABLE", ",", "\"corpus_ref\"", ")", ")", ".", "append", "(", "\"\"", ")", ";", "String", "distLeft", "=", "\"min\"", "+", "i", "+", "\"", "-", "\"", "+", "tas", ".", "aliasedColumn", "(", "NODE_TABLE", ",", "\"right_token\"", ")", ";", "String", "distRight", "=", "tas", ".", "aliasedColumn", "(", "NODE_TABLE", ",", "\"left_token\"", ")", "+", "\"", "-", "max\"", "+", "i", ";", "sb", ".", "append", "(", "indent3", ")", ".", "append", "(", "\"\"", ")", ".", "append", "(", "tas", ".", "aliasedColumn", "(", "NODE_TABLE", ",", "\"text_ref\"", ")", ")", ".", "append", "(", "\"\"", ")", ".", "append", "(", "distLeft", ")", ".", "append", "(", "\"+", "1,", "-abs(\"", ")", ".", "append", "(", "distLeft", ")", ".", "append", "(", "\"\"", ")", ";", "sb", ".", "append", "(", "indent3", ")", ".", "append", "(", "\"\"", ")", ".", "append", "(", "tas", ".", "aliasedColumn", "(", "NODE_TABLE", ",", "\"text_ref\"", ")", ")", ".", "append", "(", "\"\"", ")", ".", "append", "(", "distRight", ")", ".", "append", "(", "\"", "+", "1,", "-abs(\"", ")", ".", "append", "(", "distRight", ")", ".", "append", "(", "\"\"", ")", ";", "sb", ".", "append", "(", "indent2", ")", ".", "append", "(", "\"FROM", "\"", ")", ".", "append", "(", "tas", ".", "tableName", "(", "NODE_TABLE", ")", ")", ".", "append", "(", "\",", "matchesn\"", ")", ";", "sb", ".", "append", "(", "indent2", ")", ".", "append", "(", "\"WHEREn\"", ")", ";", "sb", ".", "append", "(", "indent3", ")", ".", "append", "(", "tas", ".", "aliasedColumn", "(", "NODE_TABLE", ",", "\"\"", ")", ")", ".", "append", "(", "\"", "IN", "(\"", ")", ".", "append", "(", "StringUtils", ".", "join", "(", "queryData", ".", "getCorpusList", "(", ")", ",", "\",\"", ")", ")", ".", "append", "(", "\")", "ANDn\"", ")", ";", "sb", ".", "append", "(", "indent3", ")", ".", "append", "(", "tas", ".", "aliasedColumn", "(", "NODE_TABLE", ",", "\"n_sample\"", ")", ")", ".", "append", "(", "\"\"", ")", ";", "sb", ".", "append", "(", "indent3", ")", ".", "append", "(", "tas", ".", "aliasedColumn", "(", "NODE_TABLE", ",", "\"seg_name\"", ")", ")", ".", "append", "(", "\"", "=", "\"", ")", ".", "append", "(", "sqlString", "(", "annoQueryData", ".", "getSegmentationLayer", "(", ")", ")", ")", ".", "append", "(", "\"", "ANDn\"", ")", ";", "sb", ".", "append", "(", "indent3", ")", ".", "append", "(", "tas", ".", "aliasedColumn", "(", "NODE_TABLE", ",", "\"text_ref\"", ")", ")", ".", "append", "(", "\"\"", ")", ".", "append", "(", "i", ")", ".", "append", "(", "\"", "ANDn\"", ")", ";", "sb", ".", "append", "(", "indent3", ")", ".", "append", "(", "tas", ".", "aliasedColumn", "(", "NODE_TABLE", ",", "\"corpus_ref\"", ")", ")", ".", "append", "(", "\"\"", ")", ".", "append", "(", "i", ")", ".", "append", "(", "\"n\"", ")", ";", "if", "(", "i", "<", "alternative", ".", "size", "(", ")", ")", "{", "sb", ".", "append", "(", "\"n\"", ")", ".", "append", "(", "indent2", ")", ".", "append", "(", "\"UNION", "ALL\"", ")", ".", "append", "(", "\"nn\"", ")", ";", "}", "}", "sb", ".", "append", "(", "indent", ")", ".", "append", "(", "\")\"", ")", ";", "return", "sb", ".", "toString", "(", ")", ";", "}", "protected", "String", "getSolutionFromNearestSegWithClause", "(", "QueryData", "queryData", ",", "AnnotateQueryData", "annoQueryData", ",", "List", "<", "QueryNode", ">", "alternative", ",", "IslandsPolicy", ".", "IslandPolicies", "islandsPolicy", ",", "String", "coveredName", ",", "String", "indent", ")", "{", "TableAccessStrategy", "tas", "=", "createTableAccessStrategy", "(", ")", ";", "String", "indent2", "=", "indent", "+", "TABSTOP", ";", "String", "indent3", "=", "indent2", "+", "TABSTOP", ";", "List", "<", "Long", ">", "corpusList", "=", "queryData", ".", "getCorpusList", "(", ")", ";", "StringBuilder", "sb", "=", "new", "StringBuilder", "(", ")", ";", "sb", ".", "append", "(", "indent", ")", ".", "append", "(", "\"\"", ")", ";", "sb", ".", "append", "(", "indent", ")", ".", "append", "(", "\"(n\"", ")", ";", "sb", ".", "append", "(", "indent2", ")", ".", "append", "(", "\"\"", ")", ";", "if", "(", "islandsPolicy", "==", "IslandsPolicy", ".", "IslandPolicies", ".", "none", ")", "{", "sb", ".", "append", "(", "\"min(\"", ")", ".", "append", "(", "coveredName", ")", ".", "append", "(", "\"\"", ")", ".", "append", "(", "coveredName", ")", ".", "append", "(", "\".n", "AS", "n,", "\"", ")", ".", "append", "(", "\"min(\"", ")", ".", "append", "(", "tas", ".", "aliasedColumn", "(", "NODE_TABLE", ",", "\"left_token\"", ")", ")", ".", "append", "(", "\")", "AS", "\\\"min\\\",", "\"", ")", ".", "append", "(", "\"max(\"", ")", ".", "append", "(", "tas", ".", "aliasedColumn", "(", "NODE_TABLE", ",", "\"right_token\"", ")", ")", ".", "append", "(", "\")", "AS", "\\\"max\\\",", "\"", ")", ".", "append", "(", "\"\"", ")", ".", "append", "(", "tas", ".", "aliasedColumn", "(", "NODE_TABLE", ",", "\"text_ref\"", ")", ")", ".", "append", "(", "\"", "AS", "\\\"text\\\"n\"", ")", ";", "}", "else", "if", "(", "islandsPolicy", "==", "IslandsPolicy", ".", "IslandPolicies", ".", "context", ")", "{", "sb", ".", "append", "(", "coveredName", ")", ".", "append", "(", "\"\"", ")", ".", "append", "(", "coveredName", ")", ".", "append", "(", "\".n", "AS", "n,", "\"", ")", ".", "append", "(", "tas", ".", "aliasedColumn", "(", "NODE_TABLE", ",", "\"left_token\"", ")", ")", ".", "append", "(", "\"", "AS", "\\\"min\\\",", "\"", ")", ".", "append", "(", "tas", ".", "aliasedColumn", "(", "NODE_TABLE", ",", "\"right_token\"", ")", ")", ".", "append", "(", "\"", "AS", "\\\"max\\\",", "\"", ")", ".", "append", "(", "tas", ".", "aliasedColumn", "(", "NODE_TABLE", ",", "\"text_ref\"", ")", ")", ".", "append", "(", "\"", "AS", "\\\"text\\\"n\"", ")", ";", "}", "else", "{", "throw", "new", "UnsupportedOperationException", "(", "\"\"", "+", "islandsPolicy", ".", "toString", "(", ")", ")", ";", "}", "sb", ".", "append", "(", "indent2", ")", ".", "append", "(", "\"FROM", "\"", ")", ".", "append", "(", "coveredName", ")", ".", "append", "(", "\",", "\"", ")", ".", "append", "(", "tas", ".", "tableName", "(", "NODE_TABLE", ")", ")", ".", "append", "(", "\"n\"", ")", ";", "sb", ".", "append", "(", "indent2", ")", ".", "append", "(", "\"WHEREn\"", ")", ";", "sb", ".", "append", "(", "indent3", ")", ".", "append", "(", "tas", ".", "aliasedColumn", "(", "NODE_TABLE", ",", "\"\"", ")", ")", ".", "append", "(", "\"", "IN", "(\"", ")", ".", "append", "(", "StringUtils", ".", "join", "(", "corpusList", ",", "\",\"", ")", ")", ".", "append", "(", "\")", "ANDn\"", ")", ";", "sb", ".", "append", "(", "indent3", ")", ".", "append", "(", "tas", ".", "aliasedColumn", "(", "NODE_TABLE", ",", "\"n_sample\"", ")", ")", ".", "append", "(", "\"\"", ")", ";", "sb", ".", "append", "(", "indent3", ")", ".", "append", "(", "tas", ".", "aliasedColumn", "(", "NODE_TABLE", ",", "\"seg_name\"", ")", ")", ".", "append", "(", "\"", "=", "\"", ")", ".", "append", "(", "sqlString", "(", "annoQueryData", ".", "getSegmentationLayer", "(", ")", ")", ")", ".", "append", "(", "\"", "ANDn\"", ")", ";", "sb", ".", "append", "(", "indent3", ")", ".", "append", "(", "tas", ".", "aliasedColumn", "(", "NODE_TABLE", ",", "\"text_ref\"", ")", ")", ".", "append", "(", "\"", "=", "\"", ")", ".", "append", "(", "coveredName", ")", ".", "append", "(", "\".\\\"text\\\"", "ANDn\"", ")", ";", "sb", ".", "append", "(", "indent3", ")", ".", "append", "(", "tas", ".", "aliasedColumn", "(", "NODE_TABLE", ",", "\"corpus_ref\"", ")", ")", ".", "append", "(", "\"", "=", "\"", ")", ".", "append", "(", "coveredName", ")", ".", "append", "(", "\"\"", ")", ";", "sb", ".", "append", "(", "indent3", ")", ".", "append", "(", "tas", ".", "aliasedColumn", "(", "NODE_TABLE", ",", "\"seg_left\"", ")", ")", ".", "append", "(", "\"", "<=", "\"", ")", ".", "append", "(", "coveredName", ")", ".", "append", "(", "\".\\\"max\\\"", "ANDn\"", ")", ";", "sb", ".", "append", "(", "indent3", ")", ".", "append", "(", "tas", ".", "aliasedColumn", "(", "NODE_TABLE", ",", "\"seg_right\"", ")", ")", ".", "append", "(", "\"", ">=", "\"", ")", ".", "append", "(", "coveredName", ")", ".", "append", "(", "\".\\\"min\\\"", "ANDn\"", ")", ";", "sb", ".", "append", "(", "indent3", ")", ".", "append", "(", "\"(\"", ")", ".", "append", "(", "coveredName", ")", ".", "append", "(", "\"\"", ")", ".", "append", "(", "coveredName", ")", ".", "append", "(", "\"\"", ")", ";", "if", "(", "islandsPolicy", "==", "IslandsPolicy", ".", "IslandPolicies", ".", "none", ")", "{", "sb", ".", "append", "(", "indent2", ")", ".", "append", "(", "\"GROUP", "BY", "\"", ")", ".", "append", "(", "tas", ".", "aliasedColumn", "(", "NODE_TABLE", ",", "\"text_ref\"", ")", ")", ".", "append", "(", "\",", "nn\"", ")", ";", "}", "sb", ".", "append", "(", "indent", ")", ".", "append", "(", "\")n\"", ")", ";", "return", "sb", ".", "toString", "(", ")", ";", "}", "public", "static", "String", "overlapForOneRange", "(", "String", "indent", ",", "String", "rangeMin", ",", "String", "rangeMax", ",", "String", "textRef", ",", "TableAccessStrategy", "tables", ")", "{", "StringBuilder", "sb", "=", "new", "StringBuilder", "(", ")", ";", "sb", ".", "append", "(", "indent", ")", ".", "append", "(", "\"(\"", ")", ";", "sb", ".", "append", "(", "tables", ".", "aliasedColumn", "(", "NODE_TABLE", ",", "\"left_token\"", ")", ")", ".", "append", "(", "\"", "<=", "\"", ")", ".", "append", "(", "rangeMax", ")", ".", "append", "(", "\"", "AND", "\"", ")", ".", "append", "(", "tables", ".", "aliasedColumn", "(", "NODE_TABLE", ",", "\"right_token\"", ")", ")", ".", "append", "(", "\"", ">=", "\"", ")", ".", "append", "(", "rangeMin", ")", ".", "append", "(", "\"", "AND", "\"", ")", ".", "append", "(", "tables", ".", "aliasedColumn", "(", "NODE_TABLE", ",", "\"text_ref\"", ")", ")", ".", "append", "(", "\"", "=", "\"", ")", ".", "append", "(", "textRef", ")", ";", "sb", ".", "append", "(", "\")\"", ")", ";", "return", "sb", ".", "toString", "(", ")", ";", "}", "public", "AnnotateInnerQuerySqlGenerator", "getInnerQuerySqlGenerator", "(", ")", "{", "return", "innerQuerySqlGenerator", ";", "}", "public", "void", "setInnerQuerySqlGenerator", "(", "AnnotateInnerQuerySqlGenerator", "innerQuerySqlGenerator", ")", "{", "this", ".", "innerQuerySqlGenerator", "=", "innerQuerySqlGenerator", ";", "}", "public", "IslandsPolicy", "getIslandsPolicy", "(", ")", "{", "return", "islandsPolicy", ";", "}", "public", "void", "setIslandsPolicy", "(", "IslandsPolicy", "islandsPolicy", ")", "{", "this", ".", "islandsPolicy", "=", "islandsPolicy", ";", "}", "}", "</s>" ]
8,796
[ "<s>", "package", "annis", ".", "sqlgen", ";", "import", "java", ".", "sql", ".", "ResultSet", ";", "import", "java", ".", "sql", ".", "SQLException", ";", "import", "org", ".", "springframework", ".", "jdbc", ".", "core", ".", "simple", ".", "ParameterizedRowMapper", ";", "import", "annis", ".", "service", ".", "objects", ".", "AnnisCorpus", ";", "import", "org", ".", "slf4j", ".", "Logger", ";", "import", "org", ".", "slf4j", ".", "LoggerFactory", ";", "public", "class", "ListCorpusSqlHelper", "implements", "ParameterizedRowMapper", "<", "AnnisCorpus", ">", "{", "private", "static", "final", "Logger", "log", "=", "LoggerFactory", ".", "getLogger", "(", "ListCorpusSqlHelper", ".", "class", ")", ";", "public", "String", "createSqlQuery", "(", ")", "{", "return", "\"\"", ";", "}", "public", "AnnisCorpus", "mapRow", "(", "ResultSet", "rs", ",", "int", "rowNum", ")", "throws", "SQLException", "{", "AnnisCorpus", "corpus", "=", "new", "AnnisCorpus", "(", ")", ";", "corpus", ".", "setId", "(", "rs", ".", "getLong", "(", "\"id\"", ")", ")", ";", "corpus", ".", "setName", "(", "rs", ".", "getString", "(", "\"name\"", ")", ")", ";", "corpus", ".", "setTextCount", "(", "rs", ".", "getInt", "(", "\"text\"", ")", ")", ";", "corpus", ".", "setTokenCount", "(", "rs", ".", "getInt", "(", "\"tokens\"", ")", ")", ";", "try", "{", "corpus", ".", "setSourcePath", "(", "rs", ".", "getString", "(", "\"source_path\"", ")", ")", ";", "}", "catch", "(", "SQLException", "ex", ")", "{", "log", ".", "debug", "(", "null", ",", "ex", ")", ";", "}", "return", "corpus", ";", "}", "}", "</s>" ]
8,797
[ "<s>", "package", "annis", ".", "sqlgen", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "util", ".", "List", ";", "import", "org", ".", "apache", ".", "commons", ".", "lang3", ".", "StringUtils", ";", "import", "annis", ".", "model", ".", "QueryAnnotation", ";", "import", "annis", ".", "model", ".", "QueryNode", ";", "public", "class", "SubQueryCorpusSelectionStrategy", "{", "public", "String", "buildSubQuery", "(", "List", "<", "Long", ">", "corpusList", ",", "List", "<", "QueryAnnotation", ">", "metaData", ")", "{", "StringBuffer", "sb", "=", "new", "StringBuffer", "(", ")", ";", "sb", ".", "append", "(", "\"\"", ")", ";", "if", "(", "!", "corpusList", ".", "isEmpty", "(", ")", ")", "{", "sb", ".", "append", "(", "\",", "\"", ")", ";", "sb", ".", "append", "(", "\"corpus", "AS", "c2\"", ")", ";", "}", "for", "(", "int", "i", "=", "1", ";", "i", "<=", "metaData", ".", "size", "(", ")", ";", "++", "i", ")", "{", "sb", ".", "append", "(", "\",", "\"", ")", ";", "sb", ".", "append", "(", "\"\"", ")", ";", "sb", ".", "append", "(", "i", ")", ";", "}", "if", "(", "hasCorpusSelection", "(", "corpusList", ",", "metaData", ")", ")", "sb", ".", "append", "(", "\"", "WHERE", "\"", ")", ";", "List", "<", "String", ">", "conditions", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "if", "(", "!", "corpusList", ".", "isEmpty", "(", ")", ")", "{", "conditions", ".", "add", "(", "\"\"", ")", ";", "conditions", ".", "add", "(", "\"\"", ")", ";", "conditions", ".", "add", "(", "\"\"", ".", "replace", "(", "\":corpusList\"", ",", "StringUtils", ".", "join", "(", "corpusList", ",", "\",", "\"", ")", ")", ")", ";", "}", "for", "(", "int", "i", "=", "1", ";", "i", "<=", "metaData", ".", "size", "(", ")", ";", "++", "i", ")", "{", "QueryAnnotation", "annotation", "=", "metaData", ".", "get", "(", "i", "-", "1", ")", ";", "if", "(", "annotation", ".", "getNamespace", "(", ")", "!=", "null", ")", "conditions", ".", "add", "(", "\"\"", "+", "i", "+", "\"\"", "+", "annotation", ".", "getNamespace", "(", ")", "+", "\"'\"", ")", ";", "conditions", ".", "add", "(", "\"\"", "+", "i", "+", "\".name", "=", "'\"", "+", "annotation", ".", "getName", "(", ")", "+", "\"'\"", ")", ";", "if", "(", "annotation", ".", "getValue", "(", ")", "!=", "null", ")", "{", "String", "value", "=", "annotation", ".", "getValue", "(", ")", ";", "if", "(", "annotation", ".", "getTextMatching", "(", ")", "==", "QueryNode", ".", "TextMatching", ".", "REGEXP_EQUAL", "||", "annotation", ".", "getTextMatching", "(", ")", "==", "QueryNode", ".", "TextMatching", ".", "REGEXP_NOT_EQUAL", ")", "{", "value", "=", "\"^\"", "+", "value", "+", "\"$\"", ";", "}", "conditions", ".", "add", "(", "\"\"", "+", "i", "+", "\".value", "\"", "+", "annotation", ".", "getTextMatching", "(", ")", ".", "sqlOperator", "(", ")", "+", "\"", "'\"", "+", "value", "+", "\"'\"", ")", ";", "}", "conditions", ".", "add", "(", "\"\"", "+", "i", "+", "\"\"", ")", ";", "}", "sb", ".", "append", "(", "StringUtils", ".", "join", "(", "conditions", ",", "\"", "AND", "\"", ")", ")", ";", "return", "sb", ".", "toString", "(", ")", ";", "}", "public", "boolean", "hasCorpusSelection", "(", "List", "<", "Long", ">", "corpusList", ",", "List", "<", "QueryAnnotation", ">", "metaData", ")", "{", "return", "!", "(", "corpusList", ".", "isEmpty", "(", ")", "&&", "metaData", ".", "isEmpty", "(", ")", ")", ";", "}", "}", "</s>" ]
8,798
[ "<s>", "package", "annis", ".", "sqlgen", ";", "import", "java", ".", "util", ".", "Collection", ";", "import", "org", ".", "apache", ".", "commons", ".", "lang3", ".", "StringEscapeUtils", ";", "import", "org", ".", "apache", ".", "commons", ".", "lang3", ".", "StringUtils", ";", "import", "annis", ".", "model", ".", "QueryNode", ".", "TextMatching", ";", "public", "class", "SqlConstraints", "{", "private", "static", "boolean", "disableBetweenSymmetricPredicate", "=", "false", ";", "private", "static", "boolean", "disableBetweenPredicate", "=", "false", ";", "public", "static", "String", "isTrue", "(", "String", "lhs", ")", "{", "return", "lhs", "+", "\"", "IS", "TRUE\"", ";", "}", "public", "static", "String", "isFalse", "(", "String", "lhs", ")", "{", "return", "lhs", "+", "\"", "IS", "NOT", "TRUE\"", ";", "}", "public", "static", "String", "isNull", "(", "String", "lhs", ")", "{", "return", "lhs", "+", "\"", "IS", "NULL\"", ";", "}", "public", "static", "String", "isNotNull", "(", "String", "lhs", ")", "{", "return", "lhs", "+", "\"", "IS", "NOT", "NULL\"", ";", "}", "public", "static", "String", "join", "(", "String", "op", ",", "String", "lhs", ",", "String", "rhs", ")", "{", "return", "lhs", "+", "\"", "\"", "+", "op", "+", "\"", "\"", "+", "rhs", ";", "}", "public", "static", "String", "numberJoin", "(", "String", "op", ",", "String", "lhs", ",", "String", "rhs", ",", "int", "offset", ")", "{", "String", "plus", "=", "offset", ">=", "0", "?", "\"", "+", "\"", ":", "\"", "-", "\"", ";", "return", "join", "(", "op", ",", "lhs", ",", "rhs", ")", "+", "plus", "+", "String", ".", "valueOf", "(", "Math", ".", "abs", "(", "offset", ")", ")", ";", "}", "public", "static", "String", "bitSelect", "(", "String", "column", ",", "boolean", "[", "]", "bits", ")", "{", "StringBuilder", "sbBits", "=", "new", "StringBuilder", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "bits", ".", "length", ";", "i", "++", ")", "{", "sbBits", ".", "append", "(", "bits", "[", "i", "]", "?", "\"1\"", ":", "\"0\"", ")", ";", "}", "return", "\"(\"", "+", "column", "+", "\"", "&", "B'\"", "+", "sbBits", ".", "toString", "(", ")", "+", "\"')", "\"", "+", "\"=", "B'\"", "+", "sbBits", ".", "toString", "(", ")", "+", "\"'\"", ";", "}", "public", "static", "String", "between", "(", "String", "lhs", ",", "String", "rhs", ",", "int", "min", ",", "int", "max", ")", "{", "if", "(", "(", "disableBetweenSymmetricPredicate", "||", "disableBetweenPredicate", ")", "&&", "min", ">", "max", ")", "{", "int", "tmp", "=", "min", ";", "min", "=", "max", ";", "max", "=", "tmp", ";", "}", "String", "minPlus", "=", "min", ">=", "0", "?", "\"", "+", "\"", ":", "\"", "-", "\"", ";", "String", "maxPlus", "=", "max", ">=", "0", "?", "\"", "+", "\"", ":", "\"", "-", "\"", ";", "if", "(", "disableBetweenPredicate", ")", "{", "return", "lhs", "+", "\"", ">=", "\"", "+", "rhs", "+", "minPlus", "+", "String", ".", "valueOf", "(", "Math", ".", "abs", "(", "min", ")", ")", "+", "\"", "AND", "\"", "+", "lhs", "+", "\"", "<=", "\"", "+", "rhs", "+", "maxPlus", "+", "String", ".", "valueOf", "(", "Math", ".", "abs", "(", "max", ")", ")", ";", "}", "else", "{", "String", "betweenPredicate", "=", "disableBetweenSymmetricPredicate", "?", "\"BETWEEN\"", ":", "\"\"", ";", "return", "lhs", "+", "\"", "\"", "+", "betweenPredicate", "+", "\"", "\"", "+", "rhs", "+", "minPlus", "+", "String", ".", "valueOf", "(", "Math", ".", "abs", "(", "min", ")", ")", "+", "\"", "AND", "\"", "+", "rhs", "+", "maxPlus", "+", "String", ".", "valueOf", "(", "Math", ".", "abs", "(", "max", ")", ")", ";", "}", "}", "public", "static", "String", "between", "(", "String", "lhs", ",", "int", "min", ",", "int", "max", ")", "{", "if", "(", "(", "disableBetweenSymmetricPredicate", "||", "disableBetweenPredicate", ")", "&&", "min", ">", "max", ")", "{", "int", "tmp", "=", "min", ";", "min", "=", "max", ";", "max", "=", "tmp", ";", "}", "if", "(", "disableBetweenPredicate", ")", "{", "return", "lhs", "+", "\"", ">=", "\"", "+", "min", "+", "\"", "AND", "\"", "+", "lhs", "+", "\"", "<=", "\"", "+", "max", ";", "}", "else", "{", "String", "betweenPredicate", "=", "disableBetweenSymmetricPredicate", "?", "\"BETWEEN\"", ":", "\"\"", ";", "return", "lhs", "+", "\"", "\"", "+", "betweenPredicate", "+", "\"", "\"", "+", "min", "+", "\"", "AND", "\"", "+", "max", ";", "}", "}", "public", "static", "String", "in", "(", "String", "lhs", ",", "String", "rhs", ")", "{", "return", "lhs", "+", "\"", "IN", "(\"", "+", "rhs", "+", "\")\"", ";", "}", "public", "static", "String", "in", "(", "String", "lhs", ",", "Collection", "<", "?", ">", "values", ")", "{", "if", "(", "values", ".", "isEmpty", "(", ")", ")", "{", "return", "in", "(", "lhs", ",", "\"NULL\"", ")", ";", "}", "else", "{", "return", "in", "(", "lhs", ",", "StringUtils", ".", "join", "(", "values", ",", "\",\"", ")", ")", ";", "}", "}", "public", "static", "String", "sqlString", "(", "String", "string", ")", "{", "if", "(", "string", "==", "null", ")", "{", "return", "\"''\"", ";", "}", "else", "{", "return", "\"'\"", "+", "StringUtils", ".", "replace", "(", "string", ",", "\"'\"", ",", "\"''\"", ")", "+", "\"'\"", ";", "}", "}", "public", "static", "String", "sqlString", "(", "String", "string", ",", "TextMatching", "textMatching", ")", "{", "if", "(", "textMatching", "==", "TextMatching", ".", "REGEXP_EQUAL", "||", "textMatching", "==", "TextMatching", ".", "REGEXP_NOT_EQUAL", ")", "{", "string", "=", "\"^(\"", "+", "string", "+", "\")$\"", ";", "}", "return", "sqlString", "(", "string", ")", ";", "}", "public", "static", "boolean", "isDisableBetweenSymmetricPredicate", "(", ")", "{", "return", "disableBetweenSymmetricPredicate", ";", "}", "public", "static", "void", "setDisableBetweenSymmetricPredicate", "(", "boolean", "disableBetweenPredicate", ")", "{", "SqlConstraints", ".", "disableBetweenSymmetricPredicate", "=", "disableBetweenPredicate", ";", "}", "public", "static", "boolean", "isDisableBetweenPredicate", "(", ")", "{", "return", "disableBetweenPredicate", ";", "}", "public", "static", "void", "setDisableBetweenPredicate", "(", "boolean", "disableBetweenPredicate", ")", "{", "SqlConstraints", ".", "disableBetweenPredicate", "=", "disableBetweenPredicate", ";", "}", "}", "</s>" ]
8,799
[ "<s>", "package", "annis", ".", "sqlgen", ";", "import", "static", "java", ".", "util", ".", "Arrays", ".", "asList", ";", "import", "java", ".", "sql", ".", "Array", ";", "import", "java", ".", "sql", ".", "ResultSet", ";", "import", "java", ".", "sql", ".", "SQLException", ";", "import", "java", ".", "util", ".", "Collections", ";", "import", "java", ".", "util", ".", "List", ";", "public", "class", "ArrayCorpusPathExtractor", "implements", "CorpusPathExtractor", "{", "@", "Override", "public", "List", "<", "String", ">", "extractCorpusPath", "(", "ResultSet", "resultSet", ",", "String", "columnName", ")", "throws", "SQLException", "{", "Array", "jdbcArray", "=", "resultSet", ".", "getArray", "(", "columnName", ")", ";", "String", "[", "]", "pathArray", "=", "(", "String", "[", "]", ")", "jdbcArray", ".", "getArray", "(", ")", ";", "List", "<", "String", ">", "path", "=", "asList", "(", "pathArray", ")", ";", "Collections", ".", "reverse", "(", "path", ")", ";", "return", "path", ";", "}", "}", "</s>" ]