///////////////////////////////////////////////////////////////////////////// // // OPERATION: oTZEREMDO_DeleteEntity // // PURPOSE: Delete Relationship from ER Model // ///////////////////////////////////////////////////////////////////////////// zOPER_EXPORT zSHORT OPERATION oTZEREMDO_DeleteEntity( zVIEW vTZEREMDO, zSHORT nReposition ) { zVIEW vTZEREMD1; zVIEW vTZERSASO; zVIEW vSubtask; // to refresh ER Diagram zSHORT nRC; zLONG lEntityZKey; LPLIBRARY hLibrary = 0; // used for dynamic call to ER control func's zFARPROC_RemoveFunc lpfn = 0; // Position and determine if there are any relationships involving // this Entity prior to deleting the Entity. nRC = CreateViewFromViewForTask( &vTZEREMD1, vTZEREMDO, 0 ); nRC = GetIntegerFromAttribute( &lEntityZKey, vTZEREMD1, "ER_Entity", "ZKey" ); nRC = SetCursorFirstEntityByInteger( vTZEREMD1, "ER_Entity_2", "ZKey", lEntityZKey, "EntpER_Model" ); // Delete the entity if it is involved in any relationships. if ( nRC >= zCURSOR_SET ) { // Loop and Delete all ER RelLinks for ( nRC = SetCursorFirstEntity( vTZEREMDO, "ER_RelLink", "" ); nRC >= zCURSOR_SET; nRC = SetCursorNextEntity( vTZEREMDO, "ER_RelLink", "" ) ) { oTZEREMDO_DeleteRelationship( vTZEREMDO, zREPOS_NONE, 1 ); } // Check to if all relationships were deleted. if ( SetCursorFirstEntityByInteger( vTZEREMD1, "ER_Entity_2", "ZKey", lEntityZKey, "EntpER_Model" ) >= zCURSOR_SET ) { DropView( vTZEREMD1 ); return( -1 ); } } // Delete ER Entity if ( GetViewByName( &vSubtask, "TZEREMDD", vTZEREMDO, zLEVEL_TASK ) > 0 ) { lpfn = (zFARPROC_RemoveFunc) GetOperationDynamicCallAddress( vSubtask, (LPLPLIBRARY) &hLibrary, "TZCTL", "RemoveEntity", "(tzlooprs)" ); if ( lpfn ) (*lpfn)( vSubtask, "ERD", 0, 0 ); } nRC = DeleteEntity( vTZEREMDO, "ER_Entity", nReposition ); // It is possible that the ER_Entity we just deleted is part of an // opened Subject Area. If so, we must be sure that Subject Area doesn't // have hanging SA_Entity entities. if ( GetViewByName( &vTZERSASO, "TZERSASO", vTZEREMDO, zLEVEL_TASK ) > 0 ) { nRC = SetCursorFirstEntity( vTZERSASO, "SA_Entity", 0 ); while ( nRC >= zCURSOR_SET ) { if ( CheckExistenceOfEntity( vTZERSASO, "ER_Entity" ) < zCURSOR_SET ) { if ( GetViewByName( &vSubtask, "SAVIEW", vTZEREMDO, zLEVEL_TASK ) > 0 ) { if ( lpfn == 0 ) // only get func addr once { lpfn = (zFARPROC_RemoveFunc) GetOperationDynamicCallAddress( vSubtask, (LPLPLIBRARY) &hLibrary, "TZCTL", "RemoveEntity", "(tzlooprs)" ); } if ( lpfn ) (*lpfn)( vSubtask, "ERD", 0, 0 ); } DeleteEntity( vTZERSASO, "SA_Entity", zREPOS_NONE ); } nRC = SetCursorNextEntity( vTZERSASO, "SA_Entity", 0 ); } } DropView( vTZEREMD1 ); return( 0 ); }
///////////////////////////////////////////////////////////////////////////// // // OPERATION: oTZEREMDO_DeleteRelationship // // PURPOSE: Delete Relationship from ER Model // ///////////////////////////////////////////////////////////////////////////// zOPER_EXPORT zSHORT OPERATION oTZEREMDO_DeleteRelationship( zVIEW vTZEREMDO, zSHORT nReposition, zSHORT nQuietMode ) { zVIEW vTZERSASO; zVIEW vSubtask; zVIEW vERD; zSHORT nRC; unsigned long ulZKey; LPLIBRARY hLibrary = 0; // used for dynamic call to ER control func's zFARPROC_RemoveFunc lpfn = 0; // Positon on ER_RelType on Right Side( side representing relationships // only ) thus allowing a single Delete to cascade and Delete all // representations of the Relationship on both sides of the Object. nRC = SetCursorFirstEntityByEntityCsr( vTZEREMDO, "ER_RelType", vTZEREMDO, "ER_RelType_1", "EntpER_Model" ); if ( GetViewByName( &vSubtask, "TZEREMDD", vTZEREMDO, zLEVEL_TASK ) > 0 ) { if ( lpfn == 0 ) // only get func addr once { lpfn =(zFARPROC_RemoveFunc) GetOperationDynamicCallAddress( vSubtask,(LPLPLIBRARY) &hLibrary, "TZCTL", "RemoveRelationship", "(tzlooprs)" ); } if ( lpfn ) (*lpfn)( vSubtask, "ERD", 0, 0 ); } // if delete Relationship and this Relationship is a part of the // Identifier, then delete the Relationship from the Identifier CreateViewFromViewForTask( &vERD, vTZEREMDO, 0 ); for ( nRC = SetCursorFirstEntity( vERD, "ER_RelLink_2", "" ); nRC >= zCURSOR_SET; nRC = SetCursorNextEntity( vERD, "ER_RelLink_2", "" ) ) { GetIntegerFromAttribute( &ulZKey, vERD, "ER_RelLink_2", "ZKey" ); for ( nRC = SetCursorFirstEntityByInteger( vERD, "ER_RelLinkIdentifier", "ZKey", ulZKey, "EntpER_Model" ); nRC >= zCURSOR_SET; nRC = SetCursorNextEntityByInteger( vERD, "ER_RelLinkIdentifier", "ZKey", ulZKey, "EntpER_Model" )) { if ( CheckExistenceOfEntity( vERD, "ER_AttributeIdentifier" ) == zCURSOR_NULL ) { DeleteEntity( vERD, "ER_FactType", zREPOS_NONE ); } } } DropView( vERD ); nRC = DeleteEntity( vTZEREMDO, "ER_RelType", nReposition ); if ( nReposition != zREPOS_NONE ) { if ( nReposition == zREPOS_NEXT ) SetCursorNextEntity( vTZEREMDO, "ER_RelLink", "" ); else SetCursorPrevEntity( vTZEREMDO, "ER_RelLink", "" ); } // It is possible that the ER_RelType we just deleted is part of an // opened Subject Area. If so, we must be sure that Subject Area doesn't // have hanging SA_RelType entities that result from the deleted // relationships. if ( GetViewByName( &vTZERSASO, "TZERSASO", vTZEREMDO, zLEVEL_TASK ) > 0 ) { nRC = SetCursorFirstEntity( vTZERSASO, "SA_RelType", 0 ); while ( nRC >= zCURSOR_SET ) { if ( CheckExistenceOfEntity( vTZERSASO, "ER_RelType" ) < zCURSOR_SET ) { if ( GetViewByName( &vSubtask, "SAVIEW", vTZEREMDO, zLEVEL_TASK ) > 0 ) { if ( lpfn == 0 ) // only get func addr once { lpfn = (zFARPROC_RemoveFunc) GetOperationDynamicCallAddress( vSubtask, (LPLPLIBRARY) &hLibrary, "TZCTL", "RemoveRelationship", "(tzlooprs)" ); } if ( lpfn ) (*lpfn)( vSubtask, "ERD", 0, 0 ); } DeleteEntity( vTZERSASO, "SA_RelType", zREPOS_NONE ); } nRC = SetCursorNextEntity( vTZERSASO, "SA_RelType", 0 ); } } return( 0 ); }
///////////////////////////////////////////////////////////////////////////// // // bSubcontrol - TRUE - add controls to existing pZSubtask->m_pZMIXCtrl // FALSE - delete existing pZSubtask->m_pZMIXCtrl and start // a new list // ///////////////////////////////////////////////////////////////////////////// void OPERATION CreateZeidonCtrls( zVIEW vSubobject, ZSubtask *pZSubtask, CWnd *pWndParent, ZMapAct *pzmaComposite, zSHORT nOffsetX, zSHORT nOffsetY, zBOOL bSubcontrol ) { zKZWDLGXO_Ctrl_DEF CtrlDef; zFARPROC_CONTROL lpfnCtrlProc; LPLIBRARY hCCtlLibrary; zPCHAR pchDLL_Name; zPCHAR pchCOP; zSHORT nRC; #ifdef DEBUG_ALL TraceLineX( "CreateZeidonCtrls parent - ", (zLONG) pZSubtask ); #endif nRC = CheckExistenceOfEntity( vSubobject, szlCtrl ); if ( bSubcontrol == FALSE ) { mDeleteInit( pZSubtask->m_pZMIXCtrl ); if ( nRC > zCURSOR_UNCHANGED ) { zLONG lTempCtrlCnt; // just to get the long temporarily GetIntegerFromAttribute( &lTempCtrlCnt, pZSubtask->m_vDialog, szlWnd, "CtrlCnt" ); // TraceLineI( "CreateZeidonCtrls count ", lTempCtrlCnt ); pZSubtask->m_pZMIXCtrl = new ZMultiIdxSet( (fnCOMPARE) fnCompareCtrlNodes, (fnCOMPARE) fnSeekCtrlNode, lTempCtrlCnt ); // Instead of having ZMultiIdxSet delete the nodes itself, we call // a recursive routine (fnDeleteCtrls) to guarantee the child // controls are deleted before their parents. } else pZSubtask->m_pZMIXCtrl = 0; CreateViewFromViewForTask( &(pZSubtask->m_vPE), pZSubtask->m_pZTask->m_vPE, pZSubtask->m_vDialog ); } #ifdef DEBUG_LODSTRUCT zmemset( CtrlDef.Tag, 0xFE, sizeof( CtrlDef ) ); // CtrlDef.CheckByte = 0xFE; #endif while ( nRC > zCURSOR_UNCHANGED ) { // Get the structure of attributes for this control. zPCHAR pch = 0; // for derived Text attribute GetStructFromEntityAttrs( (zPCHAR) CtrlDef.Tag, vSubobject, szlCtrl ); #ifdef DEBUG_LODSTRUCT if ( CtrlDef.CheckByte != 0xFE ) MessageBox( 0, "CtrlDef Structure Length Error", "GetStructFromEntityAttrs", MB_OK ); // zPCHAR pchCheckByte = (zPCHAR) &(CtrlDef.CheckByte); // pchCheckByte--; // if ( *pchCheckByte == (char) 0xFE ) // TraceLineS( "zdrctl CtrlDef CheckByte error??", "" ); #endif GetAddrForAttribute( (zPCHAR *) &pch, vSubobject, szlCtrl, szlD_Text ); if ( *pch ) zstrcpy( CtrlDef.Text, pch ); #ifdef DEBUG_ALL TraceLineS( "Tag ", CtrlDef.Tag ); TraceLineI( "Type ", CtrlDef.Type ); TraceLineI( "IdNbr ", CtrlDef.IdNbr ); TraceLineI( "PSDLG_X ", CtrlDef.PSDLG_X ); TraceLineI( "PSDLG_Y ", CtrlDef.PSDLG_Y ); TraceLineI( "SZDLG_X ", CtrlDef.SZDLG_X ); TraceLineI( "SZDLG_Y ", CtrlDef.SZDLG_Y ); #endif // The token is validated by the painter and/or conversion to // the executable object, but we check here anyway. nRC = SetCursorFirstEntityByInteger( pZSubtask->m_pZTask->m_vPE, szlCtrl, szlKey, CtrlDef.Type, 0 ); if ( nRC != zCURSOR_SET ) { TraceLine( "(drvr) ID (%d) not found (%d) in PPE for Ctrl: %s.%s.%s", CtrlDef.Type, nRC, pZSubtask->m_pzsDlgTag ? *(pZSubtask->m_pzsDlgTag) : "?", pZSubtask->m_pzsWndTag ? *(pZSubtask->m_pzsWndTag) : "?", CtrlDef.Tag ); DisplayEntityInstance( pZSubtask->m_pZTask->m_vPE, szlCtrl ); DisplayObjectInstance( pZSubtask->m_pZTask->m_vPE, 0, 0 ); // Skip this one and try the next. nRC = SetCursorNextEntity( vSubobject, szlCtrl, 0 ); continue; } GetAddrForAttribute( (zPCHAR *) &pchDLL_Name, pZSubtask->m_pZTask->m_vPE, szlCtrl, szlDLL ); GetAddrForAttribute( (zPCHAR *) &pchCOP, pZSubtask->m_pZTask->m_vPE, szlCtrl, szlCOP ); // If the DLL name is added to the list, this is the first time it // has been encountered ... so call its initialization routine. pZSubtask->m_pZTask->AddApplicationDLL( pZSubtask, pchDLL_Name ); hCCtlLibrary = 0; // set to zero for GetOperationDynamicCallAddress lpfnCtrlProc = (zFARPROC_CONTROL) GetOperationDynamicCallAddress( pZSubtask->m_vDialog, (LPLPLIBRARY) &hCCtlLibrary, pchDLL_Name, pchCOP, "(drvr) Ctrl" ); try { if ( lpfnCtrlProc ) // && (k % 2) == 0 ) { // TraceLineS( "Create Control: ", pchCOP ); (*lpfnCtrlProc)( pZSubtask, pWndParent, pzmaComposite, vSubobject, nOffsetX, nOffsetY, &CtrlDef ); } } #if 0 catch( CResourceException *e ) { zCHAR szMsg[ 256 ]; e->GetErrorMessage( szMsg, sizeof( szMsg ) ); zstrcat( szMsg, } #endif catch( CException *e ) { zCHAR szMsg[ 256 ]; e->GetErrorMessage( szMsg, sizeof( szMsg ) ); MessageSend( pZSubtask->m_vDialog, 0, "Zeidon Control", szMsg, zMSGQ_MODAL_ERROR, FALSE ); break; } nRC = SetCursorNextEntity( vSubobject, szlCtrl, 0 ); } // end of: while ( nRC == zCURSOR_UNCHANGED ) looping thru controls if ( bSubcontrol == FALSE ) { DropView( pZSubtask->m_vPE ); pZSubtask->m_vPE = 0; // using this to determine Ctrls have been created // Ctrl creation is complete ... notify each ctrl. if ( pZSubtask->m_pZMIXCtrl ) { pZSubtask->m_pZMIXCtrl->VisitInorder( (fnVISIT_INORDER) fnPostCreateCtrls, 0, 0, 0 ); } } }