public void testTypes() throws Exception {
    assertTrue(!FilterUtils.areProperSubset(tf1, tf2));
    assertTrue(FilterUtils.areProperSubset(tf1, tf1));

    assertTrue(FilterUtils.areDisjoint(tf1, tf2));
    assertTrue(!FilterUtils.areDisjoint(tf1, tf1));
  }
  public void testOrAncestorDescendants() {
    FeatureFilter type_foo = new FeatureFilter.ByType("foo");
    FeatureFilter type_bar = new FeatureFilter.ByType("bar");
    FeatureFilter test = new FeatureFilter.ByAncestor(new FeatureFilter.OnlyDescendants(type_foo));

    assertTrue(FilterUtils.areDisjoint(type_bar, test));
    assertTrue(!FilterUtils.areDisjoint(type_foo, test));
  }
 public void testParentAncestor() throws Exception {
   assertTrue(
       FilterUtils.areProperSubset(parent_cf_ComponentFeature, ancestor_cf_ComponentFeature));
   assertTrue(
       !FilterUtils.areProperSubset(ancestor_cf_ComponentFeature, parent_cf_ComponentFeature));
   assertTrue(
       FilterUtils.areDisjoint(ancestor_cf_ComponentFeature, not_ancestor_cf_ComponentFeature));
   assertTrue(
       FilterUtils.areDisjoint(not_ancestor_cf_ComponentFeature, parent_cf_ComponentFeature));
 }
  public void testAncestorLeafChildren() {
    FeatureFilter type_foo = new FeatureFilter.ByType("foo");
    FeatureFilter type_bar = new FeatureFilter.ByType("bar");
    FeatureFilter test =
        new FeatureFilter.ByAncestor(
            new FeatureFilter.OnlyChildren(new FeatureFilter.And(type_foo, FeatureFilter.leaf)));
    FeatureFilter test_nonleaf =
        new FeatureFilter.ByAncestor(new FeatureFilter.OnlyChildren(type_foo));

    assertTrue(FilterUtils.areDisjoint(type_bar, test));
    assertTrue(!FilterUtils.areDisjoint(type_bar, test_nonleaf));
    assertTrue(!FilterUtils.areDisjoint(type_foo, test));
  }
 public void testDisjointAnnotationTypesContains() {
   AnnotationType atype = new AnnotationType.Impl();
   atype.setDefaultConstraints(PropertyConstraint.NONE, CardinalityConstraint.ZERO);
   atype.setConstraints("foo", PropertyConstraint.ANY, CardinalityConstraint.ONE);
   assertTrue(
       FilterUtils.areDisjoint(
           new FeatureFilter.ByAnnotationType(atype),
           new FeatureFilter.AnnotationContains("bar", "some_value")));
   assertTrue(
       !FilterUtils.areDisjoint(
           new FeatureFilter.ByAnnotationType(atype),
           new FeatureFilter.AnnotationContains("foo", "some_value")));
 }
  public void testParentChildren() {
    FeatureFilter type_foo = new FeatureFilter.ByType("foo");
    FeatureFilter type_bar = new FeatureFilter.ByType("bar");
    FeatureFilter type_baz = new FeatureFilter.ByType("baz");
    FeatureFilter test =
        new FeatureFilter.ByParent(
            new FeatureFilter.OnlyChildren(
                new FeatureFilter.And(
                    type_foo,
                    new FeatureFilter.OnlyChildren(
                        new FeatureFilter.And(type_baz, FeatureFilter.leaf)))));

    assertTrue(FilterUtils.areDisjoint(type_bar, test));
    assertTrue(!FilterUtils.areDisjoint(type_foo, test));
    assertTrue(FilterUtils.areDisjoint(type_baz, test));
  }
 /* (non-Javadoc)
  * @see fr.umlv.smoreau.beontime.filter.Filter#getQueryHQL()
  */
 public String getHQLQuery() {
   try {
     return FilterUtils.createHQLQuery(this, corres);
   } catch (Exception e) {
     throw new RuntimeException("Erreur lors de l'introspection", e);
   }
 }
  public void testOrOptimizeAllNone() {
    optimizeExact(all_or_all, FilterUtils.all());
    optimizeExact(FilterUtils.or(all_or_all, all_or_all), FilterUtils.all());

    optimizeExact(all_or_none, FilterUtils.all());
    optimizeExact(FilterUtils.or(all_or_none, FilterUtils.none()), FilterUtils.all());

    optimizeExact(none_or_none, FilterUtils.none());
  }
  public void testAndOptimizeAllNone() {
    optimizeExact(all_and_all, FilterUtils.all());
    optimizeExact(FilterUtils.and(all_and_all, all_and_all), FilterUtils.all());

    optimizeExact(all_and_none, FilterUtils.none());
    optimizeExact(FilterUtils.and(all_and_none, FilterUtils.all()), FilterUtils.none());

    optimizeExact(none_and_none, FilterUtils.none());
  }
 public MaterialFilter(Material material) {
   super();
   try {
     FilterUtils.fillFilterClass(this, material, corres.keySet());
   } catch (Exception e) {
     throw new RuntimeException("Erreur lors de l'introspection", e);
   }
 }
Exemple #11
0
  protected Filter(String name, Icon icon) {
    assert name != null;

    putValue(Action.SMALL_ICON, icon);
    putValue(Action.NAME, name);

    FilterUtils.addFilter(this);
  }
  public void testOr() throws Exception {
    assertTrue(FilterUtils.areProperSubset(tf1, tf1_or_tf2));
    assertTrue(!FilterUtils.areDisjoint(tf1, tf1_or_tf2));
    assertTrue(FilterUtils.areDisjoint(tf3, tf1_or_tf2));

    assertTrue(!FilterUtils.areProperSubset(tf1_or_tf2, tf2_or_tf3));
    assertTrue(!FilterUtils.areDisjoint(tf1_or_tf2, tf2_or_tf3));

    assertTrue(FilterUtils.areProperSubset(tf1_or_tf2, tf1_or_tf2_or_tf3));
    assertTrue(FilterUtils.areProperSubset(tf2_or_tf3, tf1_or_tf2_or_tf3));
    assertTrue(FilterUtils.areProperSubset(tf1_or_tf3, tf1_or_tf2_or_tf3));
  }
Exemple #13
0
 /**
  * Obtiene el certificado de firma asociado a un certificado de autenticación dado.
  *
  * @param ksm Gestor del almacen en donde se encuentran los certificados.
  * @param cert Certificado de autenticación del que encontrar el asociado.
  * @param aliases Alias de los certificados del almacén.
  * @param pos Posición del listado de alias en el que se encuentra el alias del certificado
  *     del que se busca pareja.
  * @return Alias del certificado asociado o {@code null} si no se encuentra.
  */
 private String getAssociatedCertAlias(
     final KeyStoreManager ksm,
     final X509Certificate cert,
     final String[] aliases,
     final int pos) {
   X509Certificate tempCert;
   for (int j = 0; j < aliases.length; j++) {
     if (pos != j) {
       tempCert = ksm.getCertificate(aliases[j]);
       if (this.isSignatureDnieCert(tempCert)
           && FilterUtils.getSubjectSN(tempCert) != null
           && FilterUtils.getSubjectSN(tempCert).equalsIgnoreCase(FilterUtils.getSubjectSN(cert))
           && SSLFilter.getExpiredDate(tempCert).equals(SSLFilter.getExpiredDate(cert))) {
         return aliases[j];
       }
     }
   }
   return null;
 }
  public void testByProperty() throws Exception {
    assertTrue("are disjoint: " + pf4 + ", " + pf5, FilterUtils.areDisjoint(pf4, pf5));
    assertTrue("not disjoint: " + pf4 + ", " + pf6, !FilterUtils.areDisjoint(pf4, pf6));
    assertTrue("not disjoint: " + pf5 + ", " + pf6, !FilterUtils.areDisjoint(pf5, pf6));

    assertTrue("not subset: " + pf4 + ", " + pf5, !FilterUtils.areProperSubset(pf4, pf5));
    assertTrue("not subset: " + pf4 + ", " + pf6, !FilterUtils.areProperSubset(pf4, pf6));
    assertTrue("not subset: " + pf5 + ", " + pf6, !FilterUtils.areProperSubset(pf5, pf6));

    assertTrue("are subset: " + pf4 + ", " + pf4, FilterUtils.areProperSubset(pf4, pf4));
  }
  public void testNot() throws Exception {
    assertTrue(FilterUtils.areProperSubset(ntf1, ntf1));
    assertTrue(!FilterUtils.areDisjoint(ntf1, ntf1));

    assertTrue(FilterUtils.areDisjoint(tf1, ntf1));
    assertTrue(!FilterUtils.areProperSubset(tf1, ntf1));

    assertTrue(!FilterUtils.areDisjoint(tf2, ntf1));
    assertTrue(FilterUtils.areProperSubset(tf2, ntf1));
  }
Exemple #16
0
 @Override
 public void configure(DocumentReader reader, Element element) {
   bitrates.clear();
   try {
     for (Element bitrate :
         DocumentReader.getChildElements(reader.getElementByPath(element, CONFIG_TAG))) {
       BitrateInfo bri = new BitrateInfo(bitrate);
       log.debug("Adding BitrateInfo " + bri);
       bitrates.put(bri.getName(), bri);
     }
   } catch (Exception ex) {
     log.error("Error in filter.xml:" + ex, ex);
   }
   log.info("Configured bit rate labeler " + bitrates);
   FilterUtils.propertiesConfigure(this, reader, element);
 }
  public void testLocation() throws Exception {
    // Simple comparison of locations.

    assertTrue(FilterUtils.areProperSubset(olf1, olf1));
    assertTrue(!FilterUtils.areProperSubset(olf1, olf2));
    assertTrue(!FilterUtils.areDisjoint(olf1, olf1));

    // Assymetry between containment and overlapping

    assertTrue(FilterUtils.areProperSubset(clf1, olf1));
    assertTrue(!FilterUtils.areProperSubset(olf1, clf1));

    assertTrue(FilterUtils.areDisjoint(olf1, clf2));
    assertTrue(FilterUtils.areDisjoint(clf1, olf2));
  }
Exemple #18
0
 public static <C extends Containerable> ExistsFilter createExists(
     ItemPath itemPath, Class<C> clazz, PrismContext prismContext, ObjectFilter filter)
     throws SchemaException {
   ItemDefinition itemDefinition = FilterUtils.findItemDefinition(itemPath, clazz, prismContext);
   return new ExistsFilter(itemPath, itemDefinition, filter);
 }
Exemple #19
0
 /**
  * Recupera el n&uacute;mero de serie de un certificado en formato hexadecimal. Los ceros ('0') a
  * la izquierda del n&uacute;mero de serie se eliminan durante el proceso. Si el certificado no
  * tiene n&uacute;mero de serie, devolver&aacute; {@code null}.
  *
  * @param cert Certificado.
  * @return Numero de serie en hexadecimal.
  */
 private static String getCertificateSN(final X509Certificate cert) {
   return FilterUtils.bigIntegerToHex(cert.getSerialNumber());
 }
Exemple #20
0
  /** {@inheritDoc} */
  public void doFilter(ServletRequest req, ServletResponse resp, FilterChain chain)
      throws IOException, ServletException {
    // According to CORS spec OPTIONS method does not pass auth info
    if (((HttpServletRequest) req).getMethod().equals("OPTIONS")) {
      chain.doFilter(req, resp);
      return;
    }
    Object auth = null;
    int numberOfTries = 0;
    if (!appConfig.isInitialized()) {
      appConfig.initialize(filterConfig, req);
    }
    int retries = appConfig.getRetries();
    long pauseTime = appConfig.getPauseTime();

    // Extract credential
    String token = ((HttpServletRequest) req).getHeader(TOKEN);

    if (token == null) {
      if (!appConfig.isDelayAuthDecision()) {
        logger.error(HttpServletResponse.SC_UNAUTHORIZED + " No token found.");
        ((HttpServletResponse) resp).sendError(HttpServletResponse.SC_UNAUTHORIZED, TOKEN_NOTFOUND);
        return;
      } else {
        logger.info("No token found...Skipping");
      }
    } else {
      do {
        try {
          auth = FilterUtils.getCachedToken(token);
        } catch (ServiceUnavailableException e) {
          if (numberOfTries < retries) {
            FilterUtils.pause(pauseTime);
            logger.debug("Retrying connection after " + pauseTime + " seconds.");
            numberOfTries++;
            continue;
          } else {
            logger.debug("Exhausted retries..");
            TokenExceptionHandler handler =
                TokenExceptionHandler.valueOf("ServiceUnavailableException");
            handler.onException(e, resp, token);
          }
          return;
        } catch (ClientProtocolException e) {
          if (numberOfTries < retries) {
            FilterUtils.pause(pauseTime);
            logger.debug("Retrying connection after " + pauseTime + " seconds.");
            numberOfTries++;
            continue;
          } else {
            logger.debug("Exhausted retries..");
            TokenExceptionHandler handler =
                TokenExceptionHandler.valueOf("ClientProtocolException");
            handler.onException(e, resp, token);
          }
          return;
        } catch (UncheckedExecutionException e) {
          final TokenExceptionHandler handler;
          final Exception toHandle;
          if ((e.getCause() != null) && e.getCause() instanceof AdminAuthException) {
            toHandle = (AdminAuthException) e.getCause();
            handler = TokenExceptionHandler.valueOf("AdminAuthException");
          } else if ((e.getCause() != null) && e.getCause() instanceof AuthException) {
            toHandle = (AuthException) e.getCause();
            handler = TokenExceptionHandler.valueOf("AuthException");
          } else {
            toHandle = e;
            handler = TokenExceptionHandler.valueOf("UncheckedExecutionException");
          }
          handler.onException(toHandle, resp, token);
          return;
        }

      } while (auth == null && numberOfTries <= retries);
    }
    req = FilterUtils.wrapRequest(req, auth);
    logger.debug("TokenAuth: Forwarding down stream to next filter/servlet");
    // Forward downstream...
    chain.doFilter(req, resp);
  }
 private void optimizeEquals(FeatureFilter raw, FeatureFilter target) {
   FeatureFilter result = FilterUtils.optimize(raw);
   assertTrue(
       "optimize: " + raw + " should be " + target + " but is " + result, result.equals(target));
 }
 public void testByClass() throws Exception {
   assertTrue(FilterUtils.areProperSubset(cf_HomologyFeature, cf_StrandedFeature));
   assertTrue(FilterUtils.areProperSubset(cf_ComponentFeature, cf_StrandedFeature));
   assertTrue(FilterUtils.areDisjoint(cf_ComponentFeature, cf_HomologyFeature));
 }
 public void testAndOr() throws Exception {
   assertTrue(FilterUtils.areProperSubset(pf1_and_tf1, pf1_AND_tf1_or_tf2));
   assertTrue(FilterUtils.areProperSubset(pf1_and_pf2_and_tf1, pf1_and_pf2_OR_tf1));
 }
  public void testAnd() throws Exception {
    // all_and_all vs all
    assertTrue(
        "are subset: " + all_and_all + ", " + FeatureFilter.all,
        FilterUtils.areProperSubset(all_and_all, FeatureFilter.all));
    assertTrue(
        "not disjoint: " + all_and_all + ", " + FeatureFilter.all,
        !FilterUtils.areDisjoint(all_and_all, FeatureFilter.all));
    assertTrue(
        "are subset: " + FeatureFilter.all + ", " + all_and_all,
        FilterUtils.areProperSubset(FeatureFilter.all, all_and_all));
    assertTrue(
        "not disjoint: " + FeatureFilter.all + ", " + all_and_all,
        !FilterUtils.areDisjoint(FeatureFilter.all, all_and_all));

    // all_and_all vs none
    assertTrue(
        "not subset: " + all_and_all + ", " + FeatureFilter.none,
        !FilterUtils.areProperSubset(all_and_all, FeatureFilter.none));
    assertTrue(
        "are disjoint: " + all_and_all + ", " + FeatureFilter.none,
        FilterUtils.areDisjoint(all_and_all, FeatureFilter.none));
    assertTrue(
        "are subset: " + FeatureFilter.none + ", " + all_and_all,
        FilterUtils.areProperSubset(FeatureFilter.none, all_and_all));
    assertTrue(
        "are disjoint: " + FeatureFilter.none + ", " + all_and_all,
        FilterUtils.areDisjoint(FeatureFilter.none, all_and_all));

    // all_and_none vs all
    assertTrue(
        "are subset: " + all_and_none + ", " + FeatureFilter.all,
        FilterUtils.areProperSubset(all_and_none, FeatureFilter.all));
    assertTrue(
        "are disjoint: " + all_and_none + ", " + FeatureFilter.all,
        FilterUtils.areDisjoint(all_and_none, FeatureFilter.all));
    assertTrue(
        "not subset: " + FeatureFilter.all + ", " + all_and_none,
        !FilterUtils.areProperSubset(FeatureFilter.all, all_and_none));
    assertTrue(
        "are disjoint: " + FeatureFilter.all + ", " + all_and_none,
        FilterUtils.areDisjoint(FeatureFilter.all, all_and_none));

    // all_and_none vs none
    assertTrue(
        "are subset: " + all_and_none + ", " + FeatureFilter.none,
        FilterUtils.areProperSubset(all_and_none, FeatureFilter.none));
    assertTrue(
        "are disjoint: " + all_and_none + ", " + FeatureFilter.none,
        FilterUtils.areDisjoint(all_and_none, FeatureFilter.none));
    assertTrue(
        "are subset: " + FeatureFilter.none + ", " + all_and_none,
        FilterUtils.areProperSubset(FeatureFilter.none, all_and_none));
    assertTrue(
        "are disjoint: " + FeatureFilter.none + ", " + all_and_none,
        FilterUtils.areDisjoint(FeatureFilter.none, all_and_none));

    // none_and_all vs all
    assertTrue(
        "are subset: " + none_and_all + ", " + FeatureFilter.all,
        FilterUtils.areProperSubset(none_and_all, FeatureFilter.all));
    assertTrue(
        "are disjoint: " + none_and_all + ", " + FeatureFilter.all,
        FilterUtils.areDisjoint(none_and_all, FeatureFilter.all));
    assertTrue(
        "not subset: " + FeatureFilter.all + ", " + none_and_all,
        !FilterUtils.areProperSubset(FeatureFilter.all, none_and_all));
    assertTrue(
        "are disjoint: " + FeatureFilter.all + ", " + none_and_all,
        FilterUtils.areDisjoint(FeatureFilter.all, none_and_all));

    // none_and_all vs none
    assertTrue(
        "are subset: " + none_and_all + ", " + FeatureFilter.none,
        FilterUtils.areProperSubset(none_and_all, FeatureFilter.none));
    assertTrue(
        "are disjoint: " + none_and_all + ", " + FeatureFilter.none,
        FilterUtils.areDisjoint(none_and_all, FeatureFilter.none));
    assertTrue(
        "are subset: " + FeatureFilter.none + ", " + none_and_all,
        FilterUtils.areProperSubset(FeatureFilter.none, none_and_all));
    assertTrue(
        "are disjoint: " + FeatureFilter.none + ", " + none_and_all,
        FilterUtils.areDisjoint(FeatureFilter.none, none_and_all));

    // none_and_none vs all
    assertTrue(
        "are subset: " + none_and_none + ", " + FeatureFilter.all,
        FilterUtils.areProperSubset(none_and_none, FeatureFilter.all));
    assertTrue(
        "are disjoint: " + none_and_none + ", " + FeatureFilter.all,
        FilterUtils.areDisjoint(none_and_none, FeatureFilter.all));
    assertTrue(
        "not subset: " + FeatureFilter.all + ", " + none_and_none,
        !FilterUtils.areProperSubset(FeatureFilter.all, none_and_none));
    assertTrue(
        "are disjoint: " + FeatureFilter.all + ", " + none_and_none,
        FilterUtils.areDisjoint(FeatureFilter.all, none_and_none));

    // none_and_none vs none
    assertTrue(
        "are subset: " + none_and_none + ", " + FeatureFilter.none,
        FilterUtils.areProperSubset(none_and_none, FeatureFilter.none));
    assertTrue(
        "are disjoint: " + none_and_none + ", " + FeatureFilter.none,
        FilterUtils.areDisjoint(none_and_none, FeatureFilter.none));
    assertTrue(
        "are subset: " + FeatureFilter.none + ", " + none_and_none,
        FilterUtils.areProperSubset(FeatureFilter.none, none_and_none));
    assertTrue(
        "are disjoint: " + FeatureFilter.none + ", " + none_and_none,
        FilterUtils.areDisjoint(FeatureFilter.none, none_and_none));

    // pf1_and_pf2 vs pf1, pf2
    assertTrue(
        "are subset: " + pf1_and_pf2 + ", " + pf1, FilterUtils.areProperSubset(pf1_and_pf2, pf1));
    assertTrue(
        "not disjoint: " + pf1_and_pf2 + ", " + pf1, !FilterUtils.areDisjoint(pf1_and_pf2, pf1));
    assertTrue(
        "are subset: " + pf1_and_pf2 + ", " + pf2, FilterUtils.areProperSubset(pf1_and_pf2, pf2));
    assertTrue(
        "not disjoint: " + pf1_and_pf2 + ", " + pf2, !FilterUtils.areDisjoint(pf1_and_pf2, pf2));

    assertTrue(
        "not subset: " + pf1_and_pf2 + ", " + pf3, !FilterUtils.areProperSubset(pf1_and_pf2, pf3));
    assertTrue(
        "not subset: " + pf2_and_pf3 + ", " + pf1_and_pf2,
        !FilterUtils.areProperSubset(pf2_and_pf3, pf1_and_pf2));
    assertTrue(
        "are subset: " + pf1_and_pf2_and_pf3 + ", " + pf1_and_pf2,
        FilterUtils.areProperSubset(pf1_and_pf2_and_pf3, pf1_and_pf2));
    assertTrue(
        "are subset: " + pf1_and_pf2_and_pf3 + ", " + pf2_and_pf3,
        FilterUtils.areProperSubset(pf1_and_pf2_and_pf3, pf2_and_pf3));

    assertTrue(
        "are subset: " + pf1_and_pf2_and_tf1 + ", " + pf1_and_pf2,
        FilterUtils.areProperSubset(pf1_and_pf2_and_tf1, pf1_and_pf2));
    assertTrue(
        "are subset: " + pf1_and_pf2_and_tf1 + ", " + pf1_and_tf1,
        FilterUtils.areProperSubset(pf1_and_pf2_and_tf1, pf1_and_tf1));

    assertTrue(
        "are disjoint: " + pf1_and_tf1 + ", " + tf2, FilterUtils.areDisjoint(pf1_and_tf1, tf2));
    assertTrue(
        "are disjoint: " + pf1_and_pf2_and_tf1 + ", " + tf2,
        FilterUtils.areDisjoint(pf1_and_pf2_and_tf1, tf2));
  }
  public void testAndOrMethods() {
    checkEquals(
        FilterUtils.and(FilterUtils.and(tf1, tf2), tf3),
        FilterUtils.and(new FeatureFilter[] {tf1, tf2, tf3}));

    checkEquals(
        FilterUtils.and(tf1, FilterUtils.and(tf2, tf3)),
        FilterUtils.and(new FeatureFilter[] {tf1, tf2, tf3}));

    checkEquals(
        FilterUtils.or(FilterUtils.or(tf1, tf2), tf3),
        FilterUtils.or(new FeatureFilter[] {tf1, tf2, tf3}));

    checkEquals(
        FilterUtils.or(tf1, FilterUtils.or(tf2, tf3)),
        FilterUtils.or(new FeatureFilter[] {tf1, tf2, tf3}));
  }
  public void testUseCases() {
    // schemas for our database features
    FeatureFilter transcript = FilterUtils.byType("transcript");
    FeatureFilter exon = FilterUtils.byType("exon");
    FeatureFilter repeat = FilterUtils.byType("repeat");

    AnnotationType.Impl tsType = new AnnotationType.Impl();
    tsType.setConstraints(
        "transcript.id", new PropertyConstraint.ByClass(String.class), CardinalityConstraint.ONE);
    tsType.setDefaultConstraints(PropertyConstraint.NONE, CardinalityConstraint.NONE);
    FeatureFilter tsID = FilterUtils.byAnnotationType(tsType);

    AnnotationType.Impl exType = new AnnotationType.Impl();
    exType.setConstraints(
        "id", new PropertyConstraint.ByClass(String.class), CardinalityConstraint.ONE);
    exType.setDefaultConstraints(PropertyConstraint.NONE, CardinalityConstraint.NONE);
    FeatureFilter exID = FilterUtils.byAnnotationType(exType);

    AnnotationType.Impl rpType = new AnnotationType.Impl();
    rpType.setConstraints("id", PropertyConstraint.ANY, CardinalityConstraint.ONE);
    rpType.setDefaultConstraints(PropertyConstraint.NONE, CardinalityConstraint.NONE);
    FeatureFilter repeatID = FilterUtils.byAnnotationType(rpType);

    FeatureFilter tsSchema = FilterUtils.and(transcript, tsID);
    FeatureFilter exSchema = FilterUtils.and(exon, exID);
    FeatureFilter reSchema = FilterUtils.and(repeat, repeatID);

    FeatureFilter dbFilter = FilterUtils.or(new FeatureFilter[] {tsSchema, exSchema, reSchema});

    // pull out a feature by transcript.id
    FeatureFilter aTranscript = FilterUtils.byAnnotation("transcript.id", "ts:42");

    // let the fun commence
    optimizeEquals(
        FilterUtils.and(tsSchema, aTranscript), FilterUtils.and(transcript, aTranscript));
    optimizeExact(FilterUtils.and(exSchema, aTranscript), FilterUtils.none());
    optimizeExact(FilterUtils.and(reSchema, aTranscript), FilterUtils.none());
    optimizeEquals(dbFilter, dbFilter);
    optimizeEquals(
        FilterUtils.and(dbFilter, aTranscript), FilterUtils.and(transcript, aTranscript));
  }
  public void testAndOrAllNone() {
    optimizeExact(FilterUtils.or(all_and_all, FilterUtils.all()), FilterUtils.all());
    optimizeExact(FilterUtils.or(all_and_none, FilterUtils.all()), FilterUtils.all());

    optimizeExact(FilterUtils.or(all_and_all, FilterUtils.none()), FilterUtils.all());
    optimizeExact(FilterUtils.or(all_and_none, FilterUtils.none()), FilterUtils.none());

    optimizeExact(FilterUtils.and(all_or_all, FilterUtils.all()), FilterUtils.all());
  }
Exemple #28
0
 /** {@inheritDoc} */
 public void destroy() {
   FilterUtils.destroyFilter();
 }
  public void testHasByProperty() throws Exception {
    assertTrue("not disjoint: " + pf1 + ", " + pf4, !FilterUtils.areDisjoint(pf1, pf4));
    assertTrue("not disjoint: " + pf2 + ", " + pf4, !FilterUtils.areDisjoint(pf2, pf4));
    assertTrue("not disjoint: " + pf3 + ", " + pf4, !FilterUtils.areDisjoint(pf3, pf4));

    assertTrue("not subset: " + pf1 + ", " + pf4, !FilterUtils.areProperSubset(pf1, pf4));
    assertTrue("are subset: " + pf4 + ", " + pf1, FilterUtils.areProperSubset(pf4, pf1));
    assertTrue("are subset: " + pf5 + ", " + pf1, FilterUtils.areProperSubset(pf5, pf1));
    assertTrue("not subset: " + pf6 + ", " + pf1, !FilterUtils.areProperSubset(pf6, pf1));

    assertTrue("not subset: " + pf2 + ", " + pf4, !FilterUtils.areProperSubset(pf2, pf4));
    assertTrue("not subset: " + pf4 + ", " + pf2, !FilterUtils.areProperSubset(pf4, pf2));
    assertTrue("not subset: " + pf5 + ", " + pf2, !FilterUtils.areProperSubset(pf5, pf2));
    assertTrue("are subset: " + pf6 + ", " + pf2, FilterUtils.areProperSubset(pf6, pf2));
  }