/*
 * Copyright 2012 SFB 632.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package annis.service.objects;

import java.io.Serializable;

import java.util.Map;
import java.util.TreeMap;
import javax.xml.bind.annotation.XmlRootElement;

/**
 * This class is only a wrapper to transport the salt ids with the
 * {@link QueryData} class as extension.
 *
 * @author Benjamin Weißenfels <b.pixeldrama@gmail.com>
 */
@XmlRootElement
public class SaltURIGroupSet implements Serializable
{
  private Map<Integer, SaltURIGroup> groups;
  
  public SaltURIGroupSet()
  {
    groups = new TreeMap<Integer, SaltURIGroup>();
  }

  public Map<Integer, SaltURIGroup> getGroups()
  {
    return groups;
  }

  public void setGroups(Map<Integer, SaltURIGroup> groups)
  {
    this.groups = groups;
  }
  
  
}

@@ -629,28 +629,172 @@
 ort 
-java.io.Serializable
+annis.CommonHelper;%0Aimport annis.model.QueryNode;%0Aimport java.io.Serializable;%0Aimport java.net.URISyntaxException;%0Aimport java.util.ArrayList;%0Aimport java.util.List
 ;%0A%0Ai
@@ -810,24 +810,46 @@
 a.util.Map;%0A
+import java.util.Set;%0A
 import java.
@@ -858,24 +858,50 @@
 il.TreeMap;%0A
+import java.util.TreeSet;%0A
 import javax
@@ -936,16 +936,73 @@
 Element;
+%0Aimport org.slf4j.Logger;%0Aimport org.slf4j.LoggerFactory;
 %0A%0A/**%0A *
@@ -1241,16 +1241,103 @@
 zable%0A%7B%0A
+  private static final Logger log = LoggerFactory.getLogger(SaltURIGroupSet.class);%0A  %0A
   privat
@@ -1376,16 +1376,19 @@
 ups;%0A  %0A
+  %0A
   public
@@ -1601,24 +1601,24 @@
 groups)%0A  %7B%0A
-
     this.gro
@@ -1638,13 +1638,1146 @@
 %0A  %7D%0A  %0A
+  /**%0A   * Parses a string representation of a %7B@link SaltURIGroupSet%7D. %0A   * Each group is separated with a %22;%22 and each Salt ID with a %22,%22.%0A   * Example: %0A   * %7B@code %0A   * salt://id1,salt://id2,salt://id3;salt://id4,salt://id5;salt://id6%0A   * %7D%0A   * %0A   * @param raw%0A   * @return %0A   */%0A  public static SaltURIGroupSet fromString(String raw)%0A  %7B%0A    SaltURIGroupSet saltIDs = new SaltURIGroupSet();%0A%0A%0A    int i = 0;%0A    for (String group : raw.split(%22%5C%5Cs*;%5C%5Cs*%22))%0A    %7B%0A      SaltURIGroup urisForGroup = new SaltURIGroup();%0A%0A      for (String id : group.split(%22%5B,%5C%5Cs%5D+%22))%0A      %7B%0A        java.net.URI uri;%0A        try%0A        %7B%0A          uri = new java.net.URI(id);%0A%0A          if (!%22salt%22.equals(uri.getScheme()) %7C%7C uri.getFragment() == null)%0A          %7B%0A            throw new URISyntaxException(%22not a Salt id%22, uri.toString());%0A          %7D%0A        %7D%0A        catch (URISyntaxException ex)%0A        %7B%0A          log.error(%22Invalid syntax for ID %22 + id, ex);%0A          continue;%0A        %7D%0A        urisForGroup.getUris().add(uri);%0A      %7D%0A      %0A      saltIDs.getGroups().put(++i, urisForGroup);%0A    %7D%0A    %0A    return saltIDs;%0A  %7D%0A  %0A
   %0A%7D%0A

allow to parse raw strings in SaltURIGroupSet