Example #1
0
 public static void walk(IFastOrmContainer fastOrm, IMakerAndEntityDefnVisitor visitor) {
   try {
     IEntityDefn primary = fastOrm.getEntityDefn();
     visitor.acceptPrimary(fastOrm.getPrimaryTempTableMaker(), primary);
     visitChildren(fastOrm, primary, visitor);
   } catch (Exception e) {
     throw WrappedException.wrap(e);
   }
 }
Example #2
0
 public static <From, To> To aggregate(
     IFastOrmContainer fastOrm,
     IMakerAndEntityDefnFoldVisitor<From, To> visitor,
     IAggregator<From, To> aggregator) {
   aggregator.add(
       visitor.acceptPrimary(fastOrm.getPrimaryTempTableMaker(), fastOrm.getEntityDefn()));
   visitChildren(fastOrm, fastOrm.getEntityDefn(), visitor, aggregator);
   return aggregator.result();
 }
Example #3
0
 public static void walk(IJob job, IMutableMakerAndEntityDefnVisitor visitor) {
   try {
     IEntityDefn primary = job.getEntityDefn();
     IFastOrmContainer container = job.getContainer();
     visitor.accept(container.getTempTableMakerFactory().findMutatingMakerFor(primary), primary);
     visitChildren(container, primary, visitor);
   } catch (Exception e) {
     throw WrappedException.wrap(e);
   }
 }
Example #4
0
 private static void visitChildren(
     IFastOrmContainer fastOrm, IEntityDefn parent, IMutableMakerAndEntityDefnVisitor visitor)
     throws Exception {
   for (IEntityDefn child : parent.getChildren()) {
     visitor.accept(fastOrm.getTempTableMakerFactory().findMutatingMakerFor(child), child);
     visitChildren(fastOrm, child, visitor);
   }
 }
Example #5
0
    public static void dropAndMakeTables(
        IFastOrmContainer fastOrm,
        IEntityDefn entityDefn,
        final IExtraDataGenerator extraDataGenerator) {
      final Map<IEntityDefn, Map<String, String>> entityToColumnsAndTypes =
          findMinimumColumns(fastOrm);
      final SqlHelper sqlHelper = new SqlHelper(fastOrm.getDataSource());
      sqlHelper.dropAllTables();
      walk(
          fastOrm.getEntityDefn(),
          new IEntityDefnParentChildVisitor() {
            @Override
            public void acceptPrimary(IEntityDefn primary) throws Exception {
              extraDataGenerator.enrichColumnsForMakingTables(entityToColumnsAndTypes, primary);
            }

            @Override
            public void acceptChild(IEntityDefn parent, IEntityDefn child) throws Exception {
              extraDataGenerator.enrichColumnsForMakingTables(entityToColumnsAndTypes, child);
            }
          });
      walk(
          fastOrm.getEntityDefn(),
          new IEntityDefnParentChildVisitor() {
            @Override
            public void acceptPrimary(IEntityDefn primary) {
              sqlHelper.create(
                  primary.getTableName(),
                  Maps.toArray(entityToColumnsAndTypes.get(primary), new String[0]));
              sqlHelper.index(primary);
            }

            @Override
            public void acceptChild(IEntityDefn parent, IEntityDefn child) {
              sqlHelper.create(
                  child.getTableName(),
                  Maps.toArray(entityToColumnsAndTypes.get(child), new String[0]));
              sqlHelper.index(child);
            }
          });
    }
Example #6
0
 private static void visitChildren(
     IFastOrmContainer fastOrm, IEntityDefn parent, IMakerAndEntityDefnVisitor visitor)
     throws Exception {
   for (IEntityDefn child : parent.getChildren()) {
     visitor.acceptChild(
         fastOrm
             .getTempTableMakerFactory()
             .findReaderMakerFor(parent.parameters(), child.parameters()),
         parent,
         child);
     visitChildren(fastOrm, child, visitor);
   }
 }
Example #7
0
 private static <To, From> void visitChildren(
     IFastOrmContainer fastOrm,
     IEntityDefn parent,
     IMakerAndEntityDefnFoldVisitor<From, To> visitor,
     IAggregator<From, To> aggregator) {
   for (IEntityDefn child : parent.getChildren()) {
     aggregator.add(
         visitor.acceptChild(
             fastOrm
                 .getTempTableMakerFactory()
                 .findReaderMakerFor(parent.parameters(), child.parameters()),
             parent,
             child));
     visitChildren(fastOrm, child, visitor, aggregator);
   }
 }