jsdai.lang
Class MappingUtil

java.lang.Object
  extended byjsdai.lang.MappingUtil

public class MappingUtil
extends java.lang.Object

This class is a superclass of all mapping early binding classes known as M classes.
Here is an example how derived classes can be used:

 import jsdai.MAp214.*;
 import jsdai.lang.*;
 import jsdai.dictionary.*;
 import jsdai.mapping.*;
	
 public static final void main (String args[])  throws SdaiException, Exception {
		System.out.println("Test application of Item");
		//Session is opened already by initializing static members.
		SdaiSession session = SdaiSession.getSession();
		//Transaction is already started by initializing static members.
		//SdaiTransaction trx = session.startTransactionReadWriteAccess();
		SdaiRepository repo = session.linkRepository(args[0],null);
		repo.openRepository();
		ASdaiModel domain = repo.getModels();
		SdaiModel model = domain.getByIndex(1);

		model.startReadWriteAccess();

		AEntity instances = MItem.findInstances(domain, null);

		int no_of_instances = instances.getMemberCount();
		System.out.println("Number of received instances is "+no_of_instances);
		System.out.println(instances);
		int expectedRetType = -1;
		for (int i=1;i<=no_of_instances;i++) {
			EEntity instance = (EEntity) instances.getByIndexEntity(i);
			System.out.println("");
			System.out.println("instance is "+instance);
			expectedRetType = MItem.testId(domain, instance);
			switch (expectedRetType) {
				case MItem.ID__STRING:
					//put appropriate call to getXX method here.
				break;
			default:
				System.out.println("Value not set!");
			}
			expectedRetType = MItem.testName(domain, instance);
			switch (expectedRetType) {
				case MItem.NAME__STRING:
					//put appropriate call to getXX method here.
					String result = MItem.getName(domain, instance, (String) null);
					System.out.println("result for name is"+result);
					if (result.equalsIgnoreCase("nba")) {
						result = "LKL";
						System.out.println("setting new value for name");
						MItem.setName(domain, instance, result, (String) null);
						session.getActiveTransaction().commit();
					}
				break;
			default:
				System.out.println("Value not set!");
			}
			expectedRetType = MItem.testDescription(domain, instance);
			switch (expectedRetType) {
				case MItem.DESCRIPTION__STRING:
					//put appropriate call to getXX method here.
				break;
			default:
				System.out.println("Value not set!");
			}
		}
	}


Field Summary
static java.lang.String getErrorString1
          This error string is used to create and throw SdaiException and indicates that user called a getXX method that accepts EEntity instance as parameter, but user has passed to this method an instance, which was of incorrect type.
static java.lang.String setErrorString1
          The error string to be used to inform user about attempt to use setXX method improperly.
static java.lang.String testErrorString1
          The error string to be used to construct SdaiException, when early binding class detects that type of actually returned value is unexpected and there is no static constant to be returned from testXX method.
static int VA_NSET
          Value used to return from testXX methods to indicate: a) attribute is not set b) call to getXX would result in SdaiException.
 
Method Summary
static void changeMappingModeTo(int newMappingMode)
          Method allows to change value of protected static member, which is taken when derived classes needs to access mapping operation, and mapping mode (or severity level) is required for passing to mapping operation.
static void copyEntities(AEntity to, AEntity from)
          A helper method for findInstances method in generated classes.
static jsdai.dictionary.EAttribute findArmAttribute(jsdai.dictionary.EEntity_definition entity, java.lang.String attributeName)
           
static jsdai.mapping.EGeneric_attribute_mapping findAttributeMapping(jsdai.mapping.EEntity_mapping em, jsdai.dictionary.EAttribute attribute, java.lang.String dataTypeName, ASdaiModel mappingDomain)
           
static jsdai.mapping.EEntity_mapping findEntityMapping(jsdai.dictionary.EEntity_definition mappedEntity, java.lang.String aimName, ASdaiModel mappingDomain)
           
static ASdaiModel findMetaDomain(SdaiModel mp)
           
static jsdai.mapping.ESchema_mapping findSchemaMapping(SdaiModel modelMAP)
           
static SdaiModel findSystemModel(java.lang.String name)
           
static jsdai.dictionary.ENamed_type findType(java.lang.String name, jsdai.dictionary.ANamed_type types)
           
static jsdai.dictionary.ANamed_type getNamedTypes(jsdai.dictionary.ESchema_definition schema, ASdaiModel metaDomain)
           
static jsdai.dictionary.ESchema_definition getSource(jsdai.mapping.ESchema_mapping sm)
           
static jsdai.dictionary.ESchema_definition getTarget(jsdai.mapping.ESchema_mapping sm)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

setErrorString1

public static final java.lang.String setErrorString1
The error string to be used to inform user about attempt to use setXX method improperly. Original string says: "Attempt to determine which attribute_mapping to use failed: type of given instance should not be used with this overload of setXX method."

See Also:
Constant Field Values

testErrorString1

public static final java.lang.String testErrorString1
The error string to be used to construct SdaiException, when early binding class detects that type of actually returned value is unexpected and there is no static constant to be returned from testXX method. Original string says: "Attempt to determine type of returned value failed: you may need to regenerate your classes with jsdai.mappingUtils.ClassesGenerator."

See Also:
Constant Field Values

getErrorString1

public static final java.lang.String getErrorString1
This error string is used to create and throw SdaiException and indicates that user called a getXX method that accepts EEntity instance as parameter, but user has passed to this method an instance, which was of incorrect type. 'Incorrect' type means that attribute value can not be read from instances of 'incorrect' type. Or, attribute value can be read, but its type will be incompatible with return type of getXX method. Original string says: "Type of given instance is not compatible with required types!" If desired, a processor of this exception can invoke getErrorBase() : Object to obtain the instance, on which this 'get' operation has failed. The output of getErrorString1 is followed by invalid value itself, thus giving the processor full information on all circumstances, under which the exception has occurred.

See Also:
Constant Field Values

VA_NSET

public static final int VA_NSET
Value used to return from testXX methods to indicate: a) attribute is not set b) call to getXX would result in SdaiException.

See Also:
Constant Field Values
Method Detail

changeMappingModeTo

public static void changeMappingModeTo(int newMappingMode)
Method allows to change value of protected static member, which is taken when derived classes needs to access mapping operation, and mapping mode (or severity level) is required for passing to mapping operation.

Parameters:
newMappingMode - new mapping mode, can be one of values, defined in EEntity class (NO_RESTRICTIONS, etc.)

findSystemModel

public static SdaiModel findSystemModel(java.lang.String name)

findSchemaMapping

public static jsdai.mapping.ESchema_mapping findSchemaMapping(SdaiModel modelMAP)

findMetaDomain

public static ASdaiModel findMetaDomain(SdaiModel mp)

getSource

public static jsdai.dictionary.ESchema_definition getSource(jsdai.mapping.ESchema_mapping sm)

getTarget

public static jsdai.dictionary.ESchema_definition getTarget(jsdai.mapping.ESchema_mapping sm)

getNamedTypes

public static jsdai.dictionary.ANamed_type getNamedTypes(jsdai.dictionary.ESchema_definition schema,
                                                         ASdaiModel metaDomain)

findType

public static jsdai.dictionary.ENamed_type findType(java.lang.String name,
                                                    jsdai.dictionary.ANamed_type types)

findEntityMapping

public static jsdai.mapping.EEntity_mapping findEntityMapping(jsdai.dictionary.EEntity_definition mappedEntity,
                                                              java.lang.String aimName,
                                                              ASdaiModel mappingDomain)

findArmAttribute

public static jsdai.dictionary.EAttribute findArmAttribute(jsdai.dictionary.EEntity_definition entity,
                                                           java.lang.String attributeName)

findAttributeMapping

public static jsdai.mapping.EGeneric_attribute_mapping findAttributeMapping(jsdai.mapping.EEntity_mapping em,
                                                                            jsdai.dictionary.EAttribute attribute,
                                                                            java.lang.String dataTypeName,
                                                                            ASdaiModel mappingDomain)
Parameters:
em - Entity mapping, that is related with desired to find attribute mapping.
attribute - Attribute, whose mapping is searched.
dataTypeName - In some cases entity_mapping can have several alternatives for mapping given attribute. Then, each attribute_mapping contains a string value that allows to distinguish attribute_mappings between each other. This parameter indicates what string value is contained in desired attribute_mapping.
mappingDomain - Model(s), where desired attribute_mapping should be searched.

copyEntities

public static void copyEntities(AEntity to,
                                AEntity from)
                         throws SdaiException
A helper method for findInstances method in generated classes. Is used to copy instances from one aggregate to another. Ensures, that resulting aggregate does not contain repeated entries. Notice, that we switched over to using HashSet, as this appeared to be many times faster than using isMember() function- probably due to bug in that function. See bugzilla #631 for report on this.

Throws:
SdaiException

Copyright © LKSoftWare GmbH, 1999-2008