コード例 #1
0
  public void initializeIBMPCDescriptor() {
    MWTableDescriptor descriptor = getIBMPCDescriptor();
    MWTable table = tableNamed("INH_COMP");
    descriptor.setPrimaryTable(table);

    descriptor.getCachingPolicy().setCacheType(MWCachingPolicy.CACHE_TYPE_FULL);

    // inheritance policy
    descriptor.addInheritancePolicy();
    MWRelationalDescriptorInheritancePolicy inheritancePolicy =
        (MWRelationalDescriptorInheritancePolicy) descriptor.getInheritancePolicy();
    inheritancePolicy.setReadSubclassesOnQuery(false);
    inheritancePolicy.setParentDescriptor(getPCDescriptor());

    //		//afterload policy
    descriptor.addAfterLoadingPolicy();
    MWClass postLoadClass = descriptor.getMWClass();
    ((MWDescriptorAfterLoadingPolicy) descriptor.getAfterLoadingPolicy())
        .setPostLoadMethodClass(postLoadClass);
    ((MWDescriptorAfterLoadingPolicy) descriptor.getAfterLoadingPolicy())
        .setPostLoadMethod(methodNamed(postLoadClass, "addToDescriptor"));

    // direct to field mapping
    addDirectMapping(descriptor, "isClone", table, "CLONE");
  }
コード例 #2
0
  public void initializeEngineerDescriptor() {
    MWTableDescriptor descriptor = getEngineerDescriptor();
    MWTable table = tableNamed("PERSON2");
    descriptor.setPrimaryTable(table);

    descriptor.getCachingPolicy().setCacheType(MWCachingPolicy.CACHE_TYPE_FULL);

    // inheritance policy
    descriptor.addInheritancePolicy();
    MWRelationalDescriptorInheritancePolicy inheritancePolicy =
        (MWRelationalDescriptorInheritancePolicy) descriptor.getInheritancePolicy();
    inheritancePolicy.setParentDescriptor(getPersonDescriptor());
  }
コード例 #3
0
  public void initializeNonFueledVehicleDescriptor() {

    MWTableDescriptor descriptor = getNonFueledVehicleDescriptor();
    MWTable table = tableNamed("VEHICLE");
    descriptor.setPrimaryTable(table);

    descriptor.getCachingPolicy().setCacheType(MWCachingPolicy.CACHE_TYPE_FULL);

    // inheritance policy
    descriptor.addInheritancePolicy();
    MWRelationalDescriptorInheritancePolicy inheritancePolicy =
        (MWRelationalDescriptorInheritancePolicy) descriptor.getInheritancePolicy();
    inheritancePolicy.setParentDescriptor(getVehicleDescriptor());
  }
コード例 #4
0
  public void initializeSportsCarDescriptor() {
    MWTableDescriptor sportsCarDescriptor = getSportsCarDescriptor();

    MWTable table = tableNamed("CAR");
    sportsCarDescriptor.setPrimaryTable(table);

    sportsCarDescriptor.getCachingPolicy().setCacheType(MWCachingPolicy.CACHE_TYPE_FULL);

    // inheritance policy
    sportsCarDescriptor.addInheritancePolicy();
    MWRelationalDescriptorInheritancePolicy inheritancePolicy =
        (MWRelationalDescriptorInheritancePolicy) sportsCarDescriptor.getInheritancePolicy();
    inheritancePolicy.setReadSubclassesOnQuery(false);
    inheritancePolicy.setParentDescriptor(getCarDescriptor());
  }
コード例 #5
0
  public void initializeFueledVehicleDescriptor() {
    MWTableDescriptor descriptor = getFueledVehicleDescriptor();
    MWTable table = tableNamed("FUEL_VEH");
    descriptor.setPrimaryTable(table);

    descriptor.getCachingPolicy().setCacheType(MWCachingPolicy.CACHE_TYPE_FULL);

    // inheritance policy
    descriptor.addInheritancePolicy();
    MWRelationalDescriptorInheritancePolicy inheritancePolicy =
        (MWRelationalDescriptorInheritancePolicy) descriptor.getInheritancePolicy();
    inheritancePolicy.setReadSubclassesOnQuery(false);
    inheritancePolicy.setParentDescriptor(getVehicleDescriptor());

    // direct to field mapping
    addDirectMapping(descriptor, "fuelCapacity", table, "FUEL_CAP");
  }
コード例 #6
0
  public void initializeBusDescriptor() {
    MWTableDescriptor descriptor = getBusDescriptor();
    MWTable table = tableNamed("BUS");
    descriptor.setPrimaryTable(table);

    try {
      descriptor.mapInheritedAttributesToRootMinusOne();
    } catch (ClassNotFoundException ex) {
      throw new RuntimeException(ex);
    }

    descriptor.getCachingPolicy().setCacheType(MWCachingPolicy.CACHE_TYPE_FULL);

    // inheritance policy
    descriptor.addInheritancePolicy();
    MWRelationalDescriptorInheritancePolicy inheritancePolicy =
        (MWRelationalDescriptorInheritancePolicy) descriptor.getInheritancePolicy();
    inheritancePolicy.setReadSubclassesOnQuery(false);
    inheritancePolicy.setParentDescriptor(getFueledVehicleDescriptor());

    // multi-table info policy
    descriptor.addMultiTableInfoPolicy();

    MWTable fuelVehTable = tableNamed("FUEL_VEH");
    descriptor.addAssociatedTable(fuelVehTable);

    // direct to field mapping
    addDirectMapping(descriptor, "description", table, "DESCRIP");
    addDirectMapping(descriptor, "fuelType", fuelVehTable, "FUEL_TYP");

    // direct collection mapping
    MWRelationalDirectCollectionMapping partNumbersMapping =
        (MWRelationalDirectCollectionMapping)
            addDirectMapping(descriptor, "partNumbers").asMWDirectCollectionMapping();
    partNumbersMapping.setTargetTable(tableNamed("PARTNUMS"));
    partNumbersMapping.setDirectValueColumn(tableNamed("PARTNUMS").columnNamed("PART_NUM"));
    partNumbersMapping.setReference(tableNamed("PARTNUMS").referenceNamed("PARTNUMS_BUS"));
    partNumbersMapping.setUseNoIndirection();

    descriptor.removeMappingForAttribute(descriptor.getMWClass().attributeNamedFromAll("id"));
    descriptor.removeMappingForAttribute(descriptor.getMWClass().attributeNamedFromAll("owner"));
    descriptor.removeMappingForAttribute(
        descriptor.getMWClass().attributeNamedFromAll("passengerCapacity"));
    descriptor.removeMappingForAttribute(
        descriptor.getMWClass().attributeNamedFromAll("fuelCapacity"));
  }
コード例 #7
0
  public void initializePCDescriptor() {
    MWTableDescriptor descriptor = getPCDescriptor();
    MWTable table = tableNamed("INH_COMP");
    descriptor.setPrimaryTable(table);

    descriptor.getCachingPolicy().setCacheType(MWCachingPolicy.CACHE_TYPE_FULL);

    // inheritance policy
    descriptor.addInheritancePolicy();
    MWRelationalDescriptorInheritancePolicy inheritancePolicy =
        (MWRelationalDescriptorInheritancePolicy) descriptor.getInheritancePolicy();
    inheritancePolicy.setParentDescriptor(getComputerDescriptor());

    // afterload policy
    descriptor.addAfterLoadingPolicy();
    MWClass postLoadClass = descriptor.getMWClass();
    ((MWDescriptorAfterLoadingPolicy) descriptor.getAfterLoadingPolicy())
        .setPostLoadMethodClass(postLoadClass);
    ((MWDescriptorAfterLoadingPolicy) descriptor.getAfterLoadingPolicy())
        .setPostLoadMethod(methodNamed(postLoadClass, "addToDescriptor"));
  }
コード例 #8
0
  public void initializeMainframeDescriptor() {
    MWTableDescriptor descriptor = getMainframeDescriptor();
    MWTable table = tableNamed("INH_COMP");
    descriptor.setPrimaryTable(table);

    descriptor.getCachingPolicy().setCacheType(MWCachingPolicy.CACHE_TYPE_FULL);

    // inheritance policy
    descriptor.addInheritancePolicy();
    MWRelationalDescriptorInheritancePolicy inheritancePolicy =
        (MWRelationalDescriptorInheritancePolicy) descriptor.getInheritancePolicy();
    inheritancePolicy.setReadSubclassesOnQuery(false);
    inheritancePolicy.setParentDescriptor(getComputerDescriptor());

    // afterload policy
    descriptor.addAfterLoadingPolicy();
    MWClass postLoadClass = descriptor.getMWClass();
    ((MWDescriptorAfterLoadingPolicy) descriptor.getAfterLoadingPolicy())
        .setPostLoadMethodClass(postLoadClass);
    ((MWDescriptorAfterLoadingPolicy) descriptor.getAfterLoadingPolicy())
        .setPostLoadMethod(methodNamed(postLoadClass, "addToDescriptor"));

    // multi-table info policy
    descriptor.addMultiTableInfoPolicy();
    MWDescriptorMultiTableInfoPolicy multiTablePolicy =
        (MWDescriptorMultiTableInfoPolicy) descriptor.getMultiTableInfoPolicy();

    MWTable inhMfTable = tableNamed("INH_MF");
    descriptor.addAssociatedTable(inhMfTable);
    multiTablePolicy.secondaryTableHolderFor(inhMfTable).setPrimaryKeysHaveSameName(false);
    multiTablePolicy
        .secondaryTableHolderFor(inhMfTable)
        .setReference(inhMfTable.referenceNamed("INH_MF_INH_COMP"));
    // more needed here for the table associations

    // direct to field mapping
    addDirectMapping(descriptor, "numberOfProcessors", inhMfTable, "PROCS");
  }
コード例 #9
0
  public void initializeSoftwareEngineerDescriptor() {
    MWTableDescriptor descriptor = getSoftwareEngineerDescriptor();
    MWTable table = tableNamed("PERSON2");
    descriptor.setPrimaryTable(table);

    descriptor.getCachingPolicy().setCacheType(MWCachingPolicy.CACHE_TYPE_FULL);

    // inheritance policy
    descriptor.addInheritancePolicy();
    MWRelationalDescriptorInheritancePolicy inheritancePolicy =
        (MWRelationalDescriptorInheritancePolicy) descriptor.getInheritancePolicy();
    inheritancePolicy.setReadSubclassesOnQuery(false);
    inheritancePolicy.setParentDescriptor(getEngineerDescriptor());

    // direct to field mappings
    addDirectMapping(descriptor, "isExperiencedInJava", table, "KNOWS_JAVA");

    // 1-1 mappings
    MWOneToOneMapping bossMapping =
        descriptor.addOneToOneMapping(descriptor.getMWClass().attributeNamed("boss"));
    bossMapping.setReferenceDescriptor(getEngineerDescriptor());
    bossMapping.setReference(
        getEngineerDescriptor().getPrimaryTable().referenceNamed("PERSON2_PERSON2"));
  }