Exemple #1
0
 public static Iterable<CascadeStyle> interpretCascadeStyles(
     String cascades, LocalBindingContext bindingContext) {
   final Set<CascadeStyle> cascadeStyles = new HashSet<CascadeStyle>();
   if (StringHelper.isEmpty(cascades)) {
     cascades = bindingContext.getMappingDefaults().getCascadeStyle();
   }
   for (String cascade : StringHelper.split(",", cascades)) {
     cascadeStyles.add(CascadeStyle.getCascadeStyle(cascade));
   }
   return cascadeStyles;
 }
 private boolean isSequence(Object key, Set sequences) {
   if (key instanceof String) {
     if (sequences.contains(key)) {
       return true;
     } else {
       String[] strings = StringHelper.split(".", (String) key);
       if (strings.length == 3) {
         return sequences.contains(strings[2]);
       } else if (strings.length == 2) {
         return sequences.contains(strings[1]);
       }
     }
   }
   return false;
 }
 /**
  * Turns a path into an AST.
  *
  * @param path The path.
  * @param factory The AST factory to use.
  * @return An HQL AST representing the path.
  */
 public static AST parsePath(String path, ASTFactory factory) {
   String[] identifiers = StringHelper.split(".", path);
   AST lhs = null;
   for (int i = 0; i < identifiers.length; i++) {
     String identifier = identifiers[i];
     AST child = ASTUtil.create(factory, HqlSqlTokenTypes.IDENT, identifier);
     if (i == 0) {
       lhs = child;
     } else {
       lhs = ASTUtil.createBinarySubtree(factory, HqlSqlTokenTypes.DOT, ".", lhs, child);
     }
   }
   if (LOG.isDebugEnabled()) {
     LOG.debugf("parsePath() : %s -> %s", path, ASTUtil.getDebugString(lhs));
   }
   return lhs;
 }
Exemple #4
0
 private void preprocess(String token, QueryTranslatorImpl q) throws QueryException {
   // ugly hack for cases like "elements(foo.bar.collection)"
   // (multi-part path expression ending in elements or indices)
   String[] tokens = StringHelper.split(".", token, true);
   if (tokens.length > 5
       && (CollectionPropertyNames.COLLECTION_ELEMENTS.equals(tokens[tokens.length - 1])
           || CollectionPropertyNames.COLLECTION_INDICES.equals(tokens[tokens.length - 1]))) {
     pathExpressionParser.start(q);
     for (int i = 0; i < tokens.length - 3; i++) {
       pathExpressionParser.token(tokens[i], q);
     }
     pathExpressionParser.token(null, q);
     pathExpressionParser.end(q);
     addJoin(pathExpressionParser.getWhereJoin(), q);
     pathExpressionParser.ignoreInitialJoin();
   }
 }
 private boolean isTable(Object key) throws HibernateException {
   // BIG HACK - should probably utilize the table cache before going to the jdbcreader :(
   if (key instanceof String) {
     String[] strings = StringHelper.split(".", (String) key);
     if (strings.length == 1) {
       tableSelector.clearSchemaSelections();
       tableSelector.addSchemaSelection(new SchemaSelection(null, null, strings[0]));
       List list = reader.readDatabaseSchema(dbc, null, null);
       return !list.isEmpty();
     } else if (strings.length == 3) {
       tableSelector.clearSchemaSelections();
       tableSelector.addSchemaSelection(new SchemaSelection(strings[0], strings[1], strings[2]));
       List list = reader.readDatabaseSchema(dbc, null, null);
       return !list.isEmpty();
     } else if (strings.length == 2) {
       tableSelector.clearSchemaSelections();
       tableSelector.addSchemaSelection(new SchemaSelection(null, strings[0], strings[1]));
       List list = reader.readDatabaseSchema(dbc, null, null);
       return !list.isEmpty();
     }
   }
   return false;
 }
    private ArrayList<MetadataSourceType> resolveInitialSourceProcessOrdering(
        ConfigurationService configService) {
      final ArrayList<MetadataSourceType> initialSelections = new ArrayList<MetadataSourceType>();

      final String sourceProcessOrderingSetting =
          configService.getSetting(
              AvailableSettings.ARTIFACT_PROCESSING_ORDER, StandardConverters.STRING);
      if (sourceProcessOrderingSetting != null) {
        final String[] orderChoices =
            StringHelper.split(",; ", sourceProcessOrderingSetting, false);
        initialSelections.addAll(
            CollectionHelper.<MetadataSourceType>arrayList(orderChoices.length));
        for (String orderChoice : orderChoices) {
          initialSelections.add(MetadataSourceType.parsePrecedence(orderChoice));
        }
      }
      if (initialSelections.isEmpty()) {
        initialSelections.add(MetadataSourceType.HBM);
        initialSelections.add(MetadataSourceType.CLASS);
      }

      return initialSelections;
    }