コード例 #1
0
  public void initializePersonDescriptor() {
    MWTableDescriptor descriptor = getPersonDescriptor();
    MWTable table = tableNamed("PERSON2");
    descriptor.setPrimaryTable(table);

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

    // sequencing
    descriptor.setUsesSequencing(true);
    descriptor.setSequenceNumberName("SEQ");
    descriptor.setSequenceNumberTable(table);
    descriptor.setSequenceNumberColumn(table.columnNamed("ID"));

    descriptor.addInheritancePolicy();
    MWRelationalDescriptorInheritancePolicy inheritancePolicy =
        (MWRelationalDescriptorInheritancePolicy) descriptor.getInheritancePolicy();
    inheritancePolicy.setReadSubclassesOnQuery(false);
    ((MWRelationalClassIndicatorFieldPolicy) inheritancePolicy.getClassIndicatorPolicy())
        .setField(table.columnNamed("C_TYPE"));
    ((MWRelationalClassIndicatorFieldPolicy) inheritancePolicy.getClassIndicatorPolicy())
        .setClassNameIsIndicator(true);

    // direct to field mappings
    addDirectMapping(descriptor, "id", table, "ID");
    addDirectMapping(descriptor, "name", table, "NAME");

    // 1-1 mappings
    MWOneToOneMapping bestFriendMapping =
        descriptor.addOneToOneMapping(descriptor.getMWClass().attributeNamed("bestFriend"));
    bestFriendMapping.setReferenceDescriptor(getEngineerDescriptor());
    bestFriendMapping.setReference(
        getEngineerDescriptor().getPrimaryTable().referenceNamed("PERSON2_PERSON22"));

    MWOneToOneMapping carMapping =
        descriptor.addOneToOneMapping(descriptor.getMWClass().attributeNamed("car"));
    carMapping.setReferenceDescriptor(getCarDescriptor());
    carMapping.setReference(table.referenceNamed("PERSON2_CAR"));
    carMapping.setPrivateOwned(true);

    MWOneToOneMapping representitiveMapping =
        descriptor.addOneToOneMapping(descriptor.getMWClass().attributeNamed("representitive"));
    representitiveMapping.setReferenceDescriptor(getSalesRepDescriptor());
    representitiveMapping.setReference(table.referenceNamed("PERSON2_PERSON23"));
  }
コード例 #2
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"));
  }
コード例 #3
0
  public void initializeVehicleDescriptor() {
    MWTableDescriptor descriptor = getVehicleDescriptor();
    MWTable table = tableNamed("VEHICLE");
    descriptor.setPrimaryTable(table);

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

    // sequencing
    descriptor.setUsesSequencing(true);
    descriptor.setSequenceNumberName("SEQ");
    descriptor.setSequenceNumberTable(table);
    descriptor.setSequenceNumberColumn(table.columnNamed("ID"));

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

    MWRelationalClassIndicatorFieldPolicy classIndicatorPolicy =
        (MWRelationalClassIndicatorFieldPolicy) inheritancePolicy.getClassIndicatorPolicy();
    classIndicatorPolicy.setIndicatorType(
        new MWTypeDeclaration(classIndicatorPolicy, typeFor(java.lang.String.class)));

    classIndicatorPolicy.setField(table.columnNamed("TYPE"));

    classIndicatorPolicy
        .getClassIndicatorValueForDescriptor(getVehicleDescriptor())
        .setInclude(false);

    classIndicatorPolicy
        .getClassIndicatorValueForDescriptor(getNonFueledVehicleDescriptor())
        .setIndicatorValue("2");

    classIndicatorPolicy
        .getClassIndicatorValueForDescriptor(getFueledVehicleDescriptor())
        .setIndicatorValue("1");

    classIndicatorPolicy
        .getClassIndicatorValueForDescriptor(getBusDescriptor())
        .setIndicatorValue("3");

    classIndicatorPolicy
        .getClassIndicatorValueForDescriptor(getCarDescriptor())
        .setIndicatorValue("4");

    classIndicatorPolicy
        .getClassIndicatorValueForDescriptor(getBicycleDescriptor())
        .setIndicatorValue("6");

    classIndicatorPolicy
        .getClassIndicatorValueForDescriptor(getSportsCarDescriptor())
        .setIndicatorValue("5");

    classIndicatorPolicy
        .getClassIndicatorValueForDescriptor(getBoatDescriptor())
        .setIndicatorValue("7");

    // direct to field mappings
    addDirectMapping(descriptor, "id", table, "ID");
    addDirectMapping(descriptor, "passengerCapacity", table, "CAPACITY");

    // 1-1 mappings
    MWOneToOneMapping ownerMapping =
        descriptor.addOneToOneMapping(descriptor.getMWClass().attributeNamed("owner"));
    ownerMapping.setReferenceDescriptor(getCompanyDescriptor());
    ownerMapping.setReference(table.referenceNamed("VEHICLE_COMPANY"));
  }