Skip to content

Instantly share code, notes, and snippets.

@qadeeras
Created September 25, 2012 14:41
Show Gist options
  • Save qadeeras/3782334 to your computer and use it in GitHub Desktop.
Save qadeeras/3782334 to your computer and use it in GitHub Desktop.
Entry in to a table(stub given as example)
#include <iostream>
#include <stdio.h>
#include <tc.h>
#include <epm/cr.h>
#include <pom.h>
#include <tccore/aom_prop.h>
#include <emh.h>
#include <mem.h>
#include <tccore/aom.h>
#include <pom/pom/pom.h>
#include <sa/sa.h>
#include <tccore/tctype.h>
#include <tccore/tctype.h>
#include <tccore/grm.h>
#define POM_STUB "POM_stub"
#define POM_OBJECT "POM_object"
#define OBJECT_CLASS "object_class"
#define DEFINITIVE "definitive"
#define OBJECT_UID "object_uid"
#define OWNING_SITE "owning_site"
using namespace std;
char *pErrmsg = NULL;
int nFail = ITK_ok;
class StubEntry
{
private :
tag_t ownsiteTag;
char type_class[TCTYPE_class_name_size_c+1];
tag_t class_id;
tag_t attrObject_class;
tag_t attrDefinitive;
tag_t attrObject_uid;
tag_t attrOwning_site;
int getAttr(tag_t &puidTag);
int attrFinder();
public :
StubEntry();
int createEntry(char *inPuid);
};
StubEntry::StubEntry()
{
class_id=NULLTAG;
ownsiteTag=NULLTAG;
attrObject_class=NULLTAG;
attrDefinitive=NULLTAG;
attrObject_uid=NULLTAG;
attrOwning_site=NULLTAG;
attrFinder();
}
int StubEntry :: attrFinder()
{
POM_class_id_of_class(POM_STUB,&class_id);
POM_attr_id_of_attr (OWNING_SITE, POM_OBJECT, &attrOwning_site);
POM_attr_id_of_attr (OBJECT_CLASS, POM_STUB, &attrObject_class);
POM_attr_id_of_attr (DEFINITIVE, POM_STUB, &attrDefinitive);
POM_attr_id_of_attr (OBJECT_UID, POM_STUB, &attrObject_uid);
return 0;
}
int StubEntry :: getAttr(tag_t &puidTag)
{
tag_t type_tag=NULLTAG;
TCTYPE_ask_object_type(puidTag, &type_tag);
TCTYPE_ask_class_name(type_tag, type_class);
logical is_it_null=false;
logical is_it_empty=false;
int status=POM_ask_attr_tag(puidTag, attrOwning_site, &ownsiteTag, &is_it_null,&is_it_empty);
if(status != ITK_ok)
{
cout<<"Failed to get the owning-site attribute \n";
return 1;
}
if( is_it_null || is_it_empty || ownsiteTag == NULL)
{
cout<<"Owning site is empty for puid \n";
return 1;
}
return 0;
}
int StubEntry :: createEntry(char *inPuid)
{
char *puid = inPuid;
tag_t puidTag=NULLTAG;
ITK__convert_uid_to_tag(puid, &puidTag);
getAttr(puidTag);
tag_t instance_tag = NULLTAG;
POM_create_instance( class_id, &instance_tag );
POM_set_attr_string ( 1, &instance_tag, attrObject_class, type_class);
POM_set_attr_string ( 1, &instance_tag, attrObject_uid, puid);
POM_set_attr_tag ( 1, &instance_tag, attrDefinitive, ownsiteTag);
POM_save_instances(1, &instance_tag,"true");
puidTag=NULLTAG;
return 0;
}
int ITK_user_main(int argc, char* argv[])
{
char *inPuid=ITK_ask_cli_argument( "-d=" );
if(inPuid==NULL||inPuid=="")
{
cout<<"Command line argument -d=<input puid> is missing, exiting\n";
return 1;
}
if (ITK_auto_login() == ITK_ok)
cout<<"Login successful... \n\n";
else
{
cout<<"Login failed...\n" ;
return 1;
}
ITK_set_journalling(TRUE);
SA_init_module();
POM_init_module();
AOM_init_module();
int status = ITK_set_bypass(TRUE);
if(status != ITK_ok)
{
cout<<"Bypas failed \n";
return 1;
}
POM_set_env_info(POM_bypass_attr_update,FALSE,0,0.0,NULLTAG,NULL);
StubEntry newEntry;
newEntry.createEntry(inPuid);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment