Project

General

Profile

« Previous | Next » 

Revision 036b973d

Added by Andreas Kohlbecker almost 4 years ago

ref #9146 media metadata service method with cdm property based include and exclude filter definitions

View differences:

cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/metadata/CdmPreference.java
13 13
import java.util.Arrays;
14 14
import java.util.List;
15 15
import java.util.UUID;
16
import java.util.stream.Collectors;
16 17

  
17 18
import javax.persistence.Column;
18 19
import javax.persistence.Embeddable;
......
52 53
@Entity
53 54
public final class CdmPreference implements Serializable {
54 55

  
56
    /**
57
     *
58
     */
59
    private static final String STRING_LIST_SEPARATOR = "[,;\\s]";
60

  
55 61
    private static final int VALUE_LENGTH = 65536; //= CdmBase.CLOB_LENGTH;
56 62

  
57 63
    private static final long serialVersionUID = 4307599154287181582L;
......
291 297
	 * @throws IllegalArgumentException
292 298
	 */
293 299
	public List<UUID> getValueUuidList() throws IllegalArgumentException {
300

  
294 301
	    List<UUID> result = new ArrayList<>();
295
	    if (StringUtils.isBlank(value)){
296
	        return result;
297
	    }
298
	    String[] splits = getValue().split("[,;]");
299
	    for (String split : splits ){
300
	        try {
301
                if (StringUtils.isBlank(split)){
302
                    continue; //neglect trailing separators
303
                }
304
	            UUID uuid = UUID.fromString(split.trim());
305
                result.add(uuid);
306
            } catch (IllegalArgumentException e) {
307
                throw e;
308
            }
302
	    for (String split : splitStringListValue()){
303
            UUID uuid = UUID.fromString(split.trim());
304
            result.add(uuid);
309 305
	    }
306

  
310 307
	    return result;
311 308
    }
312 309

  
310
	/**
311
	 * Splits the <code>value</code> into tokens by the separators defined in {@link #STRING_LIST_SEPARATOR}
312
	 *
313
	 * @return
314
	 */
315
    public  List<String> splitStringListValue() {
316
        List<String> tokens;
317
        if (!StringUtils.isBlank(value)){
318
	        tokens = Arrays.stream(getValue().split(STRING_LIST_SEPARATOR)).filter(t -> !StringUtils.isBlank(t)).collect(Collectors.toList());
319
	    } else {
320
	        tokens = new ArrayList<>();
321
	    }
322
        return tokens;
323
    }
324

  
313 325

  
314 326

  
315 327
    /**

Also available in: Unified diff