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"); }
public void initializeCompanyDescriptor() { MWTableDescriptor descriptor = getCompanyDescriptor(); MWTable table = tableNamed("COMPANY"); 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")); // direct to field mapping addDirectMapping(descriptor, "id", table, "ID"); addDirectMapping(descriptor, "name", table, "NAME"); // 1-many mappings MWOneToManyMapping vehiclesMapping = descriptor.addOneToManyMapping(descriptor.getMWClass().attributeNamed("vehicles")); vehiclesMapping.setReferenceDescriptor(getVehicleDescriptor()); vehiclesMapping.setReference( getVehicleDescriptor().getPrimaryTable().referenceNamed("VEHICLE_COMPANY")); vehiclesMapping.setPrivateOwned(true); }
protected void initializeExchangeRateDescriptor() { MWClass exchangeRateClass = refreshedTypeNamed( "org.eclipse.persistence.tools.workbench.test.models.currency.ExchangeRate"); MWTable exchangeRateTable = getProject().getDatabase().tableNamed("EXCHANGE_RATE"); MWTableDescriptor descriptor; try { descriptor = (MWTableDescriptor) getProject().addDescriptorForType(exchangeRateClass); } catch (InterfaceDescriptorCreationException e) { throw new RuntimeException(e); } descriptor.setPrimaryTable(exchangeRateTable); // Caching Policy descriptor.getCachingPolicy().setCacheSize(405); descriptor.getCachingPolicy().setCacheType(MWCachingPolicy.CACHE_TYPE_FULL); descriptor .getCachingPolicy() .setExistenceChecking(MWCachingPolicy.EXISTENCE_CHECKING_CHECK_DATABASE); // Direct to field mappings addDirectMapping(descriptor, "id", exchangeRateTable, "ID"); addDirectMapping(descriptor, "periodLength", exchangeRateTable, "PERIOD"); // Aggregate mappings MWAggregateMapping currencyRangeMapping = descriptor.addAggregateMapping(descriptor.getMWClass().attributeNamed("currencyRange")); MWClass currencyRangeClass = refreshedTypeNamed( "org.eclipse.persistence.tools.workbench.test.models.currency.CurrencyRange"); MWAggregateDescriptor currencyRangeDescriptor = (MWAggregateDescriptor) getProject().descriptorForType(currencyRangeClass); currencyRangeMapping.setReferenceDescriptor(currencyRangeDescriptor); Iterator fieldAssociations = CollectionTools.sort(currencyRangeMapping.pathsToFields()).iterator(); String[] fieldNames = new String[] {"HI_UNIT", "HI_VALUE", "LO_UNIT", "LO_VALUE", "TREND"}; for (int i = 0; i < fieldNames.length; i++) { MWAggregatePathToColumn association = (MWAggregatePathToColumn) fieldAssociations.next(); association.setColumn(exchangeRateTable.columnNamed(fieldNames[i])); } }
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()); }
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()); }
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()); }
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"); }
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")); }
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")); }
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")); }
public void initializeComputerDescriptor() { MWTableDescriptor descriptor = getComputerDescriptor(); MWTable table = tableNamed("INH_COMP"); 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")); // afterload policy descriptor.addAfterLoadingPolicy(); MWClass postLoadClass = typeNamed( "org.eclipse.persistence.tools.workbench.test.models.complexinheritance.Computer"); ((MWDescriptorAfterLoadingPolicy) descriptor.getAfterLoadingPolicy()) .setPostLoadMethodClass(postLoadClass); ((MWDescriptorAfterLoadingPolicy) descriptor.getAfterLoadingPolicy()) .setPostLoadMethod(methodNamed(postLoadClass, "addToDescriptor")); // inheritance policy descriptor.addInheritancePolicy(); MWRelationalDescriptorInheritancePolicy inheritancePolicy = (MWRelationalDescriptorInheritancePolicy) descriptor.getInheritancePolicy(); inheritancePolicy.useClassExtractionMethodIndicatorPolicy(); ((MWClassIndicatorExtractionMethodPolicy) inheritancePolicy.getClassIndicatorPolicy()) .setClassExtractionMethod(methodNamed(descriptor.getMWClass(), "getClassFromRow")); // direct to field mapping addDirectMapping(descriptor, "id", table, "ID"); addDirectMapping(descriptor, "manufacturer", table, "MANUFAC"); addDirectMapping(descriptor, "memory", table, "MEMORY"); addDirectMapping(descriptor, "processorMake", table, "MAKE"); addDirectMapping(descriptor, "processorSpeed", table, "SPEED"); }
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"); }
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")); }
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")); }