home *** CD-ROM | disk | FTP | other *** search
- #---------------------------------------------------------------------------
- #
- # Copyright (c) 1992-1995 by Cadre Technologies Inc.
- #
- # This software is furnished under a license and may be used only in
- # accordance with the terms of such license and with the inclusion of
- # the above copyright notice. This software or any other copies thereof
- # may not be provided or otherwise made available to any other person.
- # No title to and ownership of the software is hereby transferred.
- #
- # The information in this software is subject to change without notice
- # and should not be construed as a commitment by Cadre Technologies Inc.
- #
- #---------------------------------------------------------------------------
- #
- # File : @(#)check.tcl /main/hindenburg/4
- # Author : edri
- # Original date : 03-10-94
- # Description : Check front end
- #
- #---------------------------------------------------------------------------
- #
-
- source [m4_path_name tcl cginit.tcl]
-
- require legacy.tcl
- require wmt_util.tcl
- require chktcl_msg.tcl
- require check_util.tcl
- require check_conf.tcl
- require checks.tcl
- require prep_disp.tcl
- require prep_funcs.tcl
- require prep_db_fn.tcl
- require chk_disp.tcl
- require chk_funcs.tcl
- require chk_db_fn.tcl
- require libsql.tcl
-
- global ooplClassFilter; set ooplClassFilter ""
- global ooplExclClassFilter; set ooplExclClassFilter ""
-
- #
- # See if any boolean options were specified, set the appropriate
- # variables, and remove any options from argv.
- #
- proc parse_options {} {
- global boolean_options argv
- foreach opt $boolean_options {
- set i [lsearch $argv [lindex $opt 0]]
- set optvar [lindex $opt 1]
- eval "global $optvar"
- if {$i == -1} {
- set optdef [lindex $opt 2]
- eval "set $optvar $optdef"
- } else {
- set argv [lreplace $argv $i $i]
- eval "set $optvar 1"
- }
- }
- }
-
- #
- # Set check status for specified diagram
- #
-
- proc set_check_status {diagramName {newStatus ""}} {
- # E_SET_CHECK_STATUS Wrong number of arguments, should be: set_check_status diagram.type [reset|ok|failed]
-
- set fileName [nt_get_name $diagramName]
- set fileType [nt_get_type $diagramName]
-
- if {$fileName == "" || $fileType == ""} {
- puts stderr "ERROR: set_check_status: file name '$diagramName' not of format 'diagram.type'"
- return 0
- }
-
- set cc [ClientContext::global]
- set sysV [$cc currentSystem]
- set fileV [$sysV findFileVersion $fileName $fileType]
-
- if [$fileV isNil] {
- #
- # Exceptional case: A.B.cdm
- #
-
- set fileV [$sysV findFileVersion $fileName.$fileType cdm]
-
- if [$fileV isNil] {
- puts stderr "ERROR: set_check_status: '$diagramName': no such fileV"
- return 0
- }
- }
-
- switch -exact -- "$newStatus" {
- "" -
- reset { set status "not checked" }
- ok { set status "checked OK" }
- failed { set status "checked with errors" }
- default { puts stderr "ERROR: set_check_status: '$newStatus': bad status; should be one of \[reset|ok|failed\]" ; return 0}
- }
-
- if 0 {
- #
- # Cannot set property while diagram is locked ...
- #
- if {[catch {$fileV setProperty check_status "$status"} reason]} {
- # for now, ignore failure message...
- #m4_warning $W_CHECK_STATUS "$status"
- #puts stderr "WARNING: Unable to set property 'check_status' to value '$status'"
- #puts stderr $reason
- return 0
- }
- } # 0
-
- return 1
- }
-
-
-
-
- #
- # Main entry point for extended checking
- #
- proc checkMain {} {
- global oomodel ooplmodel
-
- m4_message $M_STARTING_EXTENDED_CHECKING
- M4CheckManager::resetErrorCount
- parse_options
-
- if {$usecase} {
- uplevel #0 {require chkucmodel.tcl}
- checkUseCaseModel
- show_errors
- return
- }
-
- OTShRegister::check
-
- find_file_types
- set sources ""
- set eventtypes ""
- set diagram_count 0
- set diagram ""
- foreach obj [CommandLineInterface::getSourceObjects] {
- if {[string first "." $obj] == -1} {
- # obj is a class
- lappend sources $obj
- } else {
- set diagname [nt_get_name $obj]
- set diagtype [string tolower [nt_get_type $obj]]
- if {$diagtype == "cdm"} {
- # obj is a class after all
- lappend sources $diagname
- continue
- } elseif {$diagtype == "ccd" ||
- $diagtype == "etd" ||
- $diagtype == "std"} {
- # Remember which kinds of events are needed
- lappend eventtypes $diagtype
- } elseif {$diagtype != "cad"} {
- m4_message $M_CANNOT_CHECK_DIAG_TYPE $diagname $diagtype
- continue
- }
-
- # remember if just one event diagram is specified; if so,
- # we only check events in that diagram
- if {$diagtype == "ccd" ||
- $diagtype == "etd" ||
- $diagtype == "std"} {
- incr diagram_count
- if {$diagram_count == 1} {
- set diagram $obj
- } else {
- set diagram ""
- }
- }
-
- # add diagram to sources
- lappend sources $obj
- }
- }
-
- #
- # If no event diagrams specified or doing global checking,
- # get events sent in any diagram
- #
- if {[lempty $eventtypes] || $global} {
- set eventtypes {ccd etd std}
- }
-
- #
- # Check(s) needing specific types of events to be loaded.
- #
- if {[M4CheckManager::errorControl $E_NO_CORR_CCDMSG_FOUND] != "off"} {
- lappend eventtypes "ccd"
- }
-
- if { [[ClientContext::global] currentLevel] == "File" } {
- [ClientContext::global] upLevel
- }
- set oomodel [load_model $sources $eventtypes $global 0 1 $timing]
- if {"$oomodel" == ""} {
- m4_message $M_LOADING_OOPL_FAILED
- show_errors
- return
- }
- set ooplmodel [$oomodel ooplModel]
-
- #
- # Prepare the model for checking
- #
- puts stdout "\nPreparing the model for checking.\n"
- prepare $ooplmodel check
- if {[$oomodel error] > 0} {
- m4_message $M_PREPARE_CHECK_FAILED
- $oomodel delete
- return
- }
-
- # Check the internal model
- #
- $ooplmodel check "$sources"
-
- #set sqlmodel [$oomodel sqlModel]
- #$sqlmodel check
- #
- # Check the model
- #
- puts stdout "\nChecking the model.\n"
- check $ooplmodel $diagram
- show_errors
-
- #
- # Update check statusses of all specified diagrams.
- #
- # Note that this may set the status of a diagram incorrectly, for
- # example if a diagram was specified that did not contain any
- # incorrect classes.
- #
- foreach diagram $sources {
- if {[string first "." $diagram] > 0} {
- set status [expr {([M4CheckManager::getErrorCount] == 0) ? "ok" : "failed"}]
- if [catch {set_check_status $diagram $status} msg] {
- puts stdout "$diagram: $msg\n"
- }
- }
- }
-
- $oomodel delete
- }
-
- #
- # Load and return the OOModel for the specified list of sources, which is
- # a list of diagram names and/or class names.
- #
- proc load_model {sources eventtypes global {quiet "0"} {subjects 1} {time 0}} {
-
- if {$global} {
- #
- # Global checking, load all classes, except the ones specified.
- # Also load all CCD Subjects in the system.
- #
- if {!$quiet} {
- m4_message $M_LOADING_MODEL
- }
- } else {
- if [lempty $sources] {
- if {!$quiet} {
- m4_message $M_NO_CLASSES_SPECIFIED
- }
- return ""
- }
- #
- # Only load CCD Subjects in any CCDs specified.
- #
- if {!$quiet} {
- m4_message $M_LOADING_SPECIFIED
- }
- }
-
- set time_info [time {eval "set model \[OOModel::createModel]"}]
- global ooplClassFilter
- set ooplClassFilter $sources
-
- if {$time} {
- set classcount [llength [getSelectedClasses [$model ooplModel]]]
- puts stdout "Loaded $classcount classes in\
- [format %3.2f [expr {"[lindex $time_info 0].0" / 1000000.0}]] seconds.\n"
- }
-
- if {[$model error] > 0} {
- $model delete
- return ""
- }
-
- return $model
- }
-
-
- set cc [ClientContext::global]
-
- #
- # Add or override certain check functions by target language dependent checks
- # using the file "langchecks.tcl" (which typically resides in the l_$target_lang
- # sub directory)
- #
- if {[$cc customFileExists langchecks tcl tcl 1]} {
- require langchecks.tcl
- }
-
- #
- # Let user override certain check functions using the u_check.tcl file.
- #
- if {[$cc customFileExists u_check tcl "" 0]} {
- require u_check.tcl
- }
-
- #
- # Just call checkMain
- #
- if [catch {checkMain} msg] {
- if {"[string range $msg 0 5]" == "ERROR:"} {
- puts stderr $msg
- } else {
- puts stderr $errorInfo
- }
- }
-