0% found this document useful (0 votes)
14 views

Individual Task ITK

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views

Individual Task ITK

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

FLOW CHART

`
Start

Fetching item revision tag and API check function for error
declaration of variables. check

=NULLTAG Check for


null tag

If error, error will be


!=NULLTAG displayed, otherwise
Create form using FORM_create2() contines
api and save the form using
AOM_save_without_extensions()
If error in api

=NULLTAG Check for


null tag
Error displayed
in rac and
!=NULLTAG printed in syslog

To getsave the form


a relation tagusing
, find the
AOM_save_without_extensions()
relation using
GRM_find_relation_type() api

=NULLTAG Check for


null tag

!=NULLTAG
Using the relation tag, create the
relation between the IR and form
using GRM_create_relation() and
save relation using
GRM_save_relation() api

=NULLTAG Check for


null tag
!=NULLTAG

Find the workflow template


using the
EPM_find_process_template()

!=NULLTAG

=NULLTAG
Check for
null tag

Create the workflow using the


EPM_create_process() and

END
Algorithm
(Every api is sent to the ITKCALL macro function to check for the error )

1. Initialize various variables and tags:

 tag_t tRev, tSpecification, tRelation, tNewForm, tProcTemp, tNewProTemp


 tag_t attachments[1]
 int iSize
 character pointer as cpRevID, cpItemid, cpcRevid

- const character pointer as cpProcessTempName

2. Check if tRev is not a null tag.

 If tRev is null, log an error message and exit.


 Otherwise, proceed.

3. Retrieve the revision ID (`cpRevID`) of `tRev` using ITEM_ask_rev_id2.

4. Retrieve the value of the "current_id" property (`cpItemid`) from `tRev` using
AOM_ask_value_string.

5. Retrieve the value of the "current_revision_id" property (`cpcRevid`) from `tRev` using
AOM_ask_value_string.

6. Calculate the size (`iSize`) required to store the name for the dataset based on `cpItemid` and
`cpcRevid`.

7. Allocate memory for the `newFormName` character array with a size of `iSize`.

8. Construct the `newFormName` by formatting it as "%s_%s_ATT" with `cpItemid` and `cpcRevid`.

9. Create a new form object (`tNewForm`) using FORM_create2 with the constructed
`newFormName`, "FormDesc," and "A7Cus_FORM."

10. Check if `tNewForm` is not a null tag.

 If `tNewForm` is null, log an error message and exit.


 Otherwise, proceed.

11. Save `tNewForm` without extensions using AOM_save_without_extensions.

12. Find the relation type "IMAN_specification" and store it in `tSpecification` using
GRM_find_relation_type.

13. Check if `tSpecification` is not a null tag (CheckNull3(tSpecification)).

 If `tSpecification` is null, log an error message and exit.


 Otherwise, proceed.

14. Create a relation (`tRelation`) between `tRev` and `tNewForm` using GRM_create_relation.

15. Check if `tRelation` is not a null tag (CheckNull3(tRelation)).


 If `tRelation` is null, log an error message and exit.
 Otherwise, proceed.

16. Save the relation using GRM_save_relation.

17. Find the process template (`tProcTemp`) with the name `cpProcessTempName` using
EPM_find_process_template.

18. Check if `tProcTemp` is not a null tag (CheckNull3(tProcTemp)).

 If `tProcTemp` is null, log an error message and exit.


 Otherwise, proceed.

19. Define a process name `cpProcessName` as "New workflow process."

20. Refresh `tNewForm` with `true` as an argument using AOM_refresh.

21. Set the `attachments` array to contain `tNewForm` and `attachment_types` array to contain
`EPM_target_attachment`.

22. Create a new process (`tNewProTemp`) with the name `cpProcessName`, "FormDesc,"
`tProcTemp`, and the attachment information using EPM_create_process.

23. Save `tNewForm` without extensions using AOM_save_without_extensions.

24. Refresh `tNewForm` with `false` as an argument using AOM_refresh.

25. Free the memory allocated for `newFormName` using SAFE_SM_FREE.

26. Log an exit message.

27.End
CODE

#undef ITKCALL // The macro function to check for the api errors
#define ITKCALL(argument) \
do { \
int retcode = argument; \
if (retcode != ITK_ok) { \
char* s; \
TC_write_syslog("Function call: %s\n", #argument); \
TC_write_syslog("Returns [%d]\n", retcode); \
EMH_store_error(EMH_severity_error, retcode);\
EMH_ask_error_text(retcode, &s); \
TC_write_syslog("Teamcenter ERROR--------------------: [%s]\n", s); \
TC_write_syslog("File: %s, Line-----------------------: %d\n\n", __FILE__, __LINE__); \
if (s != NULL) MEM_free(s); \
}\
} while (0)

int CheckNull3(tag_t Tag) // function to check the nulltag


{
if(Tag!=NULLTAG)return 0;
else {
TC_write_syslog("\n The tag is empty\n");
return 1;}
}

int A7Form_extension(METHOD_message_t * msg, va_list /*args*/) {


TC_write_syslog("\n -------------Entry------------\n");
tag_t tRev = msg->object_tag;
tag_t tSpecification = NULLTAG;
tag_t tRelation = NULLTAG;
tag_t tNewForm = NULLTAG;
tag_t tProcTemp = NULLTAG;
tag_t tNewProTemp = NULLTAG;
tag_t attachments[1];
int iSize = 0;
char* cpRevID = NULL;
char* cpItemid = NULL;
char* cpcRevid = NULL;
const char* cpProcessTempName = "product work flow";

CheckNull3(tRev); // check for nulltag

ITKCALL(ITEM_ask_rev_id2(tRev, &cpRevID)); // taking the revision id


ITKCALL(AOM_ask_value_string(tRev, "current_id", &cpItemid)); // taking the value
from the current_id property
ITKCALL(AOM_ask_value_string(tRev, "current_revision_id", &cpcRevid)); // taking the
value from the current_revision_id property

TC_write_syslog("\nThe Item id is %s\n", cpItemid);


TC_write_syslog("\nThe Revision ID:%s\n", cpRevID);
TC_write_syslog("\nThe Revision ID is empty\n");

iSize = tc_strlen(cpItemid) + tc_strlen(cpcRevid) + 4; // calculating the size to store the


name for the dataset
char* newFormName = (char*) MEM_alloc(iSize * sizeof(char)); // allocation of memory
for the name variable
sprintf(newFormName, "%s_%s_ATT", cpItemid, cpcRevid);
ITKCALL(FORM_create2(newFormName, "FormDesc", "A7Cus_FORM", &tNewForm));
// creating form with custom form business object
CheckNull3(tNewForm); // check for nulltag
AOM_save_without_extensions(tNewForm);

ITKCALL(GRM_find_relation_type("IMAN_specification", &tSpecification)); // finding


the relation to attach the created dataset to the item revision
CheckNull3(tSpecification); // check for nulltag

ITKCALL(GRM_create_relation(tRev, tNewForm, tSpecification,NULLTAG,


&tRelation));// creating the relation
CheckNull3(tRelation); // check for nulltag
GRM_save_relation(tRelation);
TC_write_syslog("\nThe grm relation is found\n");

ITKCALL(EPM_find_process_template(cpProcessTempName, &tProcTemp)); // finding


the process template
CheckNull3(tProcTemp); // check for nulltag
const char* cpProcessName = "New workflow process";
AOM_refresh(tNewForm, true);

attachments[0] = (tag_t)tNewForm;

int attachment_types[1];
attachment_types[0] = EPM_target_attachment;
ITKCALL(EPM_create_process(cpProcessName, "FormDesc", tProcTemp, 1, attachments,
attachment_types, &tNewProTemp)); //creating the new process ufing workflow template

AOM_save_without_extensions(tNewForm);
AOM_refresh(tNewForm, false);

SAFE_SM_FREE(newFormName);

TC_write_syslog("-------------End-------------\n");

return 0;
}

You might also like