/******************************************************************************* * linkDoDeleteLinks * This function is the main loop through each object in the source module, * looping through the links in the object and verifying the target OID is in * the trace attribute. If it is not in the trace attribute, then it calls * the routine that actually deletes the link. * Function concludes by telling user if link deletion success, to save the * appropriate module and if there were any link errors. * Function returns true if any links were deleted. */ bool linkDoDeleteLinks(Module src_mod, trg_mod, string trg_name, link_name, attr_name, int link_dir) { Object o, trg_obj string values, value, msg, sTrgObj int links_deleted = 0 Link l bool bTraceAttrFound = false Module mTrg current = src_mod if (!exists attribute attr_name) { warningBox dxlStrformat(LS_("String_The_specified_attribute_s_does_not_exist",NLSTEMP_("The specified attribute '%s' does not exist")), attr_name) return false } for o in src_mod do { if ((link_dir == linkLinkSrcToTrg) || (link_dir == linkLinkBothWays)){ //loop to check outgoing links for l in o->link_name do { //loop through outgoing links only through selected link module bTraceAttrFound = false mTrg = read(fullName(target l), false) if (null mTrg){ sError_Log = sError_Log "ERROR: Unable to open module " fullName(target l) " - skipping link from source module OID: " identifier o "\n" continue } if (mTrg != trg_mod) { //check if right target module continue //not right target module, so skip to next link } trg_obj = target l sTrgObj = trg_obj."Absolute Number" "" //get target OID values = probeAttr_(o, attr_name) //get all trace attribute OIDs while (!null values) { //loop through all values value = linkNextValue(values) //get next value and adjust values if (!null value) { if(value == sTrgObj) { bTraceAttrFound = true //found OID in trace attr so set flag } //end if (value... } //end if !null value } // end while (!null //done going through values, now check if should delete link if (bTraceAttrFound == false){ //Wasn't found, so try to delete the link if(!canModify o) { //first check to see if can modify the object //can't modify object, so put it in the error log sError_Log = sError_Log "Unable to delete link from source OID:" identifier o " to target OID:" sTrgObj ". Section not locked.\n" } else { //can modify object so delete the link if (DEBUG) print "Link not found in trace attribute, deleting link from source OID:" identifier o " to target OID:" sTrgObj "\n" delete (l) links_deleted++ } } } //end for l } //end of loop for outgoing links if ((link_dir == linkLinkTrgToSrc) || (link_dir == linkLinkBothWays)){ //loop for all incoming links for l in o<-link_name do { //loop through incoming links only through selected link module bTraceAttrFound = false string smTrg = fullName(source l) if (DEBUG) print "smTrg=" smTrg " trg_name=" trg_name "\n" if (smTrg != trg_name) { //check if right target module continue //not right target module, so skip to next link } trg_obj = source l sTrgObj = trg_obj."Absolute Number" "" //get target OID values = probeAttr_(o, attr_name) //get all trace attribute OIDs while (!null values) { //loop through all values value = linkNextValue(values) //get next value and adjust values if (!null value) { if(value == sTrgObj) { bTraceAttrFound = true //found OID in trace attr so set flag } //end if (value... } //end if !null value } // end while (!null //done going through values, now check if should delete link if (bTraceAttrFound == false){ //Wasn't found, so delete the link if(!canModify trg_obj) { //first check to see if can modify the object //can't modify object, so put it in the error log sError_Log = sError_Log "Unable to delete link from target OID:" sTrgObj " to source OID:" identifier o ". Section not locked.\n" } else { if (DEBUG) print "Link not found in trace attribute, deleting link from target OID:" sTrgObj " to source OID:" identifier o "\n" delete (l) links_deleted++ } } } } //end of loop for incoming links }//end for o in... if (links_deleted == 0){ return false } //links were made, flush to do link deletions and return success flushDeletions() refresh src_mod refresh trg_mod return true } // linkDoDeleteLinks