コード例 #1
0
 private static SubsetSelection getObjectPaths(final ObjectSpecification o) {
   if (o.getIncluded() != null && !o.getIncluded().isEmpty()) {
     return new SubsetSelection(
         o.getIncluded(),
         longToBoolean(o.getStrictMaps(), SubsetSelection.STRICT_MAPS_DEFAULT),
         longToBoolean(o.getStrictArrays(), SubsetSelection.STRICT_ARRAYS_DEFAULT));
   }
   return null;
 }
コード例 #2
0
 private static void mutateObjSpecByRefString(final ObjectSpecification o) {
   if (o.getRef() == null) {
     return;
   }
   final String[] reflist = o.getRef().trim().split(";");
   o.setRef(reflist[0].trim());
   final List<String> refs = new LinkedList<>();
   for (int i = 1; i < reflist.length; i++) {
     refs.add(reflist[i].trim());
   }
   if (!refs.isEmpty()) {
     if (countRefPathsInObjectSpec(o) > 0) {
       throw new IllegalArgumentException(
           "Only one of the 6 options for specifying an " + "object reference path is allowed");
     }
     o.setObjRefPath(refs);
   }
 }
コード例 #3
0
 private static int countRefPathsInObjectSpec(final ObjectSpecification o) {
   int count = 0;
   // there's probably some obnoxiously smarter way to do this
   if (o.getObjPath() != null && !o.getObjPath().isEmpty()) {
     count++;
   }
   if (o.getObjRefPath() != null && !o.getObjRefPath().isEmpty()) {
     count++;
   }
   if (o.getToObjPath() != null && !o.getToObjPath().isEmpty()) {
     count++;
   }
   if (o.getToObjRefPath() != null && !o.getToObjRefPath().isEmpty()) {
     count++;
   }
   if (longToBoolean(o.getFindReferencePath())) {
     count++;
   }
   return count;
 }
コード例 #4
0
  public static List<ObjectIdentifier> processObjectSpecifications(
      final List<ObjectSpecification> objects) {

    if (objects == null) {
      throw new NullPointerException("The object specification list cannot be null");
    }
    if (objects.isEmpty()) {
      throw new IllegalArgumentException("No object specifications provided");
    }
    final List<ObjectIdentifier> objs = new LinkedList<ObjectIdentifier>();
    int objcount = 1;
    for (final ObjectSpecification o : objects) {
      if (o == null) {
        throw new NullPointerException("Objects in the object specification list cannot be null");
      }
      final ObjectIdentifier oi;
      try {
        mutateObjSpecByRefString(o);
        oi =
            processObjectIdentifier(
                new ObjectIdentity()
                    .withWorkspace(o.getWorkspace())
                    .withWsid(o.getWsid())
                    .withName(o.getName())
                    .withObjid(o.getObjid())
                    .withVer(o.getVer())
                    .withRef(o.getRef()));
        checkAddlArgs(o.getAdditionalProperties(), o.getClass());
      } catch (IllegalArgumentException e) {
        throw new IllegalArgumentException(
            "Error on ObjectSpecification #" + objcount + ": " + e.getLocalizedMessage(), e);
      }
      objs.add(buildObjectIdentifier(o, oi, objcount));
      objcount++;
    }
    return objs;
  }
コード例 #5
0
 private static ObjectIdentifier buildObjectIdentifier(
     final ObjectSpecification o, ObjectIdentifier oi, final int objcount) {
   final SubsetSelection paths = getObjectPaths(o);
   final List<ObjectIdentifier> refchain;
   try {
     final RefChainResult res = processRefChains(o);
     if (res == null) {
       refchain = null;
     } else if (res.isToPath) {
       refchain = new LinkedList<>();
       if (res.path.size() > 1) {
         refchain.addAll(res.path.subList(1, res.path.size()));
       }
       refchain.add(oi);
       oi = res.path.get(0);
     } else {
       refchain = res.path;
     }
   } catch (IllegalArgumentException e) {
     throw new IllegalArgumentException(
         "Error on ObjectSpecification #" + objcount + ": " + e.getLocalizedMessage(), e);
   }
   final boolean searchDAG = longToBoolean(o.getFindReferencePath());
   if (paths == null && refchain == null && !searchDAG) {
     return oi;
   } else if (paths == null) {
     if (searchDAG) {
       return new ObjectIDWithRefPath(oi);
     } else {
       return new ObjectIDWithRefPath(oi, refchain);
     }
   } else {
     if (searchDAG) {
       return new ObjIDWithRefPathAndSubset(oi, paths);
     } else {
       return new ObjIDWithRefPathAndSubset(oi, refchain, paths);
     }
   }
 }
コード例 #6
0
 private static RefChainResult processRefChains(final ObjectSpecification o) {
   if (countRefPathsInObjectSpec(o) > 1) {
     throw new IllegalArgumentException(
         "Only one of the 6 options " + "for specifying an object reference path is allowed");
   }
   if (o.getObjPath() != null && !o.getObjPath().isEmpty()) {
     return new RefChainResult(processObjectPath(o.getObjPath(), false), false);
   } else if (o.getToObjPath() != null && !o.getToObjPath().isEmpty()) {
     return new RefChainResult(processObjectPath(o.getToObjPath(), true), true);
   }
   if (o.getObjRefPath() != null && !o.getObjRefPath().isEmpty()) {
     return new RefChainResult(processRefPath(o.getObjRefPath(), false), false);
   } else if (o.getToObjRefPath() != null && !o.getToObjRefPath().isEmpty()) {
     return new RefChainResult(processRefPath(o.getToObjRefPath(), true), true);
   }
   return null;
 }