Exemplo n.º 1
0
  public IQueryBuilder<I_M_Material_Tracking> createQueryBuilder(
      final IMaterialTrackingQuery queryVO) {
    Check.assumeNotNull(queryVO, "queryVO not null");

    final IQueryBuilder<I_M_Material_Tracking> queryBuilder =
        queryBL
            .createQueryBuilder(I_M_Material_Tracking.class)
            .setContext(getCtx(), getTrxName())
            .addOnlyContextClient()
            .addOnlyActiveRecordsFilter();

    final IQueryOrderByBuilder<I_M_Material_Tracking> orderBy = queryBuilder.orderBy();

    //
    // M_Product_ID
    final int productId = queryVO.getM_Product_ID();
    Check.assume(productId > 0, "productId > 0");
    queryBuilder.addEqualsFilter(I_M_Material_Tracking.COLUMN_M_Product_ID, productId);

    //
    // C_BPartner_ID
    final int bpartnerId = queryVO.getC_BPartner_ID();
    queryBuilder.addInArrayFilter(I_M_Material_Tracking.COLUMN_C_BPartner_ID, null, bpartnerId);
    orderBy.addColumn(I_M_Material_Tracking.COLUMN_C_BPartner_ID, Direction.Descending, Nulls.Last);

    // TODO: ValidFrom, ValidTo

    //
    // Processed
    final Boolean processed = queryVO.getProcessed();
    if (processed != null) {
      queryBuilder.addEqualsFilter(I_M_Material_Tracking.COLUMN_Processed, processed);
    }

    //
    // Linked documents
    final List<?> linkedModels = queryVO.getWithLinkedDocuments();
    if (linkedModels != null && !linkedModels.isEmpty()) {
      final IQuery<I_M_Material_Tracking_Ref> materialTrackingRefQuery =
          createMaterialTrackingRefQueryForModels(linkedModels);
      if (materialTrackingRefQuery != null) {
        queryBuilder.addInSubQueryFilter(
            I_M_Material_Tracking.COLUMN_M_Material_Tracking_ID,
            I_M_Material_Tracking_Ref.COLUMN_M_Material_Tracking_ID,
            materialTrackingRefQuery);
      }
      // TODO
    }

    return queryBuilder;
  }
Exemplo n.º 2
0
  @Override
  protected String doIt() throws Exception {
    if (p_Target_Directory == null) throw new FillMandatoryException("Target_Directory");
    if (p_EntityType == null) throw new FillMandatoryException("EntityType");

    final IQueryBuilder<I_EXP_Format> queryBuilder =
        Services.get(IQueryBL.class).createQueryBuilder(I_EXP_Format.class).setContext(this);

    if (p_FilterBy_AD_Client_ID) {
      queryBuilder.addInArrayFilter(I_EXP_Format.COLUMNNAME_AD_Client_ID, 0, getAD_Client_ID());
    }
    if (p_EntityType != null) {
      queryBuilder.addEqualsFilter(I_EXP_Format.COLUMNNAME_EntityType, p_EntityType);
    }

    queryBuilder
        .orderBy()
        .addColumn(I_EXP_Format.COLUMNNAME_EXP_Format_ID) // to have a predictible order
    ;

    final List<I_EXP_Format> expFormats = queryBuilder.create().list();

    final CanonicalXSDGenerator engine = new CanonicalXSDGenerator();
    for (final I_EXP_Format format : expFormats) {
      if (!format.isActive()) continue;
      engine.addEXPFormat(format);
      // metas-ts: commenting out for now, because taskes very long when there are many export
      // formats and it never helped me so far (mainly because it doesn't export embedded formats)
      // createTestModel(format);
    }
    createTestModelsIndex(expFormats);

    final String schemaFile = getSchemaFile().getAbsolutePath();
    engine.saveToFile(schemaFile);
    addLog("Created schema file: " + schemaFile);

    return "OK";
  }