@@ -37,107 +37,6 @@ class LinUtils {
37
37
38
38
private static final String [] EMPTY_ARRAY = new String [] {}
39
39
40
- /**
41
- * Query a lineage store.
42
- *
43
- * @param store lineage store to query.
44
- * @param uri Query to perform in a URI-like format.
45
- * Format 'lid://<key>[?QueryString][#fragment]' where:
46
- * - Key: Element where the query will be applied. '/' indicates query will be applied in all the elements of the lineage store.
47
- * - QueryString: all param-value pairs that the lineage element should fulfill in a URI's query string format.
48
- * - Fragment: Element fragment to retrieve.
49
- * @return Collection of object fulfilling the query
50
- */
51
- static Collection query (LinStore store , URI uri ) {
52
- String key = uri. authority ? uri. authority + uri. path : uri. path
53
- if (key == LinPath . SEPARATOR ) {
54
- return globalSearch(store, uri)
55
- } else {
56
- final parameters = uri. query ? parseQuery(uri. query) : null
57
- final children = parseChildrenFromFragment(uri. fragment)
58
- return searchPath(store, key, parameters, children )
59
- }
60
- }
61
-
62
- private static Collection<LinSerializable > globalSearch (LinStore store , URI uri ) {
63
- final results = store. search(uri. query). values()
64
- if (results && uri. fragment) {
65
- // If fragment is defined get the property of the object indicated by the fragment
66
- return filterResults(results, uri. fragment)
67
- }
68
- return results
69
- }
70
-
71
- private static List filterResults (Collection<LinSerializable > results , String fragment ) {
72
- final filteredResults = []
73
- results. forEach {
74
- final output = navigate(it, fragment)
75
- if (output) {
76
- filteredResults. add(output)
77
- }
78
- }
79
- return filteredResults
80
- }
81
-
82
- /**
83
- * Get the array of the search path children elements from the fragment string
84
- *
85
- * @param fragment String containing the elements separated by '.'
86
- * @return array with the parsed element
87
- */
88
- static String [] parseChildrenFromFragment (String fragment ) {
89
- if ( ! fragment )
90
- return EMPTY_ARRAY
91
- final children = fragment. tokenize(' .' )
92
- new LinPropertyValidator (). validate(children)
93
- return children as String []
94
- }
95
-
96
- /**
97
- * Search for objects inside a description
98
- *
99
- * @param store lineage store
100
- * @param key lineage key where to perform the search
101
- * @param params Parameter-value pairs to be evaluated in the key
102
- * @param children Sub-objects to evaluate and retrieve
103
- * @return List of object
104
- */
105
- protected static List<Object > searchPath (LinStore store , String key , Map<String , String > params , String [] children = []) {
106
- final object = store. load(key)
107
- if (! object) {
108
- throw new FileNotFoundException (" Lineage object $key not found" )
109
- }
110
- final results = new LinkedList<Object > ()
111
- if (children && children. size() > 0 ) {
112
- treatSubObject(store, key, object, children, params, results)
113
- } else {
114
- treatObject(object, params, results)
115
- }
116
-
117
- return results
118
- }
119
-
120
- private static void treatSubObject (LinStore store , String key , LinSerializable object , String [] children , Map<String , String > params , LinkedList<Object > results ) {
121
- final output = getSubObject(store, key, object, children)
122
- if (! output) {
123
- throw new FileNotFoundException (" Lineage object $key #${ children.join('.')} not found" )
124
- }
125
- treatObject(output, params, results)
126
- }
127
-
128
- /**
129
- * Get a metadata sub-object.
130
- *
131
- * @param store Store to retrieve lineage metadata objects.
132
- * @param key Parent metadata key.
133
- * @param object Parent object.
134
- * @param children Array of string in indicating the properties to navigate to get the sub-object.
135
- * @return Sub-object or null in it does not exist.
136
- */
137
- static Object getSubObject (LinStore store , String key , LinSerializable object , String [] children ) {
138
- return navigate(object, children. join(' .' ))
139
- }
140
-
141
40
/**
142
41
* Evaluates object or the objects in a collection matches a set of parameter-value pairs. It includes in the results collection in case of match.
143
42
*
@@ -157,23 +56,6 @@ class LinUtils {
157
56
}
158
57
}
159
58
160
- /**
161
- * Parses a query string and store them in parameter-value Map.
162
- *
163
- * @param queryString URI-like query string. (e.g. param1=value1¶m2=value2).
164
- * @return Map containing the parameter-value pairs of the query string.
165
- */
166
- static Map<String , String > parseQuery (String queryString ) {
167
- if ( ! queryString ) {
168
- return [:]
169
- }
170
- final params = queryString. split(' &' ). collectEntries {
171
- it. split(' =' ). collect { URLDecoder . decode(it, ' UTF-8' ) }
172
- } as Map<String , String >
173
- new LinPropertyValidator (). validateQueryParams(params)
174
- return params
175
- }
176
-
177
59
/**
178
60
* Check if an object fulfill the parameter-value
179
61
*
0 commit comments