Jef 的个人资料This has blog has moved ...照片日志列表更多 工具 帮助

日志


MIIS: MapAttributeForJoin Video and format example

I was catching up on my RSS feeds today, and I stumbled upon Alex Tcherniakhovski's video on Very practical example of using MapAttributesForJoin Method.  It's an excellent video tutorial on using the MAFJ function.

In summary it goes into converting the data type's to a common data type to map them for a join rule.

I tend to use MAFJ quite heavily because I seem to deal with data systems that store the common data value in various formats.

I would say the most common one that I use, is the normalizing the format for storing the US-SSN identifier between the DS and the MV.   Since often you will not be able to have the DataSource be formatted to what you have in the MV, this is a simple way to control that via extensions.

case "MAFJ_SSN":
{
	// MVentry.SSN = "123456789"
	// CSentry.SSN = "123-45-6789"
	// In order to make them "match" for join they need to
	// be equalized in format

	// using RegularExpressions replace the - in the SSN string
	string mySSN = regex.Replace(csentry["SSN"].Value,"-","").toString();	
		
	// mySSN = "123456789"

	// Add the formatted string to the Values collection to
	// be compared for JOIN.

	values.Add(mySSN);
}
break;

It should be noted that "values" is a ValueCollection so you could fill it with multiple formats of the value you wish to join upon.  I suppose this could be used to map a persons name who might be "Joe", "Joey", "Josef", or "Joseph", so that it correctly joins the "Joe Smith" in the metaverse.  I could see where you would want to join on a common name vs legal format of a name in some systems, but I have never had reason to do this myself.

 
tags: , , 
8月17日

MIIS: Provisioning New Object into a DB Management Agent

I saw the question of how to provision a new object into a SQL MA using MIIS, so I thought I'd just post a simple method I use often.

It's called ProvDB and can be added to the Metaverse Extension to be called based upon business logic.

I have a standard Correlation ID (CID) that ties data objects together, so this is what is used to provision the object into the DataSource.  Once the Object is provisioned with this CID, the MA join logic will handle all other data flows.  This makes its simplistic since the CID is the anchor for the MA as well.

Here is the standard method of ProvDB:

 void ProvDB(MVEntry mventry, string DBMA)
        {
            ConnectedMA ManagementAgent;    // Management agent object
            int Connectors;                 // Management agent connectors
            CSEntry csentry;                // Connector space entry objectt agent connectors
            
            // Get the management agent connectors

            ManagementAgent = mventry.ConnectedMAs[DBMA];

            // Get the management agent connectors.
            Connectors = ManagementAgent.Connectors.Count;

            // determine if this object may have a connector with this MA already.
            if (Connectors == 0)
            {


                try
                {

                   
                    csentry = ManagementAgent.Connectors.StartNewConnector("Person");
                    csentry["CID"].Value = mventry["CID"].Value;
                    
                    csentry.CommitNewConnector();

                }
                catch (ObjectAlreadyExistsException exAlreadyExists)
                {
                    string ExceptionMessage = null;
                    
		// throw exception if you want to alert on duplicates, or just catch to let join rules resolve
		ExceptionMessage = "Duplicate User - in " + DBMA;
                  throw new UnexpectedDataException(ExceptionMessage);


                }

                catch (NullReferenceException exNull)
                {
                    string ExceptionMessage = null;
                    ExceptionMessage = "Null Reference Exception in " + DBMA;
                    throw new UnexpectedDataException(ExceptionMessage);

                }

            }
            else
            {
                // Do nothing.  Object may already have a connection.
            }
        }

So you could use a simple routine to determine if the object should be provisioned into the correct MA-CS.

If (mventry["employeeType").IsPresent && mventry["employeeType"].Value == "CONTRACTOR") 
{ 
	// Provision into Contractor system
	ProvDB(mventry, "ContractorDB")
}

So you can reuse this to provision objects based on the CID into different DBs since the provision ADD is handled by the MA interface.

 

[Edit: I had left in code referencing DN concatination for a DB.   I removed this, since it is confusing.  It was from an assumption I had that later turned out to be wrong. ]

 tags: , ,