data browser interface for the composite ...web.mit.edu/smadnick/www/wp2/1991-04.pdfchapter 2 -...

122
DATA BROWSER INTERFACE FOR THE COMPOSITE INFORMATION SYSTEM Thomas Parker May 1991 WP # CIS-91-04

Upload: others

Post on 19-Apr-2020

5 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: DATA BROWSER INTERFACE FOR THE COMPOSITE ...web.mit.edu/smadnick/www/wp2/1991-04.pdfChapter 2 - Architecture This chapter describes the architecture that was used to build the CIS

DATA BROWSER INTERFACE FOR THECOMPOSITE INFORMATION SYSTEM

Thomas Parker

May 1991 WP # CIS-91-04

Page 2: DATA BROWSER INTERFACE FOR THE COMPOSITE ...web.mit.edu/smadnick/www/wp2/1991-04.pdfChapter 2 - Architecture This chapter describes the architecture that was used to build the CIS

Data Browser Interface forthe Composite Information System

by

Thomas H. Parker

Master of Science Thesis in ManagementMassachusetts Institute of Technology

Cambridge, MA 02139

WP# CIS-91-04

ABSTRACT

As the use of computer based information systems has become more andmore widespread, organizations increasingly desire to integrate informationacross disparate databases. Previous work at MIT has focused on developingsoftware to link together heterogeneous databases and automate the task ofdata retrieval. This work has lead to the development of prototype softwarecalled the Composite Information System/Tool Kit (CIS/TK).

Most of the work to date has focused on developing 'back-end" data retrievalsoftware. In contrast, the result of this thesis has been a "front-end" softwareprototype called the CIS Data Browser (CIS/DB). CIS/DB is a flexible, menudriven system that works in conjunction with CIS/TK to facilitate theretrieval of information from distributed heterogeneous databases. Thisthesis describes the architecture of CIS/DB as well as how to use the software.It is hoped that the CIS/DB will provide the foundation for futuredevelopment of CIS user interface software.

KEYWORDS AND PHRASES: distributed database management systems,user interface, query generation, client/server archtecture, CIS/TK.

ACKNOWLEDGEMENTS: Stuart Madnick, Thesis Advisor; Henry Kon, PhD.candidate; Wilberto Martinez SB '89.

Page 3: DATA BROWSER INTERFACE FOR THE COMPOSITE ...web.mit.edu/smadnick/www/wp2/1991-04.pdfChapter 2 - Architecture This chapter describes the architecture that was used to build the CIS

Table of Contents

A bstract...........................................................................................................................2A cknow ledgem ents.....................................................................................................3Table of Contents ............................................................................................... 4Chapter - 1 Introduction.......... ............ ...... 5

1.1 Background ........................... .............. 51.2 Goals ............................................ 61.3 Layout of this Document................... ............. ...........6

Chapter 2 - Architecture............. ........................ ........82.1 Overview........................... ................ .... 82.2 Communication between CIS/TK and CIS/DB Server....................92.3 Communication between Server and Client..............................112.4 Communication between Client and User..............................132.5 Architecture Decisions...................................................13

Chapter 3 - User Guide........................................ .................................. 163.1 Overview ........... ............................... .163.2 Tips on Using the Application........................... 183.3 Defining a Query................................... .......... ........193.4 Executing a Query ................................... 21

Chapter 4 - Future Research......................... ...... ...... .... 244.1 CIS/TK..................................................244.2 CIS Data Browser..... . . .. ........ .............................. 26

Chapter 5 - Conclusion................. ................... ....... 30Bibliography................. ................................. 31Appendix A - System Configuration........ .......... .............. 32

A.1 The Client and Server Applications........... ............................ 32A.2 CIS/TK. ................................ ............ 33A.3 Running the Software................................................33

Appendix B - Source Code Files.................................... .............................. 36B.1 "c" Files.... . . ................................................ 36B.2 Screen Files............ . ............................... ... 104B.3 Miscellaneous Files................ ......................................... 118

Appendix C - File Formats......................... ........... 122C.1 Global Schema Exchange File........................... ..... 122C.2 Query Files..........................................................122C.3 Messages........................... .......... ........122

Page 4: DATA BROWSER INTERFACE FOR THE COMPOSITE ...web.mit.edu/smadnick/www/wp2/1991-04.pdfChapter 2 - Architecture This chapter describes the architecture that was used to build the CIS

Chapter - 1 Introduction

1.1 Background

As the use of computer based information systems has become more andmore widespread, information users increasingly desire to integrateinformation from different sources. In a corporate setting, differentdepartments typically each have their own (i.e. heterogeneous) databases.These databases might be in different file formats, reside on differentmachines, located at different sites. Even within a department some or all ofthese incompatibilities may exist. In most organizations, the task ofcombining data from different databases typically takes days, if not weeks, andrequires many person-hours to accomplish.

The Composite Information System/Tool Kit (CIS/TK) is a prototype beingdeveloped at the MIT Sloan School of Management for providingconnectivity among disparate information systems. Specifically, the goal ofthe CIS/TK project is to develop tools which can combine data fromheterogeneous databases and deliver the data to an information user withoutthe user having to understand the intricacies of the source databases. That is,the user should be presented with a single unified database rather thanseveral unconnected databases. A truly unified database will make thefollowing items transparent to the user:

e The physical location of the data (e.g. Boston, Los Angeles)e The structure of the data (e.g. Oracle file, ASCII file)* The method for retrieving the data (e.g. SQL commands)

Most of the research to date has focused on the underlying software forgathering and joining data across databases, that is creating a unified databasefrom several heterogeneous databases. Little work has been done ondeveloping software (i.e. a user agent (UA)) that can be used by a non-technical person to view data in the unified database. One existing UArequires the user to learn a complex query language. Another is menu drivenand easy to use but only allows the user to ask an extremely limited range ofquestions. This thesis attempts to develop a UA that addresses some of theweaknesses in the previous systems. The next section discusses the goals ofthe UA in more detail.

Page 5: DATA BROWSER INTERFACE FOR THE COMPOSITE ...web.mit.edu/smadnick/www/wp2/1991-04.pdfChapter 2 - Architecture This chapter describes the architecture that was used to build the CIS

1.2 Goals

As discussed in the preceding section, the goal of this thesis is to develop auser agent (UA) for accessing heterogeneous databases which have beenunified by the CIS/TK software. Specific goals are for the UA are:

" Usability" Flexibilitye Accessibility" Adaptability

Usability means that the UA should be extremely easy for any person,technical or non-technical, to use. In the simplest terms, someone should beable to operate the software with a minimum of instruction and withouthaving to read a user's manual. This implies that the UA should be menudriven and not overly complex.

Flexibility means that the UA should allow the user to ask a broad range ofquestions of the database, that is create ad hoc queries. In the past, many UA'shave limited the user to posing a pre-defined set of questions that a databaseanalyst guessed people wanted to ask.

Accessibility means that the system should be available to users at all times. Ifa person can not get access to the system because there is always someone elseusing it, that person will not use the system. This implies that the systemshould have multi-user capabilities.

Adaptability means that the system can present different views of the data todifferent users. Different users have different needs and thus may want toview the same data differently. This implies that the system should be ablework with any CIS/TK data schema.

1.3 Layout of this Document

The software developed for this thesis will henceforth be referred to as theCIS Data Browser (CIS/DB). The remainder of this document provides both atechnical and non-technical description of the software and raises some issuesthat will require further research.

Chapter 2 describes the architecture of both the CIS/DB and the existingCIS/TK software, and the reasons behind the decisions made in designingCIS/DB. This chapter is written for those wishing to gain a technicalunderstanding of how the software works.

Page 6: DATA BROWSER INTERFACE FOR THE COMPOSITE ...web.mit.edu/smadnick/www/wp2/1991-04.pdfChapter 2 - Architecture This chapter describes the architecture that was used to build the CIS

Chapter 3 contains a guide to using the CIS/DB. It presents examples ofcreating and executing a query. This chapter is appropriate for those readerswho would like to take the software for a test drive.

Chapter 4 discusses areas of both the CIS/DB and the CIS/TK system wherefurther research is needed. This chapter is written for those wishing tounderstand the limitations of the current system and the future directionsthat the CIS software should take.

Chapter 5 presents the conclusions of the research.

Appendices A-C contains technical information about the CIS/DB. They areuseful for those wishing to configure the software, make furtherenhancements to the software, or gain a more in depth technicalunderstanding of how the software works than is presented in Chapter 2.

Page 7: DATA BROWSER INTERFACE FOR THE COMPOSITE ...web.mit.edu/smadnick/www/wp2/1991-04.pdfChapter 2 - Architecture This chapter describes the architecture that was used to build the CIS

Chapter 2 - Architecture

This chapter describes the architecture that was used to build the CIS DataBrowser. The chapter documents how the various pieces of software thatmake up the CIS environment interact with one another. In addition, thefinal section of the chapter explains why this particular architecture waschosen.

2.1 Overview

Figure 2-1 shows the four level model upon which the CIS software is built.At the bottom level, are the local databases in which the data is actuallystored. An example of such a database might be a financial database which isstored in Oracle format and is accessed using Structured Query Language(SQL).

At the second level are a set of local query processors (LQP's). The LQP'stranslate global queries into the query language of a local database and alsoperform the steps necessary to access that database. There is one LQP for eachlocal database.

At the third level are the Global Query Processor (GQP) and the GlobalSchema Manager (GSM). The GSM creates a single, unified view of all thelocal databases. The GQP consists of a Global Retrieval Language (GRL) and asystem to take GRL queries and submit them to the LQP's which retrieve theactual data. Both the second and third level software are part of the CIS/TKmodule.

At the top level is the Application Query Processor (AQP). This is the level atwhich an end user interacts with the software. The AQP accepts user inputsand submits them to the Global Query Processor in the form of GRL queries.Because of the multi-level CIS architecture, the AQP can take on many forms.However, the primary purpose of this document is to describe the CIS DataBrowser (CIS/DB) AQP.

Figure 2-2 shows a detailed diagram of the CIS Data Browser architecture.There are two components to the CIS/DB system, a server and a client. Theserver component handles all communication with the CIS/TK software andis written in "c". The client component handles interaction with a user and iswritten in "c" using the JAM application development environment. Mostof CIS/TK is written in the Lisp programming language. The sections thatfollow describe communication between:

" CIS/TK and the CIS/DB Server" The CIS/DB Server and Cliente The CIS/DB Client and an end user

Page 8: DATA BROWSER INTERFACE FOR THE COMPOSITE ...web.mit.edu/smadnick/www/wp2/1991-04.pdfChapter 2 - Architecture This chapter describes the architecture that was used to build the CIS

CIS Data Browser

Global Query ProcessorGlobal Schema Manager

CIS/TK

Local Query Languagee.g. SQL

Local Databases

Figure 2-1 - The Four Level CIS Model

2.2 Communication between CIS/TK and CIS/DB Server

As shown in figure 2-2, the CIS/DB Server and CIS/TK communicatethrough UNIX named pipes. Named pipes are virtual devices that can beread and written in the same manner as files. Whenever the Server isexecuted, it creates two pipes:

" A pipe to carry data from the Server to CIS/TK (the input pipe)e A pipe to carry data from CIS/TK to the Server (the output pipe)

Page 9: DATA BROWSER INTERFACE FOR THE COMPOSITE ...web.mit.edu/smadnick/www/wp2/1991-04.pdfChapter 2 - Architecture This chapter describes the architecture that was used to build the CIS

terminal dbclient

dbserver

terminal

namedpipes

I I

CIS/TK

copy of global schema global schema

Figure 2-2 - The CIS Data Browser Architecture

After creating the pipes, the Server automatically executes the CIS/TKsoftware as a separate process. The standard input stream of CIS/TK is routedthrough the input pipe and the standard output stream of CIS/TK is routedthrough the output pipe. The nature of the relationship between the Serverand CIS/TK is master/slave where the Server is the master and CIS/TK theslave. That is, the Server issues commands and CIS/TK responds to thosecommands.

There are three types of commands that are sent from the Server to CIS/TKthrough the input pipe. The first type is initialization commands. Thesecommands are sent each time CIS/TK is started. The commands are readfrom a file and determine the configuration of CIS/TK. The second type is acommand asking for a copy of the global schema. The third type is acommand asking for the answer to a GRL query. The latter two commandtypes are sent as the result of a message received from a Client process (see thenext section).

dbclient

CIS Data Browser

Page 10: DATA BROWSER INTERFACE FOR THE COMPOSITE ...web.mit.edu/smadnick/www/wp2/1991-04.pdfChapter 2 - Architecture This chapter describes the architecture that was used to build the CIS

The output pipe is used by the Server to determine when CIS/TK hasfinished responding to a command and to determine if a command has leadto an error. Data that is passed from CIS/TK to the Server is not sent directlythrough this pipe. Rather, the data is passed in a temporary file whose nameis passed to CIS/TK through the input pipe.

2.3 Communication between Server and Client

As shown in figure 2-2, the CIS/DB Server and Client communicate througha Unix message queue. A message queue is an area of memory that is set upby Unix to facilitate inter-process communication. Figure 2-3 depicts howqueues work. Programs access queues in a first-in-first-out (FIFO) fashion.That is, every message written to the queue is put at the bottom and eachmessage read from the queue is taken from the top. Every time a message is

Messageis read

from queue

message 1

top top top

message 1 message 2 message 2

message 2 message 3 message 3

message 3 message 4 message 4

message 4 message 5 message 5

message message 6

bottom bottom bottom

message 6

Messageis writtento queue

Figure 2-3 Message Queues

Page 11: DATA BROWSER INTERFACE FOR THE COMPOSITE ...web.mit.edu/smadnick/www/wp2/1991-04.pdfChapter 2 - Architecture This chapter describes the architecture that was used to build the CIS

read it is removed from the queue and all other messages are moved oneposition closer to the top. If there are no messages in the queue, the top andthe bottom of the queue are the same location.

There is one exception to the above rules. A message can contain the addressof the intended recipient. In the CIS/DB application, the address is the Unixprocess ID of the recipient. Each process can thus choose to read onlymessages that are addressed to it.

Through message queue addressing, one Server can communicate with manyClients at the same time. In this way multi-user access to the CIS/TK softwareis accomplished. Each Client acts as a window for each end user into the CISdatabase. When the Client needs information from the database, it writes amessage in the queue addressed to the Server. When the Server has retrievedthe information, it writes a message in the queue addressed to the Client thatmade the request. When data (e.g. a GRL query) is sent between the Clientand the Server, it is not actually sent through the message queue. Rather, theinformation is' placed in a temporary data file and the queue is used to sendthe name of the file..

A message queue is created by the Server process every time that it isexecuted. Each Client subsequently connects to the queue when it is executed.Because the message queue must already exist in order for the Client toconnect to it, a Client process can only be executed when the Server is alreadyexecuting.

There are two types of messages that are sent from a Client process to theServer process. The first type is a request for a copy of the global schema. AClient process sends this message every time it begins execution. The secondtype is a Global Retrieval Language query. The Client process sends thismessage type when the user requests execution of a query. 1 2

There are also two types of messages that are sent from the Server to a Client.Both message types are sent in response to a message from a Client. The firsttype is the information requested by the Client (i.e. a copy of the globalschema or the results of a query), and is sent if the request is successfullyhandled. The second type is an error message. The Server sends errormessages whenever a request for information from a Client is not

1 See Chapter 3 below for a description of how the user executes a query.2 See Appendix C for a precise description of message syntax.

Page 12: DATA BROWSER INTERFACE FOR THE COMPOSITE ...web.mit.edu/smadnick/www/wp2/1991-04.pdfChapter 2 - Architecture This chapter describes the architecture that was used to build the CIS

successfully handled. There are a number of reasons why errors can occurincluding:

e A Local Database needed for a query is not currently running.e A bug in the CIS/TK software prevents the execution of a query." A query was not properly formulated by the Client.

The third type of error has not been encountered in test runs of the software.

2.4 Communication between Client and User

As shown in figure 2-2, a user of CIS/DB communicates with the Clientsoftware through a computer terminal. The terminal can be a standard dumbterminal such as a Digital Equipment Corp. VT-100 or it can be a personalcomputer communicating with the CIS host over a network. All processingof terminal input and output is handled by a product called JAM3 that hasbeen incorporated into the Client software.

JAM is an event driven package that defines interaction with a user at thelevel of screens. Each screen has a pre-defined appearance and a number ofevents associated with it. Each defined event can trigger an action such as:calling a "c" function, opening a new screen, or returning to a previousscreen. Appendix B contains listings in ASCII format of the screens used bythe CIS/DB Client software. The actual screens used by the application are ina binary format.

2.5 Architecture Decisions

There are three major decisions that went into the design of the CIS/DBsoftware:

" Development of a client/server architecture" Use of the "c" programming language" Use of the JAM development environment

The sections below discuss the reasons for each of these decisions.

2.4.1 Client/Server Architecture

A client/server architecture is defined as the separation of the front-endprogram that processes the user interface (the Client) from the back-end dataretrieval engine (the Server). Typically many Clients communicate with one

3 JAM is a product of JYACC, Inc., New York, NY.

Page 13: DATA BROWSER INTERFACE FOR THE COMPOSITE ...web.mit.edu/smadnick/www/wp2/1991-04.pdfChapter 2 - Architecture This chapter describes the architecture that was used to build the CIS

Server. There are three potential benefits of a client/server architecture:

" Supports multiple user access to a shared databasee Increases modularity of programs" Increases system throughput

As noted in the introduction, one of the primary goals for CIS/DB was multi-user access. The current version of CIS/TK supports the processing of onlyone query at a time. Hence only one user can be logged into CIS/TK at a time.The client/server architecture in CIS/DB allows multiple users (Clients) tocreate and edit queries while the Server controls submission of those queriesto CIS/TK. If one client submits a query while another query is beingprocessed, it is placed in a queue. As soon as the first query is processed byCIS/TK, the second one is submitted. This allows for maximum utilizationof the scarce resource (the CIS/TK query processor).

Separating the software into a front-end interface processor and back-end dataretrieval engine increases the modularity of the program. This means that aninternal change can be made to either the Client or the Server softwarewithout effecting the other program. In addition, it is possible to have manydifferent Client programs (i.e. user interfaces) that all communicate with thesame Server. At present, there is only one Client program available.

Separating the Client and Server processes also creates the potential to runthe processes on different computers. This increases the computing resourcesavailable to handle an application and therefore increases system throughput.However, this performance enhancement is not yet supported in CIS/DB.Because the Client and Server communicate through Unix message queues,they must be running on the same computer.

2.4.1 "C"

The "c" programming language was used for CIS/DB for two reasons:

" Fast performancee Built-in inter-process communications capability

The CIS/TK software is built in the Lisp programming language. Lisp offersseveral advantages including its object orientation which makes it simpler todefine a unified database from several heterogeneous databases. However,the dynamic nature of Lisp that makes it ideal for handling object orienteddatabases also causes it to be rather slow. It can take several minutes toprocess moderately complex queries. Because speed enhances usability and"c" is faster than Lisp, "c" was a more logical choice for the development ofthe user interface.

Page 14: DATA BROWSER INTERFACE FOR THE COMPOSITE ...web.mit.edu/smadnick/www/wp2/1991-04.pdfChapter 2 - Architecture This chapter describes the architecture that was used to build the CIS

The architecture defined for the CIS/DB requires communication betweenCIS/TK, the CIS/DB Server, and the CIS/DB Client. Unix provides manymechanisms for communicating between processes, including named pipesand message queues. The fact that "c" can easily take advantage of thesecapabilities, provided another strong reason for its selection.

2.4.2 TAM

The JAM development environment was chosen for a number of reasonsincluding:

" Allows quick development of screense Provides terminal independence" Supports the use of mice

JAM allows the developer to create screens by simply painting them on aterminal. This allows for quick application development while at the sametime ensuring that all screens have a consistent appearance. In addition, JAMsupports "menu" screens. Thus it is easy to create a "user friendly", menudriven application. Menus can also be dynamically defined. This feature isused in CIS/DB to allow the software to operate with any CIS/TK dataschema. Client menus are defined at run time based on the copy of the globalschema that is passed from the Server to the Client.

Because the CIS software does not run on a personal computer, the user mustinteract with it through terminals. Because there are many different terminaltypes and few standards, it is very difficult for an application to support morethan one or two types, except with a very limited typewriter interface. JAMsupports about fifty different terminals and their graphics capabilities, andallows the application developer to add support for almost any terminal bysetting up a simple configuration file. Thus the CIS/DB application isaccessible from almost any terminal type.

Another feature of JAM that enhances the usability of applications developedwith it, is the support of mouse devices. In the CIS/DB application, it ispossible to create and execute a query without ever touching the keyboard.This feature is especially beneficial to users lacking strong typing skills.

Page 15: DATA BROWSER INTERFACE FOR THE COMPOSITE ...web.mit.edu/smadnick/www/wp2/1991-04.pdfChapter 2 - Architecture This chapter describes the architecture that was used to build the CIS

Chapter 3 - User Guide

This chapter presents a general overview of the functionality contained in theCIS Data Browser Client software and provides specific examples of how tocreate and execute a query.4 The examples given in this chapter use thePlacement Assistant System (PAS) schema. Figure 3-1 shows a graphicalrepresentation of the schema. The items in rectangles are the entities in thedatabase. The items in the diamonds are the relations on which entities canbe joined.

It should be noted that the CIS Data Browser supports any CIS/TK schemawithout reconfiguration. This is accomplished by dynamic menu definitionwhich is discussed in the previous chapter.

3.1 Overview

Figure 3-2 below shows the main screen that appears when the user executesthe CIS/DB Client program. The top form on the screen is the menu. Thebottom form is a status box that shows the currently defined query.

4 Appendix A documents how to configure and start both the Client andServer software. This section shows how to use the software once it is up andrunning.

Figure 3-1 The Placement Assistant System Global Schema

Page 16: DATA BROWSER INTERFACE FOR THE COMPOSITE ...web.mit.edu/smadnick/www/wp2/1991-04.pdfChapter 2 - Architecture This chapter describes the architecture that was used to build the CIS

Query: . .Attributes:

Constraints

End/nter Select option 9 Quit

Figure 3-2 CIS Data Browser Main Menu

The main menu contains eight options:e The List Attributes option allows the user to browse through the list

of attributes defined for each entity in the current database.e The Select Attributes option allows the user to define the list of

attributes that will be displayed in the query.e The Constrain Query option allows the user to enter constraints on

the list of data elements that will be displayed in the query.e The Execute Query option sends a query to the database and displays

the results.- The Open Query option reads in a query from a previously saved

ASCII file.5e The Save Query option saves the query in an ASCII file.* The New Query option clears the current query so that the user may

begin defining a new query.* The Quit option leaves the CIS/DB Client application.

5 Refer to Appendix C for documentation of the format of this file.

Main Menu

sElect attributesConstrain queryeXecute queryOpen querySave queryNew queryQuit

Page 17: DATA BROWSER INTERFACE FOR THE COMPOSITE ...web.mit.edu/smadnick/www/wp2/1991-04.pdfChapter 2 - Architecture This chapter describes the architecture that was used to build the CIS

Key Name Function PC VT-100Transmit Save screen and exit End Control-TExit Exit screen, don't save changes Esc Control-EDown Move cursor down a row Down arrw Down arrwUp Move cursor up a row Up arrow Up arrowPage Down Scroll down one screen PgDn Escape-UPage Up Scroll up one screen PgUp Escape-D

Figure 3-3 Important Keys

3.2 Tips on Using the Application

In order to effectively use the Client application, it is helpful to know how tonavigate around the application. This section provides some tips on usingeither the keyboard or the mouse in the Client application.

There are several standard key names that are used to identify keys. Themappings of these key names to physical keys on the keyboard vary fromterminal to terminal. The most important ones are documented in Figure 3-3for PC6 and VT-100 terminals. In the application, the most important keymappings for the current terminal and screen are displayed at the bottom ofthe screen.

There are several ways to select a menu option. The simplest method is touse the Up and Down keys to position the cursor over the desired option.Then press the Enter or Transmit key to select the option. You can also selectthe option by typing the first capitalized letter of the option. If your terminalhas a mouse, point to the option desired and click once to move the cursor tothe option. Click again to select the option.

To exit a menu, or any other screen, press the Exit key. The mapping of thiskey will vary from screen to screen, but the current mapping should always bedisplayed at the bottom of the screen. A word of caution: be careful whenusing the Exit key. If you are on a screen in which you have changed data(such as the Save Query screen), Exit undoes your changes and does notprocess the screen (i.e. it does not save the query on the Save Query screen).

To save data and process the data on a screen which has been edited, press theTransmit key. This is another key which varies between terminals but whose

6 The PC terminal refers to JTerm, a product of JYACC, Inc., New York, NY.Refer to the JTerm documentation for more information on how to configureand run JTerm.

Page 18: DATA BROWSER INTERFACE FOR THE COMPOSITE ...web.mit.edu/smadnick/www/wp2/1991-04.pdfChapter 2 - Architecture This chapter describes the architecture that was used to build the CIS

mapping is always be displayed on the bottom of the screen. For screenswhere there is only one field (such as the Save Query screen) pressing theEnter key will also save the data.

On some screens there is more data then can be displayed on one screen. Inthis case, arrows will appear at the bottom of the screen to indicate that thereis data below the current screen. Press the Page Down key to scroll to the nextscreen. Once you have scrolled past the first screen, arrows will appear at thetop of the screen to indicate that there is more data above the current screen.Press the Page Up key to scroll to the previous screen. If your terminalsupports a mouse, you can also point to the arrows at the top or bottom of thescreen and click once to scroll the screen.

At all times if your terminal supports a mouse, the key definitions shown atthe bottom of the screen can be used as a mouse driven keyboard. That is, toexecute the equivalent of a key shown at the bottom of the screen, point tothat key with the mouse and click once.

3.3 Defining a Query

Suppose you are a graduating Masters student at the MIT Sloan School ofManagement and are interested in finding employment in the automotiveindustry. The question that you desire to ask to the Placement AssistantSystem is the following:

"Find the interview dates of all companies from theautomotive industry that are recruiting at Sloan anddisplay the name and position of all Sloan alumni whowork for those companies."

There are two steps to defining this query: selecting the attributes that will bedisplayed in the query, and constraining the range of data that will bedisplayed in the query. Each of these steps is demonstrated below.

3.2.1 Selecting Attributes

The first step in defining the query described in the previous section is toselect the attributes to be displayed in the query. There are two entities thatcontain attributes that are of interest for this query, ALUMNI andCOMPANY. Figure 3-4 shows the screen that appears when selectingattributes from the ALUMNI entity.

To get to this screen, select the Select Attribute option from the Main Menu.Next, select the ALUMNI entity from the Select Entity menu. A list of all theattributes in the ALUMNI entity is now displayed. The arrows at the bottomof the attribute window indicate that there are more attributes than can bedisplayed on the screen at one time. To see the next page of attributes press

Page 19: DATA BROWSER INTERFACE FOR THE COMPOSITE ...web.mit.edu/smadnick/www/wp2/1991-04.pdfChapter 2 - Architecture This chapter describes the architecture that was used to build the CIS

Main Menu IList attributes |

Constrai. que Select EntityeXecute queryOpen query ........Save query COMPANY Select AttributesNew query FINANCE LIO ..Quit PORTFOLIO ..................

POSITION X FIRST-NAMEINDUSTRY X LAST-NAME

Query: DEGREE.Attributes: ADDRESS-i

'.T* RS. AI "A"t01.W,1' LA A ADDRESS-2-PAN.POS~ TO4 A ADDRESS-3

ZIP-CODEConstraints: POSITION-CODE

fl~fOSTY. INAM A~ti~tv XPOSITION

~dAccept $$ Select/Deselect iN Constrain 995 Next page PNOp Prey page $

Figure 3-4 Selecting Attributes

the Page Down key (or the comparable key on your terminal). Press the PageUp key to return to the first screen.

To select an attribute, move the cursor over the attribute and press the Enterkey. Pressing the Enter key again will deselect the attribute. To selectattributes using the mouse, point to the desired attribute and click once toposition the cursor on the attribute. Click again to select/deselect the attribute.For the query shown in Figure 3-4, the FIRST-NAME, LAST-NAME,POSITION, and COMPANY attributes have been selected. 7 In order topractice, select the attributes that are selected in Figure 3-4. To accept theselected attributes, press the Transmit key. If you make a mistake and wish toundo the changes you have made, press the Exit key.

To complete the query, the POSITION and DATE attributes need to be selectedfrom the COMPANY entity. To select these attributes, follow the steps abovebut select the COMPANY entity instead of ALUMNI on the Select Entitymenu.

After completing these tasks, press the Exit key to return to the main menu.You are now ready to set constraints.

7 TeCOMPANY attribute is on the next screen and thus can not be seen.

Page 20: DATA BROWSER INTERFACE FOR THE COMPOSITE ...web.mit.edu/smadnick/www/wp2/1991-04.pdfChapter 2 - Architecture This chapter describes the architecture that was used to build the CIS

3.2.2 Setting Constraints

Constraints limit the range of data that will be displayed for a given query.For the sample query there is only one constraint: we are only interested incompanies from the "Automotive" industry. Figure 3-5 shows how to setthis constraint. On the Main Menu, select the Set Constraint option. On theSelect Entity menu, select the INDUSTRY entity. On the Select Attributemenu, select the INDUSTRY-NAME attribute. Type "Automotive" in theconstraint field and press the Enter or Transmit key to accept the entry.

After completing these tasks, you are ready to execute the query. Press the Exitkey twice to return to the Main Menu.

3.4 Executing a Query

Executing a query is straightforward process. Select the Execute Query optionon the Main Menu. Figure 3-6 shows the screen that now appears. Note thatthe status box at the bottom of the screen now shows the definition of thequery discussed above. The box in the middle of the screen tells the user thatwe are waiting for the result to be returned. The user of CIS/DB must be

Main Menu

List attributessElect attrib.. :.... jf.|.|. Select Entity

eXecute queryOpen query ALUMNISave query COMPANY Select AttributeNew query FINANCEQuit PORTFOLIO I -D... .......

POSITIONS Constraint: iuti.i -..

Query :i~tiContrits

......... ...... .. ...... .......

i ft Accept M i Cancel

Figure 3-5 - Setting Constraints

Page 21: DATA BROWSER INTERFACE FOR THE COMPOSITE ...web.mit.edu/smadnick/www/wp2/1991-04.pdfChapter 2 - Architecture This chapter describes the architecture that was used to build the CIS

Main Menu

List attributessElect attributesConstrain query

Open querySave queryNew queryQuit

Executing query...Query.... : tf Waiting for result

Query :N i b.. i I-A |. ...............Attributes: ~~~~. ......................... . . . . . .

Const raints :

Figure 3-6 -Executing a Query

patient at this point. It takes approximately 3-5 minutes to process amoderately complex query. It might be tempting to think that the softwarehas is no longer executing but this is rarely the case.

Figure 3-7 shows the Query Result screen. Note that the arrows at the bottomof the screen indicate that there is more data than can be displayed on thecurrent screen. Use the Page Up and Page Down keys to browse through thedata. Press the Exit key when you are finished viewing the data.

Page 22: DATA BROWSER INTERFACE FOR THE COMPOSITE ...web.mit.edu/smadnick/www/wp2/1991-04.pdfChapter 2 - Architecture This chapter describes the architecture that was used to build the CIS

Query Results

(((ALUMNI FIRST-NAME) (ALUMNI LAST-NAME) (ALUMNI POSITION)(ALUMNI COMPANY) (COMPANY POSITION) (COMPANY DATE))

("David" "DeFrain" "Engineer" "GENERAL MOTORS CORP" "manager""February 9")("Mary" "Ritter" "Dir/Head of Dept" "GENERAL MOTORS CORP" "manager""February 9")("Calvin" "Nelson" "Manager" "GENERAL MOTORS CORP" "manager""February 9")("Samuel" "Lasry" "Analyst" "FORD MOTOR CO" "finance" "January 28")("Samuel" "Lasry" "Analyst" "FORD MOTOR CO" "corporate planning""January 28")("Samuel" "Lasry" "Analyst" "FORD MOTOR CO" "corporate planning""February 11")("Samuel" "Lasry" "Analyst" "FORD MOTOR CO" "operations research""February 18")("Maurice" "Maertens" "Manager" "FORD MOTOR CO" "finance""January 28")("Maurice" "Maertens" "Manager" "FORD MOTOR CO" "corporate planning"

Next page Ap Prev page Done

Figure 3-7 - The Query Result Screen

Page 23: DATA BROWSER INTERFACE FOR THE COMPOSITE ...web.mit.edu/smadnick/www/wp2/1991-04.pdfChapter 2 - Architecture This chapter describes the architecture that was used to build the CIS

Chapter 4 - Future Research

This chapter describes those areas in the CIS/TK and the CIS Data Browserwhere further enhancements can benefit the overall CIS system. The firstsection discusses CIS/TK and the second section discusses CIS/DB. Whileeach topic has been classified into a level of the four level CIS model (level 3for CIS/TK and level 4 for CIS/DB) some enhancements could be handled ateither level.

4.1 CISITK

Two shortcomings of CIS/TK are discussed in this section, the GlobalRetrieval Language (GRL) and the global schema structure. The globalschema is only an issue when there is an Application Query Processor (AQP)such as CIS/DB on top of CIS/TK. The GRL problems need to be resolvedregardless of the nature of the AQP.

4.1.1 Global Retrieval Language

The development of the CIS/DB exposed a major weakness in the CIS/TKGlobal Retrieval Language (GRL). The GRL does not allow a query thatinvolves joining one entity with more than two other entities. This conceptshall henceforth be referred to as "complex joins".

Figure 4-1 shows the global schema of the Placement Assistant System usedfor examples in Chapter 3. Let's take the sample query that was defined inSection 3-2 and make it more complicated. Recall that the query was:

"Find the interview dates of all companies from theautomotive industry that are recruiting at Sloan anddisplay the name and position of all Sloan alumni whowork for those companies."

Suppose that we are also interested in getting getting financial information(e.g. sales and profits for the previous year) about the companies. The querynow requires that the COMPANY entity be joined with the ALUMNI,FINANCE, and POSITION entities. However, this requires a join ofCOMPANY with three entities while the GRL only supports a join with two.Therefore, this query can not be processed using the current version of theGRL.

It should be fairly straightforward to extend the GRL to support such a query.One solution is to make the Join command take more than two argumentsi.e. any number of arguments.8

8 See WONG89, P. 58 for documentation of the current GRL syntax.

Page 24: DATA BROWSER INTERFACE FOR THE COMPOSITE ...web.mit.edu/smadnick/www/wp2/1991-04.pdfChapter 2 - Architecture This chapter describes the architecture that was used to build the CIS

Figure 4-1 The Placement Assistant System Global Schema

4.1.2 Schema Extension

The current structure of the global schema facilitates retrieval of data fromheterogeneous databases. At the same time, it does not facilitate thepresentation of the retrieved data to the user. For instance, there is noinformation about how wide each attribute field should be on the screen. Asa minimum two additional pieces of information should be added to theschema, field width (e.g. 8 characters) and field justification (e.g. right, left,center).

Additional information that might be added to make usability even betterwould be textual. For instance, an attribute label might be added (e.g."Company Name" rather than "NAME") in order to make retrieved dataeasier to read. In addition, there might be some informational text connectedto each attribute that identifies what the attribute is, and the sources fromwhich it is drawn. This data could be used by the Client to provide pop-uphelp for the user.

Page 25: DATA BROWSER INTERFACE FOR THE COMPOSITE ...web.mit.edu/smadnick/www/wp2/1991-04.pdfChapter 2 - Architecture This chapter describes the architecture that was used to build the CIS

4.2 CIS Data Browser

There are three areas in which further work could significantly improve theusability and flexibility of the CIS/DB software. They are:

" Ordering of entitiese Joining of entitiese Representation of entities

Each of these topics is discussed in a section below.

4.2.1 Order of Entities

In order for CIS/TK to process a query, it typically has to retrieve data from anumber of different databases. The order in which the different databases arequeried by CIS/TK can have a big impact on system performance.

As an example, let's look at the sample query in Section 4.1. It is obvious tous that the optimal strategy is to first find all of the alumni in the automotiveindustry and then find the companies that they work for. However, it ispossible to first find all of the companies (since there are no constraints on theCOMPANY entity this literally means all companies in the database) and thenmatch them against alumni who work in the automotive industry. Clearly,the second processing strategy accesses many more database elements and istherefore considerably slower.

In terms of the CIS software architecture, this problem must be viewed at twolevels. At the top level, how does CIS/DB order the entities when it submitsa GRL query to CIS/TK? At the next highest level, how does CIS/TK processthat query once it is received?

The CIS/DB software uses a simple algorithm to order entities when itsubmits a GRL query: if finds the first entity that has a constraint and only onejoin. For the sample query, this is the INDUSTRY entity. After the first entityis chosen, the order of the rest of the entities flows from the way in whichentities are joined (see the next section for more details). This algorithmworks perfectly for the sample query.

Suppose, however, that we are only interested in job positions where the titleis "corporate planning". This change adds a constraint to the COMPANYentity. Now CIS/DB might choose to process either the COMPANY or theINDUSTRY entity first depending on which entity happens to be first in theglobal schema. It is not intuitively obvious which entity should come first.However, the person asking the query might have some idea about whichorder makes sense. Therefore a feature might be added to CIS/DB to allowthe user to select the order of entities in a query.

Page 26: DATA BROWSER INTERFACE FOR THE COMPOSITE ...web.mit.edu/smadnick/www/wp2/1991-04.pdfChapter 2 - Architecture This chapter describes the architecture that was used to build the CIS

A more sophisticated algorithm might imbed intelligence in the applicationabout the underlying databases in order to determine the quickest way toprocess a query. Such intelligence might include which attributes are indexedand the number of records in each database. For example, if the COMPANYentity is indexed on company name but not recruiting position, and theINDUSTRY entity is indexed on industry name it would probably be faster toprocess the INDUSTRY entity first in the above example.

It is also possible to order the entities at the level of CIS/TK. CIS/TKprocesses GRL queries received from CIS/DB. The current implementationprocesses entities in the order in which they appear in a query. Thus it isassumed that the entity order has been optimized at a higher (i.e. AQP) level.A rule could be added to CIS/TK similar to the one in CIS/DB. That is,process the first entity which has a constraint. However, this wouldeliminate the capability of the user or the software to determine the order at ahigher level. Since the optimal entity order will vary from application toapplication, it is probably best determined at the application (AQP) level.

4.2.2 Entity oins

In order to process a query that involves multiple entities, those entities mustbe joined. In the CIS model, entities are joined on relations. The relations forthe Placement Assistant System are shown in the diamond shaped boxes inFigure 4-1.

The CIS/DB software automatically creates joins based on relationinformation in the global schema. The algorithm for joining entities looksthrough the list of relations for each entity and joins with all related entitiesthat are also in the query. For example, in the sample query, the INDUSTRYis automatically joined with the ALUMNI entity on the worksin relation.This works well when there is only one relationship between two entities andthere is no possibility for circular joins.

Now suppose that the INDUSTRY entity in Figure 4-1 were related to theCOMPANY entity on a relation called involvedin, in addition to beingrelated to the ALUMNI entity. Figure 4-2 shows the revised schema thatresults. It now becomes ambiguous whether INDUSTRY should be joinedwith COMPANY or ALUMNI in our sample query. In this example, thedefault behavior of CIS/DB would be to join INDUSTRY on whateverrelation happens to come first. If the worksin relation comes first,INDUSTRY would be joined with ALUMNI. If the involvedin relationcomes first, INDUSTRY would be joined with COMPANY.

27

Page 27: DATA BROWSER INTERFACE FOR THE COMPOSITE ...web.mit.edu/smadnick/www/wp2/1991-04.pdfChapter 2 - Architecture This chapter describes the architecture that was used to build the CIS

Figure 4-2 PAS Schema with New Relation involvedin

An improvement to the CIS/DB software would spot ambiguous joins likethe one in the preceding example, and prompt the user to resolve theambiguity. For example the software might simply ask the user which entityto join the INDUSTRY with, ALUMNI or COMPANY.

4.2.3 Entity Representation

Chapter 3 showed how easily someone can define and execute a query usingthe CIS/DB software. However, one shortcoming of the current system is thatit does not present the user with a visual image of the database with whichthey are working. In Chapter 3, it was assumed that the user understands thedatabase structure. However, this is frequently not the case.

A simple solution to this problem would be to develop a schematic drawingsimilar to figures 3-1, 4-1 and 4-2 and place the drawing by the terminal of allCIS/DB users. However, a better solution would be to display a visual imageof the database on the user's terminal. The user would then drive around theterminal using either cursor motion keys or a mouse to select entities and theattributes and constraints for the entity. In addition, the user could select theappropriate relations for joins in the same way, solving the problemdiscussed in the previous section.

A visual screen could probably be developed using JAM but further work isnecessary to determine the practicality of this feature. In addition, it is very

Page 28: DATA BROWSER INTERFACE FOR THE COMPOSITE ...web.mit.edu/smadnick/www/wp2/1991-04.pdfChapter 2 - Architecture This chapter describes the architecture that was used to build the CIS

unlikely that the visual screen could be created dynamically at run time basedon the global schema as is the case with the current menu system. Instead,the screen would have to be pre-configured for each schema. This wouldeliminate the capability of CIS/DB to interface with any schema withoutreconfiguration.

Page 29: DATA BROWSER INTERFACE FOR THE COMPOSITE ...web.mit.edu/smadnick/www/wp2/1991-04.pdfChapter 2 - Architecture This chapter describes the architecture that was used to build the CIS

Chapter 5 - Conclusion

This thesis has demonstrated that an easy to use and flexible interface forComposite Information Systems can be developed. However, much workremains to be done. The ultimate goal of the CIS interface should be to allowa neophyte user to pose any query about the database that comes to mind.While the CIS/DB software can process many of the queries that a user mightlike to submit, there are still shortcomings in the software.

Chapter 4 has identified many improvements that can be made. Someimprovements need to be made to CIS/TK, others to CIS/DB. Withcontinued improvements to both pieces of software, the combined CISsoftware will become easier to use, more flexible and can eventually movefrom a research prototype to a commercially viable application.

Page 30: DATA BROWSER INTERFACE FOR THE COMPOSITE ...web.mit.edu/smadnick/www/wp2/1991-04.pdfChapter 2 - Architecture This chapter describes the architecture that was used to build the CIS

Bibliography[MADN90] Madnick, Stuart E., Siegel, Michael, and Wang, Richard, "TheComposite Information System Laboratory (CISL) Project at MIT", MIT SloanSchool of Management, Cambridge, MA, Working Paper # CIS-90-04, May1990.

[WONG89] Wong, Toon Kin, "Data Connectivity for the CompositeInformation System Tool Kit", MIT Sloan School of Management,Cambridge, MA, Working Paper # CIS-89-03, June 1989.

[MART89] Martinez, Wilberto, "User Interface for the Composite InformationSystem", MIT Sloan School of Management, Cambridge, MA, Working Paper# CIS-89-07, June 1990.

Page 31: DATA BROWSER INTERFACE FOR THE COMPOSITE ...web.mit.edu/smadnick/www/wp2/1991-04.pdfChapter 2 - Architecture This chapter describes the architecture that was used to build the CIS

Appendix A - System ConfigurationA.1 The Client and Server Applications

There are a number of UNIX environment variables that must be set in orderfor the Client and Server programs to function properly. These variables aredocumented below:

CISDBDIR This variable is the name of the directory in which the CIS DataBrowser software is located. It is used by the Server to load theconfigurations for CIS/TK. See the next section for more details.

CISDBTMPDIR This variable is the name of the directory in which theServer and Client store temporary files and in which the namedpipe files that are used for communication between the Serverand CIS/TK are located. In addition, this environment variableis used to create the unique name for the queue through whichthe Server and Client communicate.

SMTERM

SMVARS

SMTEMP

This is the name of the terminal which is used by JAM todetermine what terminal configuration file to use. Terminalsthat have been tested so far are:

vt100 Digital Equipment Corp VT-100 or compatible

jcom JYACC Jterm running on a personal computercommunicating with the system through TCP/IP.

jcombw Same as jcom except with a monochrome monitor andcommunications via modem.

att615 AT&T 615 and compatible terminals. At the presenttime, there are bugs in the configuration file for thisterminal.

This variable provides the complete path to one of the two setupfiles that is used by JAM to configure the terminal.Configuration is based on the name of the terminal given by thevariable SMTERM. The normal value of this variable is"/usr/jam5/config/smvars.bin". The format of this file isdocumented in the JAM documentation.

This variable provides the complete path to the second setup filethat is used by JAM to configure the terminal. This fileoverrides the file named in SMVARS and is usually stored in

Page 32: DATA BROWSER INTERFACE FOR THE COMPOSITE ...web.mit.edu/smadnick/www/wp2/1991-04.pdfChapter 2 - Architecture This chapter describes the architecture that was used to build the CIS

the directory where the CIS/DB software is located. The formatof this file is documented in the JAM documentation.

A.2 CIS/TK

The CIS/TK software is loaded automatically as a sub-process of the Server.There are three files that are used to configure CIS/TK:

init.lsp

dbserver.cfg

This file contains the Lisp commands that are necessary to loadthe CIS/TK software. By changing the contents of the file, adifferent version of CIS/TK can be loaded. The file is loadedfrom the current working directory when the user starts theServer. If it is not found in the current working directory, it isloaded from the directory named by the CISDBDIR environmentvariable.

This file contains commands that are passed to CIS/TK duringthe load process. This file is passed as input into the Lispprocess. It can be used to answer configuration prompts that areasked by init.lsp (e.g. "Load communications server (y,n)?").This file can be used to quickly change the configuration ofCIS/TK. Lines that are blank or start with the pound character("#") are ignored. The file is loaded from the current workingdirectory when the user starts the Server. If it is not found in thecurrent working directory, it is loaded from the directory namedby the CISDBDIR environment variable. The file is onlynecessary when init.lsp contains code that prompts the user forconfiguration settings.

cistkcomm.lsp This file contains the lisp code that is used forcommunications between CIS/TK and CIS/DB. It is loadedautomatically into CIS/TK by the Server from the directorypointed to by the CISDBDIR environment variable.

A.3 Running the Software

There are three steps to running the CIS/DB software: set the environmentvariables, start the Server if it is not already running, and start a Client. Inaddition there is a queue utility program documented below.

A.3.1 Sample Environment Variables

The environment variables necessary to run CIS/DB have been documentedabove. Below are some sample settings:

CISDBDIR=/usr/cistk/databrowser

Page 33: DATA BROWSER INTERFACE FOR THE COMPOSITE ...web.mit.edu/smadnick/www/wp2/1991-04.pdfChapter 2 - Architecture This chapter describes the architecture that was used to build the CIS

CISDBTMPDIR=/usr/cistk/databrowser/temp

SMTERM=vt100

SMVARS=/usr/jam5/config/smvars.bin

SMSETUP=/usr/cistk/databrowser/smsetup.bin

A.3.2 Server Software

The Server software needs to be run only if it is not already in memory. It canbe run in the foreground or background. Running it in the foregroundmeans the the terminal on which it is run can not be used for anything else.Running the Server this way has the advantage of displaying all interactionbetween the Server and CIS/TK on the screen. To run in the foreground type:"dbserver". Running in the background has the advantage that the terminalcan also be used to run a client. However, this means that the CIS/TKinteraction can not be viewed on the terminal. To run in the backgroundtype: "dbserver > termfilename &" where termfilename is the name of a fileto which all terminal output should be directed. To terminate execution ofthe software, type "Control-c" at the terminal on which the Server wasstarted. This should only be done if you are sure that there are no clientprocesses running.

Whenever you try to start the Server, it checks to see if the message queuethat it uses for communications already exists. If the queue does exist, itassumes that a Server is already running and terminates. In most cases, thesoftware is in fact running. However, in some cases the queue may existwhen the Server is not in fact running. The queue utility programdocumented below can correct this problem.

A.3.3 Client Software

The Client software can only be run once the Server is already running in thesystem. There are two versions of this software, one that contains the basicsoftware, and another that also contains the JAM software that allowsreconfiguration of the screens associated with the software. The syntax is"dbclient mainmenu.scr" for the former, and "dbclientjx mainmenu.scr"for the latter. Chapter 3 documents how to use the Client once it is running.

A.3.4 Queue Utility Program

The queue utility program can be used to maintain the message queue. Thereare two functions contained in it: kill the message queue and empty themessage queue.

Page 34: DATA BROWSER INTERFACE FOR THE COMPOSITE ...web.mit.edu/smadnick/www/wp2/1991-04.pdfChapter 2 - Architecture This chapter describes the architecture that was used to build the CIS

Usually the Server program kills the message queue when it terminates.However, sometimes it is unable to kill the queue. In this case, if you try tostart the Server, you will get the message that the Server is already runningeven though it isn't. If you get this message and are sure that the Server isnot running, you can kill the queue by typing "qutil -k". To be sure that theServer is not running type the command "ps -ef I grep dbserver". If a processnamed "dbserver" shows up the Server is still running.

Usually every message that is put on the queue is read immediately by theprocess to which the message is addressed. However, if a Client process isterminated and the Server process subsequently sends a message to it (e.g. ifthe Client terminates while a query is being processed and the results are thensent back to it) the message will stay in the queue indefinitely. If this happensmany times, the message queue will eventually fill up with unread messagesand cease to function. If you believe that this problem exists type "qutil -c" toremove all unread messages from the queue.

Page 35: DATA BROWSER INTERFACE FOR THE COMPOSITE ...web.mit.edu/smadnick/www/wp2/1991-04.pdfChapter 2 - Architecture This chapter describes the architecture that was used to build the CIS

Appendix B - Source Code FilesThe sections that follow document the files the make up the CIS/DB software.The files are arranged into sections by type of file. Each section contains atable with a brief description of what the file does and then lists the actualcontents of the files.

B.1 "c" Files

There are three types of "c" files documented in this section, "c" source codefiles (*.c), "c" include files (*.h) and "c" make files.

B.1.1 Summary of Filesclienthook.c Contains the functions that are called from JAM menus.

These include functions to define, load and save queries.clientinit.c Contains the initialization functions for dbclient that

connect to the message queue for communications withdbserver and download the schema from dbserver.

dbserver.c The main program for dbserver. Runs an endless loopthat processes requests from clients.

funclist.c Definitions of functions that are called from JAMmenus. This file was delivered with the JAM softwareand was modified for the dbclient application.

futil.c File utility program that initializes directory variablesand creates temporary file names for dbclient anddbserver.

jmain.c The main dblclient program. Delievered with the JAMsoftware and modified to do initializations necessary fordbclient application.

jxmain.c The main dblclientjx program. Delievered with the JAMsoftware and modified to do initializations necessary fordbclientjx application.

lispcomm.c Contains functions that handle communications fordbserver with CIS/TK software.

query.c Contains the functions that are used by dbclient to turn aquery into GRL, submit the query, and display theresults.

queue.c Contains the functions used by both dbserver anddbclient to communicate through message queues.

qutil.c Queue utility program.schema.c Contains functions used by dbclient to search through

the global schema and find entities and attributes giventheir names.

Page 36: DATA BROWSER INTERFACE FOR THE COMPOSITE ...web.mit.edu/smadnick/www/wp2/1991-04.pdfChapter 2 - Architecture This chapter describes the architecture that was used to build the CIS

global.h Contains declarations of data structures used for queuemessages and the directory variables used for writingtemporary files.

schema.h Contains declarations of data structures used by dbclientto store a copy of the global schema and process queries.

static.h Contains declaration of static variables used by dblient.makefile Contains the instructions to make the dbserver and qutil

programs from "c" source files.

jmake Contains the instructions to make the dbclient andL __ _ dbclientjx programs from "c" source files.

Page 37: DATA BROWSER INTERFACE FOR THE COMPOSITE ...web.mit.edu/smadnick/www/wp2/1991-04.pdfChapter 2 - Architecture This chapter describes the architecture that was used to build the CIS

B.1.2 Listing of Files

clienthook.c

clienthook.c - program contains client hook functions

Written by: Tom ParkerDate: April 1991

#include <stdio.h>#include <errno.h>/* the following is mysteriously missing from errno.h */extern char *syserrlist [];#include '"global. h"#include "schema.h"#include "static.h"

/* global pointer to the current working entity */entity *curent;/* global pointer to the current working attribute */attribute *curatt;/* global variable that controls the query name */char queryfname(33];

putents - Prototyped screen entry hook function to fill theentity menu screen with entity names on entry to the screen.

inputnothing

returns0

int putents(){int entnum;entity *curent;

for(entnum=O;entnum<schema.numents;){curent = &schema.ents[entnum];/* increment the counter here since JAM arrays start at 1 */entnum++;/* put the name of the entity in the menufield */sm_o-putfield(1,entnumcurent->name);

}sm shrink to fito;

return (0) ;

/********************************************************************putatts() - screen entry hook function to fill the attibute selectionmenufor the selected entitity. Also saves the name of the current entityin the global pointer "curent".

Page 38: DATA BROWSER INTERFACE FOR THE COMPOSITE ...web.mit.edu/smadnick/www/wp2/1991-04.pdfChapter 2 - Architecture This chapter describes the architecture that was used to build the CIS

inputsflag - 1 if checklist (i.e. need to select checklist), 0 otherwisescreenname - the name of the screen to open in JAM format

returns0 if successful, -1 otherwise

int putatts (flag, screenname)int flag;char *screenname;

int attnum, groupnum;char *groupname;attribute *curatt;char entselname[MAXENTLENGTH];

/* find out what entity was chosen */smgetfield(entselname, sm_getcurno ();

/* initialize the pointer to the selected entity *//* return an error if we can't find the entity */if ((curent = (entity *) findent(entselname)) == NULL) return(-1);

/* open the window */sm jwindow (screenname);

/* if it is a checklist, get the name of the current group */if (flag)groupname = (char *) sm_ftog(l,&groupnum);

/* put the attributes for the selected entity in the window */for (attnum=0; attnum<curent->numatts;)

/* set current attribute */curatt = &curent->atts[attnum];/* increment attnum here since JAM arrays start a 1, not 0 */attnum++;/* put the name of the attribute in the menufield */sm_o_putfield(1, attnum, curatt->name);/* select those that have been selected */if (curatt->isselected && flag) smselect(groupnameattnum);

/* shrink the window to fit the number of attributes */sm shrink to fito;/* home the cursor */sm home(;

return (0) ;

saveatts() - This group validation hook function saves the list ofattributes that have been selected and then closes down the screen.

inputsname - the name of the groupcontext - context under which this function was called

Page 39: DATA BROWSER INTERFACE FOR THE COMPOSITE ...web.mit.edu/smadnick/www/wp2/1991-04.pdfChapter 2 - Architecture This chapter describes the architecture that was used to build the CIS

returns0 if successful, -1 otherwise

int saveatts (groupnamecontext)char *groupname;int context; /* not used */{int attnum;attribute *curatt;

if (curent == NULL) return(-1);

/* put the attributes for the selected entity in the window */for (attnum=O; attnum<curent->numatts;)

/* set current attribute */curatt = &curent->atts[attnum];/* increment attnum here since JAM arrays start a 1, not 0 */attnum++;/* select those that have been selected */curatt->isselected = (char ) sm isselected(groupname,attnum);

/* close the current window */sm close-windowo;

/* display the newly selected attributes */dispqueryo;

return (0);}

/ *********************************************************setscope() - Field validation hook function called to setthe scope of the query for an individual field. Also savesthe name of the current attribute for use by the fieldvalidation function.

inputsscreenname - the name of the screen on which to get input

returns0 if successful, -1 if fails

int setscope (screenname)char *screenname;{char attselname[MAXATTLENGTH];int attnum;

/* get the current field */smgetfield (attselname, smgetcurno ();

/* find the attribute */for (attnum = 0;

(strcmp (curent->atts [attnum] .name, attselname) != 0) &&(attnum < curent->numatts);

Page 40: DATA BROWSER INTERFACE FOR THE COMPOSITE ...web.mit.edu/smadnick/www/wp2/1991-04.pdfChapter 2 - Architecture This chapter describes the architecture that was used to build the CIS

attnum++)

/* if it is not in the list return an error */if (attnum == curent->numatts) return(1);/* otherwise save the attribute name */curatt = &curent->atts(attnum];

/* open named screen 1 row below the cursor */sm r at cur(screenname);

/* fill it with the contents of the field */smputfield (1, curatt->scope);

return (0);

/ ***********************************************************savescope() - This field hook function saves the scope conditionentered by the user for the current attribute. It checks to makesure that quotes are paired as a validation. If the field validatesthe window is closed and the data is saved. Otherwise the user isgiven an error message and returned to the screen.

inputfnum - the field numbercontents - the fields contentsarraynum - number of the field in an array (always 1)context - context of the call

returns0 if successful,-1 otherwise

int savescope (fnum, contents, arraynum, context)int fnum; /* not used */char *contents;int arraynum,context; /*not used */{

int len, i,numquote = 0;char test[10];

len = strlen(contents);

/* count number of quotes */for(i=0;i<len;i++)

if (contents(i] ==f'){if (numquote == 1) numquote = 0;else numquote = 1;

}

/* test to make sure that number of quotes is evenif (numquote)

{/* send an error message */sm emsg("Mismatched quotes. Please make sure quotes are

matched.");/* return */return (-1) ;

Page 41: DATA BROWSER INTERFACE FOR THE COMPOSITE ...web.mit.edu/smadnick/www/wp2/1991-04.pdfChapter 2 - Architecture This chapter describes the architecture that was used to build the CIS

/* save the contents */strcpy(curatt->scopecontents);

/* close the window */sm close-window();

/* display the newly set scope */dispqueryo;

return (0) ;}

/ ****************************************************************

savequery() - Function to save the formulationfor a query in an ASCII file.

the format for the file is (one line for each attribute):<entity name> <attributename> <isselected> <scope-condition>

inputoutfile - pointer to the output file

returnsnothing

savequery (out file)FILE *outfile;

entity *curent;attribute *curatt;int entnumattnum;

/* loop through all entities */for (entnum=O; entnum<schema . numents; entnum++)

{curent = &schema.ents[entnum];

/* loop through all attributes from the entity */for (attnum=O; attnum<curent->numatts; attnum++)

curatt = &curent->atts[attnum];/* if there is a scope condition, put out the attribute */if (curatt->isselected 1| (curatt->scope[O] != 0))

fprintf(outfile,"%s %s %d %s\n",curent->name, curatt->name,curatt->isselectedcuratt->scope);

}

return;

/****************************************************************loadquery() - Function to load the formulationfor a query from an ASCII file saved by savequery().

the format for the file is (one line for each attribute):<entityname> <attribute-name> <isselected> <scope condition>

42

Page 42: DATA BROWSER INTERFACE FOR THE COMPOSITE ...web.mit.edu/smadnick/www/wp2/1991-04.pdfChapter 2 - Architecture This chapter describes the architecture that was used to build the CIS

inputinfile - a pointer to the file to load in from

returnsnothing

loadquery(infile)FILE *infile;

entity *curent;attribute *curatt;char *attname,*entname;char inline[200], message[80];

/* clear the existing query */closequery(1);

/* read in the new query */while (fgets(inline,sizeof(inline),infile) ! NULL)

/* replace the carriage return with NULL */inline[strlen(inline)-1] = 0;entname = (char *) strtok(inline," ");/* find the entity */curent = (entity *) findent(entname);/* find the attribute */if (curent != NULL)

attname = (char *) strtok(NULL," ");curatt = (attribute *) findatt(curentattname);

}/* if the entity or attribute not found print errorif ((curent == NULL) || (curatt == NULL))

strcpy(message,"Error, can't find attribute: ");strcat(message,entname);strcat (message, "1. t) ;strcat(message, attname);sm emsg (message);

/* otherwise load it up */else

curatt->isselected = (char ) atoi(strtok(NULL," "));strcpy(curatt->scope, (char *) strtok(NULL,""il));

return;

/**************************************************************fileprompt() - This jyacc control function brings up a JYACC screento prompt the user for a file name. The default directory is thecurrent working directory.

input

Page 43: DATA BROWSER INTERFACE FOR THE COMPOSITE ...web.mit.edu/smadnick/www/wp2/1991-04.pdfChapter 2 - Architecture This chapter describes the architecture that was used to build the CIS

screenname

returns0

int fileprompt (screenname){

/* open the screen */sm r at cur(screenname);/* put the name of the file in it */sm put field (1, queryfname);/* put the cursor to the end of the name */smof f_gofield(1,strlen(queryfname));

/ **************************************************************

filevalid - This field validation checks to see if a file canbe opened and then calls the loadquery() or savequery() functionsbased on the mode.

inputmode- 0 for output, 1 for input

returns0 if successful, -1 if not successful

int filevalid(mode)int mode;

FILE *fileptr;char *fopenmode;char emess[200];

smget f ield (queryfname, 1);

.if (mode == 0) fopenmode ="w";else fopenmode = "r";fileptr = fopen (queryfname, fopenmode);if (fileptr == NULL)

{strcpy(emess, "Unable to open file: ");strcat (emess, sys errlist [errno]);smemsg(emess);/* put the cursor to the end of the name */sm offgofield(1, strlen (queryfname));return (-1) ;

if (mode == 0) savequery(fileptr);else loadquery(fileptr);

/* close the file */fclose (fileptr);

/* close the file prompt window */sm close-window();

dispqueryo;

44

Page 44: DATA BROWSER INTERFACE FOR THE COMPOSITE ...web.mit.edu/smadnick/www/wp2/1991-04.pdfChapter 2 - Architecture This chapter describes the architecture that was used to build the CIS

return (0);}/ ****************************************************************

closequery() - Control hook function to close a query. Alsocalled by load query in order to close before loading new

inputflag - 0 called from menu, 1 called from other function,

3 called from appinitreturns0

int closequery (flag)int flag;{entity *curent;attribute *curatt;int entnum, attnum;

for (entnum=O; entnum<schema .numents; entnum++)

curent = &schema.ents[entnum];for (attnum=0; attnum<curent->numatts; attnum++)

curatt = &curent->atts(attnum];/* reset the selected field */curatt->isselected = 0;/* reset the scope field */curatt->scope[0] = 0;

if (flag == 0)

/* change the default file name */getcwd (queryfname, sizeof (queryfname));strcat (queryfname, "/untitled");/* display the new query */dispqueryo;

else if (flag ==3)

/* change the default file name */getcwd (queryfname, sizeof (queryfname));strcat (queryfname, "/untitled");

return (0) ;

/ ***************************************************************appinit() - This function initializes the application by initializingthe schema structure (call to closequeryo) and displaying thequery window

inputdispwindow - the name of the query display window

return0

Page 45: DATA BROWSER INTERFACE FOR THE COMPOSITE ...web.mit.edu/smadnick/www/wp2/1991-04.pdfChapter 2 - Architecture This chapter describes the architecture that was used to build the CIS

appinit (dispwindow)char *dispwindow;{

closequery (3);/*open the query window as a sib */smjwindow (dispwindow);dispqueryo;sm wselect (0);return(0);

}

/ *****************************************************************

dispquery() - function displays the query in the query displaywindow currently harwired to "dispquery.scr"

inputnone

returnsnothing

dispquery ()

int alinenum=O, clinenum=O;int attfield=2; /* hardwired attribute field number */int confield=5; /* hardwired constraint field number */int entnum, attnum;char attline[79],conline(79];

attline[0] = 0;conline(O] = 0;

/* select the window */sm_n_wselect("dispquery.scr");

/* write out the name of the file */smput field (1, queryfname);

/* clear out the arrays */smclear-array(attfield);smclear array (confield);

/* write out the names of the selected attributes and cons'for (entnum=O;entnum<schema.numents;entnum++)

{curent=&schema.ents [entnum];for (attnum=0; attnum<curent->numatts; attnum++){curatt=&curent->atts (attnum];if (curatt->isselected)

{/* check to see if it can fit on li,if ((strlen(attline)+1+strlen(cure

1+strlen (curatt->name) ) >78){smputfield(attfield+alinenuattline [0 =0;alinenum++;

Page 46: DATA BROWSER INTERFACE FOR THE COMPOSITE ...web.mit.edu/smadnick/www/wp2/1991-04.pdfChapter 2 - Architecture This chapter describes the architecture that was used to build the CIS

)

Sti-

S~ t( COZ2re c

a z

stz~O O ~ a t )u;

ca (c 0 122~

,3 t at

(c - C n le). -Ze,,

I t yf? In le).

"Z e 'r t

pu

-Is

sr o t()

Z

Page 47: DATA BROWSER INTERFACE FOR THE COMPOSITE ...web.mit.edu/smadnick/www/wp2/1991-04.pdfChapter 2 - Architecture This chapter describes the architecture that was used to build the CIS

clientinit.c/ **********************************************************clientinit.c - client initialization program for cis front endDeveloped by: Tom ParkerDate: April 1991

#include <stdio.h>#include "global.h"#include "schema.h"#include "static.h"int qnumber; /* number of the message queue */

int initclient(garbagestring)char *garbagestring; /* not used */

qmessage inmessage, outmessage;char query[200]; /* the outgoing query */char result[200]; /* the incoming result */FILE *queryfile; /* file pointer to both the query and resultfiles */

/* initialize global directory variable */initdirs (&cisdbdir, &cisdbtmpdir);

/* initialize message headers */outmessage.to = 1;outmessage.from = getpid();inmessage.to = outmessage.from;

/* open up the message queue *//* flag of 1 means this is the server process */qnumber = qopen(1);

/* send singon message */strcpy (outmessage. command, "SIGNON");printf ("\nSigning on\n");qput (qnumber, &outmessage);printf("\nWaiting for reply\n");qget (qnumber, &inmessage);/* check for error and read result */if (strcmp ("ERROR", inmessage. command) == 0)

printf("\nUnable to get global schema. Program terminated.\n");exit (1);

getschema (inmessage.text, &schema);

return (0) ;

/****************************************************************getschema -function reads schema from file created by cisdbserver

and stores the data in a c structures defined in thefile global.h

inputsschema - pointer to the top of the schema

Page 48: DATA BROWSER INTERFACE FOR THE COMPOSITE ...web.mit.edu/smadnick/www/wp2/1991-04.pdfChapter 2 - Architecture This chapter describes the architecture that was used to build the CIS

returnsschema - the new value of pointer

getschema(fname,schema)char *fname;struct schema *schema;

FILE *schfile;char inline[MAX ATT LENGTH];int entnum, attnum, relnum;entity *curent;attribute *curatt;relation *currel;

schfile = fopen(fname,"r");

fgets(inline, sizeof(inline),schfile);schema->numents = atoi(inline);

/* allocate memory for entities */schema->ents = (entity *) calloc(schema->numents,sizeof(entity));for (entnum=0; entnum < schema->numents; entnum++)

curent = &schema->ents(entnum];/* read the entity name */fgets(curent->name,sizeof(curent->name),schfile);/* remove the newline character */curent->name[strlen(curent->name)-1] = 0;

/* read the number of attributes for this entity */fgets(inline,sizeof(inline),schfile);curent->numatts = atoi(inline);

/* allocate memory for the attributes for this entity*/curent->atts = (attribute *) calloc(curent-

>numatts, sizeof(attribute));

/* read in the attributes for this entity */for (attnum=O; attnum < curent->numatts; attnum++){/* initialize the current attribute pointer */curatt = &curent->atts[attnum];/* read in the attribute name */fgets(curatt->name,sizeof(curatt->name),schfile);/* remove the newline character */curatt->name[strlen(curatt->name)-1) = 0;

}

/* read the number of relations for this entity */fgets(inlinesizeof(inline),schfile);curent->numrels = atoi(inline);

/* allocate memory for the relations for this entity*/curent->rels = (relation *) calloc(curent-

>numrels,sizeof(relation));

/* read in the relations for this entity */for(relnum=O;relnum < curent->numrels;relnum++)

Page 49: DATA BROWSER INTERFACE FOR THE COMPOSITE ...web.mit.edu/smadnick/www/wp2/1991-04.pdfChapter 2 - Architecture This chapter describes the architecture that was used to build the CIS

/* initialize the current attribute pointer */currel = &curent->rels[relnum];/* read in the relation name */fgets(currel->name, sizeof(currel->name),schfile);/* remove the newline character */currel->name(strlen(currel->name)-1] = 0;/* read in the name of the related entity *1fgets(currel->relent,sizeof(currel->relent),schfile);/* remove the newline character */currel->relent(strlen(currel->relent)-1] = 0;

}

fclose(schfile);unlink(fname);

return(0);}

Page 50: DATA BROWSER INTERFACE FOR THE COMPOSITE ...web.mit.edu/smadnick/www/wp2/1991-04.pdfChapter 2 - Architecture This chapter describes the architecture that was used to build the CIS

dbserver.c/ *************************************************dbserver.c - main server program for cis data browserDeveloped by: Tom ParkerDate: April, 1991

#include <stdio.h>#include <signal.h>#include "global.h"

#define TRUE 1

/* CIS Data Browser main directory and temp directory *//* the same variables are declared externally in "global.h" */char *cisdbdir, *cisdbtmpdir;

void *shutdown(;int qnumber = 0; /* number of the message queue */

int main()

qmessage inmessage, outmessage;

/* set up for shutdown signal handling */signal(SIGHUPshutdown);signal(SIGINTshutdown);signal(SIGKILLshutdown);

/* initialize directory variables */initdirs(&cisdbdir,&cisdbtmpdir);

/* open up the message queue *//* flag of 0 means this is the client process *//* this also tests to make sure the server is not already running */qnumber = qopen (0) ;

/* start lisp process */initcistko;

/* initialize the outgoing and incoming message queues */outmessage.from = 1;inmessage.to = 1;

while (TRUE) /* loop forever */{

/* get next message for server */printf("\nWaiting for query\n");qget (qnumber, &inmessage);/* pose the query */printf("\nPosing query:\n%s\n",inmessage.text);/* submit query */putquery(inmessage.command,inmessage.text,

outmessage.text);/* return result to the calling program */

strcpy (outmes sage . command, "RESULT ");

Page 51: DATA BROWSER INTERFACE FOR THE COMPOSITE ...web.mit.edu/smadnick/www/wp2/1991-04.pdfChapter 2 - Architecture This chapter describes the architecture that was used to build the CIS

outmessage.to = inmessage.from;printf("\nSending response: \n%s\n",outmessage.text);qput (qnumber, &outmessage);

/****************************************************************shutdown - graceful shutdown routine which cleans up*****************************************************************/

void *shutdown()

/* close the queue */if (qnumber != 0) qclose(qnumber);lispcloseo;exit(0);/* remove the pipe files */

}

Page 52: DATA BROWSER INTERFACE FOR THE COMPOSITE ...web.mit.edu/smadnick/www/wp2/1991-04.pdfChapter 2 - Architecture This chapter describes the architecture that was used to build the CIS

funclist.c/* static char id-string[] = "@(#)funclist.c 50.17 90/09/1318:23:18"; *// *************************************//* Copyright (C) 1986 - 1990

by/* JYACC, Incorporated/* New York, New York/* All Rights Reserved/* Printed in U.S.A. *//* Property of JYACC, Incorporated *// *************************************/

/ ***********************************************************Modified by: Tom ParkerDate: April 1991

Modified for use in the "cisclient" application

/*

NAME

funclist.c

DESCRIPTION

In order to attach your functions to JAM, you need to list themin one of the function lists. This file contains example functionlists along with functions that show the calling and returnsequences of the different types of functions you can havein JAM: screen, group, field, control string, scrolling, andprototyped functions.

Screen functions are specified on the screen window (usuallyaccessed by the F3 key). These may either entry or exitfunctions. They are called with two parameters, the screen name,and a flag indicating "why-called": KENTRY, KEXIT, and KEXPOSE.

Group functions are specified on the group attribute window(shift F6). These may be validation, entry or exit.They are called with the group name and a flag indicating"why-called": K ENTRY, K_EXIT, and further bits indicatingwhich key caused the event.

Field functions are specified on the field attacments window(F4, together with a menu selection). These may bevalidation, entry or exit. They are called withfour parameters. The first is the field number, the nextis the data from that field, the third is the occurrence number,and the last is a flag giving the MDT and VALIDED bits forthe field together with bits indicating which key causedthe event.

Control functions are specified in JAM control strings,either on the control string window (shift Fl) or in a

Page 53: DATA BROWSER INTERFACE FOR THE COMPOSITE ...web.mit.edu/smadnick/www/wp2/1991-04.pdfChapter 2 - Architecture This chapter describes the architecture that was used to build the CIS

field next to a JAM menu. They are passed a single parameterthis being a pointer to the name and the following text.

The prototype list is searched whenever the abovelists do not contain the requested function. Thereis no way to specify that ONLY the prototype list besearched. A function in the prototype list may begiven without a prototype; in this case it receivesa string consisting of the text FOLLOWING the name.

See the manual for information on prototyping.

Functions on ANY list may be prototyped, however itis probably more convenient to put all prototyped functionson the prototype list - this makes them available anywherein the application (screen entry, field validation, etc.).

Note that the functions herein actually do nothing(other than return), but they do serve as models upon which youcan base your own functions.

The function smdo uinstalls is called by jmain and jxmain toallow a place for users to install their functions. It must bein any funclist.c that is used or JAM and JXFORM cannot be linked.

*/

#include "smdefs.h"#include "smkeys.h"#include "smaltsc.h"

/*************** THE FOLLOWING FUNCTIONS ARE IN THIS MODULE

void sm do uinstalls PROTO((void));st'atic int sdummy PROTO((char *, int));static int gdummy PROTO((char *, int));static int fdummy PROTO((int, char *, int, int));static int cdummy PROTO((char *));

static int bel PROTO((void));static int flush PROTO((void));static int shrink PROTO((void));

/*

NAME

Function list -- List of user functions for JAM

DESCRIPTION

All functions to be called by JAM via control strings, fieldentry/exit, etc, must be listed in the following arraysof structures. This structure is defined in sminstfn.h.

The first member is the name of the function - as specified

Page 54: DATA BROWSER INTERFACE FOR THE COMPOSITE ...web.mit.edu/smadnick/www/wp2/1991-04.pdfChapter 2 - Architecture This chapter describes the architecture that was used to build the CIS

in the screen or JAM control string.

The next member is the address of the function. Followingthis the language (C, FORTRAN, etc.) is specified. Thevalue 0 specifies C (and JPL), other values are site-specific,depending on what alternate language support has been installed.

The next member ("intrnuse") is normally 0. Howevertwo bits are defined for special use. NODELETE (OxOl)is set to prohibit deletion of this function (by callingsminstall with a count of 0). This feature may be usedto mark certain functions permanent and allow othersto be installed or deleted in different parts of theapplication. All the "built-in" functions (e.g. jmkeys)are marked in this way.

The other flag, NOTINEDITOR (0x02), may be set to preventthe function from being called when in the screen editorportion of jxform. This might be set, for example, forfunctions that access a database, or perform some otherlengthy procedure.

The next member is used in special installations for specialpurposes and should normally be 0. The last member isused internally and should be set to 0.

See the file sminstfn.h, and the manual, for more details.

*/

/* declaration of screen functions */extern int putents();extern int doqueryo;extern int appinit();

/* list of screen (entry/exit) functions

static struct fnc data sfuncs[] =

{"sdummy", sdummy, 0, 0, 0, 0 },"putentso",putents,O,,O,0},"doqueryo",doquery,O,O,OO),,"appinit(s)",appinit,0,0,0,0}

static int scount = sizeof (sfuncs) / sizeof (struct fnc data);

/* declaration of group functions */extern int saveatts();

/* list of group (entry/exit/validation) functions */static struct fnc data gfuncs[] =

"gdummy", gdummy, 0, 0, 0, 0 },"saveatts",saveatts,0,0,0,0

};static int gcount = sizeof (gfuncs) / sizeof (struct fnc_data);

Page 55: DATA BROWSER INTERFACE FOR THE COMPOSITE ...web.mit.edu/smadnick/www/wp2/1991-04.pdfChapter 2 - Architecture This chapter describes the architecture that was used to build the CIS

/* declarations of field functions */extern int savescopeo;extern int putattso;extern int filevalid(-);

/* list of field (entry/exit/validation) functions */static struct fnc data ffuncs[] =

"fdummy", fdummy, 0, 0, 0, 0 1,"savescope",savescope,0,0,0,0),"putatts(is)",putatts,0,00,0},

{ "filevalid(i)",filevalid,0,0,0,0}};static int fcount = sizeof (ffuncs) / sizeof (struct fnc data);

/* declaration of control functions */extern int fileprompto;extern int closequeryo;

/* list of JAM control functionsstatic struct fnc data cfuncs[] =

{{"cdummy", cdummy, 0, 0, 0, 0 },{ "fileprompt(s)",fileprompt,O,0,O,0},{ "closequery(i)",closequery,0,0,0,0}

};static int ccount = sizeof (cfuncs) / sizeof (struct fnc data);

/* prototypes for prototyped functions */extern int setscopeo;

/* list of prototyped functionsstatic struct fnc data pfuncs[] =

"setscope(s)", setscope,0,0,0,0),"sm flusho", flush, 0, 0, 0, 0 }f"sm bel()", bel, 0, 0, 0, 0 1,"sm_e chgattr(s,i,i)", sm_echg-attr, 0, 0, 0, 0 },"sim iachg(s,i,i)", smi_achg, 0, 0, 0, 0 },"sm_getcurnoo", si_getcurno, 0, 0, 0, 0 1,"sm igofield(s,i)", sm_igofield, 0, 0, 0, 0 },"sm occurnoo", smoccurno, 0, 0, 0, o0 ,"smn n_aprotect(si) ", smnaprotect, 0, 0, 0, 0 },"sm_n aunprotect(si)", sm_naunprotect,0, 0, 0, 0 },"sm_s_val()", sm_s_val, 0, 0, 0, 0 },"smjwindow(s)", smjwindow, 0, 0, 0, 0 I,"sm jform(s)", sm jform, 0, 0, 0, 0 1,

/* NOTE: remove the following to decrease code size by 3K *//* also remove the function shrink below

"shrinko", shrink, 0, 0, 0, 0 1};static int pcount = sizeof (pfuncs) / sizeof (struct fncdata);

/* list of JAM user defined scrolling methods/* The first is for file based scrolling, the second *//* for LDB based scrolling

Page 56: DATA BROWSER INTERFACE FOR THE COMPOSITE ...web.mit.edu/smadnick/www/wp2/1991-04.pdfChapter 2 - Architecture This chapter describes the architecture that was used to build the CIS

/* uncomment this and sm install (SCROLLFUNC) belowfor alternate scrolling methods

static struct fncdata ufuncs(] =

"sm_fbsc","sm ldb-sc",

sc_fb_sc,sc_ldbsc,

0, 0, 0, 0 },0, 0, 0, 0 }

static int ucount = sizeof (ufuncs) / sizeof (struct fnc data);*/

/ ***********************************************************************

*//* Do not remove this function or JAM and JXFORM will not link. *// ************************************************************************//*

NAME sm do uinstalls

SYNOPSISsm do uinstallso;

DESCRIPTION

Function to install user functions, signal handler, and otheruser options.

*/

voidsm do uinstalls()

/* install functions that exist in this module */

sminstall (SCREENFUNC,sminstall (GROUPFUNC,sminstall (FIELD_FUNC,sminstall (CONTROLFUNC,sm install (PROTO_FUNC,

sfuncs, &scount);gfuncs, &gcount);ffuncs, &fcount);cfuncs, &ccount);pfuncs, &pcount);

uncomment for alternate scrollingsminstall (SCROLLFUNC, ufuncs, &ucount);

/* additional installs may be placed here -/* sminstall (???, ???, &???);

/* signal handler can be installed here - *//* signal (???); */

}/ ************************************************************************/

/*

Page 57: DATA BROWSER INTERFACE FOR THE COMPOSITE ...web.mit.edu/smadnick/www/wp2/1991-04.pdfChapter 2 - Architecture This chapter describes the architecture that was used to build the CIS

NAME

sdummy -- a dummy screen (entry/exit) routine

SYNOPSIS

retcode = sdummy (screenname, whycalled)char *screen name;int whycalled;

DESCRIPTION

This is an empty screen function. The returned value isignored by JAM, and is present only to satisfy the definitionof the fnc data structure.

See smvalids.h for bits in the "whycalled" parameter.

RETURNS

0 ignored by JAM

static intsdummy (screenname, whycalled)char *screen name;int why_called;{

return (0);

/*

NAME

gdummy -- a dummy group (validation/entry/exit) routine

SYNOPSIS

retcode = gdummy (group_name, whycalled)char *group_name;int whycalled;

DESCRIPTION

This is an empty group function. The returned value isused by JAM only for validation functions. It should be0 for successful validation and -1 for unsucessful.

See smvalids.h for bits in the "why_called" parameter.

RETURNS

0 sucessful validation

Page 58: DATA BROWSER INTERFACE FOR THE COMPOSITE ...web.mit.edu/smadnick/www/wp2/1991-04.pdfChapter 2 - Architecture This chapter describes the architecture that was used to build the CIS

-1 error in validation

*/

static intgdummy (groupname, whycalled)char *group name;int whycalled;

return (0);}

/*

NAME

fdummy -- a dummy field (validation/entry/exit) routine

SYNOPSIS

retcode = fdummy (fieldnum, fielddata, item id, valmdt)int field num;char *field data;int item id,

val mdt;

DESCRIPTION

This is the shell of a field validation routine, which is calledto verify (i.e., validate) that the content of a field is correct.This particular routine always returns a value that indicatesthat the field's content is correct, so the net effect of thisroutine is an elaborate no-op.

RETURNS

0 Field's content is valid.1 Field's content is invalid, but don't move cursor to

this field if it isn't there.OTHER Field's content is invalid, and move the cursor to the

begining of this field.

*/

static intfdummy (fieldnum,fielddata,itemid,valmdt)int field num;char *field data;int item id;int val mdt;{

return (0);

/*

Page 59: DATA BROWSER INTERFACE FOR THE COMPOSITE ...web.mit.edu/smadnick/www/wp2/1991-04.pdfChapter 2 - Architecture This chapter describes the architecture that was used to build the CIS

NAME

cdummy -- a dummy control function

SYNOPSIS

key = cdummy (cfielddata)char *cfield data;int key;

DESCRIPTION

This type of function is called when JAM invokes a functionvia the caret (A) control field. The data passed to the functionis the contents of the control field (with the caret strippedoff).

RETURNS

Either a function key (e.g., PF1), which will cause JAM toact as if the user had just press that key, or any other value,which returns JAM to sminputo. This function, for simplicity,always returns a 0.

static intcdummy (cfielddata)char *cfield data;{

return (0);

/*

NAME

bel -- a shell for sm bel

SYNOPSIS

ret code = bel 0;int ret code;

DESCRIPTION

A prototyped function must return a value since it couldbe used as a field validation function. Since the libraryfunction smbel has no return value, we call the presentfunction instead.

RETURNS

0

Page 60: DATA BROWSER INTERFACE FOR THE COMPOSITE ...web.mit.edu/smadnick/www/wp2/1991-04.pdfChapter 2 - Architecture This chapter describes the architecture that was used to build the CIS

static intbel ()

sm bel (;return (0);

/*

NAME

flush

IS

ret code =

int ret cod

-- a shell for sm flush

flush (;.e;

DESCRIPTION

A prototyped function must return a value since it couldbe used as a field validation function. Since the libraryfunction smflush has no return value, we call the presentfunction instead.

RETURNS

0

*/

static intflush ()

sm flush (;return (0);

/*

NAME

shrink -- a shell for sm shrink to fit

SYNOPSIS

ret code = shrink (;int ret code;

SYNOPS

Page 61: DATA BROWSER INTERFACE FOR THE COMPOSITE ...web.mit.edu/smadnick/www/wp2/1991-04.pdfChapter 2 - Architecture This chapter describes the architecture that was used to build the CIS

DESCRIPTION

A prototyped function must return a value since it couldbe used as a field validation function. Since the libraryfunction smnshrinktofit has no return value, we call the presentfunction instead.

NOTE: smshrinktofit adds appoximately 3K to the code size.If you are not using this feature, you should remove thisroutine and the entry in the prototype function list above.

RETURNS

0

*/

static intshrink (){

smshrink to fit (;return (0);

Page 62: DATA BROWSER INTERFACE FOR THE COMPOSITE ...web.mit.edu/smadnick/www/wp2/1991-04.pdfChapter 2 - Architecture This chapter describes the architecture that was used to build the CIS

futil.c/ ****************************************************************futil.c - file utility programWritten by: Tom ParkerDate: April, 1991

current functions:gettempname(char *buffer,char *dir);

#include <stdio.h>#define CAN READ 04#define CANWRITE 02

gettempname - function returns a temporary file name

inputbuffer - the character buffer that will contain the temp file namedir - the directory in which the file will exist

returnsbuffer - the name of the file

gettempname (buffer, dir)char *buffer;char *dir;

char *temparea;

/* get the temporary nametemparea = tempnam(dir, NULL);/* copy the string to the buffer */strcpy (buffer, temparea);/* free up the memory used to create the file name */free (temparea);

return;}

initdirs - function to initialize global directory variables and checkto make sure they exist and that this process can:

read from the main dir;read and write from the temp dir;

inputs-maindir - the character pointer for main directorytmpdir - the character pointer for the temp directory

returnsmaindirtmpdir

initdirs (maindir, tmpdir)char **maindir, **tmpdir;

Page 63: DATA BROWSER INTERFACE FOR THE COMPOSITE ...web.mit.edu/smadnick/www/wp2/1991-04.pdfChapter 2 - Architecture This chapter describes the architecture that was used to build the CIS

/* initialize directory variables, check for null values */if ((*maindir = getenv("CISDBDIR")) == NULL)

{printf("Environment variable CISDBDIR not initialized...%s\n\n",

" Program terminated.");exit(1);

if (access(*maindir,CANREAD) != 0){printf("User does not have read access to: %s\nProgram

terminated. \n\n",*maindir);

exit(1);

if ((*tmpdir = getenv("CISDBTMPDIR")) == NULL)

printf("Environment variable CISDBTMPDIR notinitialized...%s\n\n",

" Program terminated.");exit(1);

}if (access(*tmpdir,CANREAD && CANWRITE) != 0)

{printf("User does not have read and write access to: %s\n%s\n\n",

*tmpdir, "Program terminated.");exit(1);

return;

Page 64: DATA BROWSER INTERFACE FOR THE COMPOSITE ...web.mit.edu/smadnick/www/wp2/1991-04.pdfChapter 2 - Architecture This chapter describes the architecture that was used to build the CIS

jmain.c/* static char id string(] = "@(#)jmain.c 50.26 90/08/22 16:37:26"; *// *************************************//* Copyright (C) 1986 - 1990

by/* JYACC, Incorporated/* New York, New York/* All Rights Reserved *//* Printed in U.S.A. *//* Property of JYACC, Incorporated *// *************************************/

#include "smdefs.h"#include "smerror.h"#include "smcmprs.h"

/* THE FOLLOWING FUNCTIONS ARE IN THIS MODULE */

int main PROTO((int, char **));static int initialize PROTO((void));static void startup PROTO((int, char **));static void cleanup PROTO((void));

/* name of first screen to bedisplayed */

static char *start screen name;

intmain (argc, argv)int argc;char **argv;{

int ret status;

/* Place code to be executed before any JAM initializations here*//* Code calls the server and initializes the schema structure */initclient (;

ret status = initializeo;

if (ret status == RETSUCCESS){

/* Place all code to be executed before *//* first screen is brought up, here

/* Call function in funclist toinstall user functions */

sm do uinstallso;

/* to hard code the name of the first screen, *//* "TOPSCREEN", replace the following line with *//* start screen name = "TOPSCREEN" */

start screen name = 0;

Page 65: DATA BROWSER INTERFACE FOR THE COMPOSITE ...web.mit.edu/smadnick/www/wp2/1991-04.pdfChapter 2 - Architecture This chapter describes the architecture that was used to build the CIS

start-up (argc, argv);}

/* Place your clean up code needed before JAM cleans up, here */

clean-up (;

/* Place all your closing code here */

exit (ret status);

}

/ ***********************************************************************

/* Modifying the rest of this file is recommended for advanced usersonly *// ***********************************************************************

/ ***********************************************************************

/* OPTIONAL SUBSYSTEMS:*//**//* To quickly add or delete several optional subsystems the following*//* macros are provided.*//* To save memory, they are by default set to 0 (not installed)*//* Setting any or all of them to 1 will cause that subsystem to be*//* installed, and consequentially take more memory.*//* Note that they can also be changed by compiler directives.*//* See the Programmer's Guide for additional information.*// ***********************************************************************

#ifndef SOFTKEYS#define SOFTKEYS 0 /* soft keys (keysets) */#endif

#ifndef ALT SCROLLING#define ALTSCROLLING 0 /* user defined scrolling */#endif

#ifndef MEMORY SCREENS#define MEMORYSCREENS 0 /* make screens memory resident */#endif

#ifndef MEMORY KEYSETS#define MEMORYKEYSETS 0 /* make keysets memory resident */#endif

Page 66: DATA BROWSER INTERFACE FOR THE COMPOSITE ...web.mit.edu/smadnick/www/wp2/1991-04.pdfChapter 2 - Architecture This chapter describes the architecture that was used to build the CIS

#ifndef BLOCK MODE#define BLOCKMODE 0 /* block mode terminals */#endif

#ifndef JTERM COMPRESSION#define JTERMCOMPRESSION 0 /* JTERM with data compression */#endif

/ ***********************************************************************

/* GLOBAL VARIABLES USED IN FOLLOWING PROCEDURES*// ***********************************************************************

#if !MEMORYSCREENS/* library descriptor of diskresident screen library */

static int jam lib;#endif

#if SOFTKEYS & !MEMORY KEYSETS/* library descriptor of diskresident softkey library

static int jamsklib;#endif

**/

/* INITIALIZE:*/

**/

static intinitialize ()

#if !MEMORY SCREENS | (SOFTKEYS & !MEMORYKEYSETS)char *error lib = 0; /* for handling library open errors */

#endif

#if JTERMCOMPRESSION/* support for data compression in JTERM */

sm cprinit (;#endif

#if ALTSCROLLING/* if support for user defined scrolling

functions is desired, call:sm alsc init (;

#endif

#if SOFTKEYS/* if soft key support is desired

initialize it by calling:

Page 67: DATA BROWSER INTERFACE FOR THE COMPOSITE ...web.mit.edu/smadnick/www/wp2/1991-04.pdfChapter 2 - Architecture This chapter describes the architecture that was used to build the CIS

smskeyinit (;#endif

/* Initialize JAM, specifying the defaultsearch path for screens: */

/* Screens are sought first in the memoryresident screen list, then in open libs,next in the current directory, then thepath specified below (as an argument),and finally in that specified by SMPATH */

sm jinitcrt (");

/* JAM will use either memory residentscreens or disk resident screens dependingon which of the following lines areused.

#if MEMORYSCREENS/* The following line installs memory

resident screen lists.sm_ jmem_forms 0;

#endif

#if SOFTKEYS & MEMORY KEYSETSsmskforms 0; /* memory resident keysets */

#endif

#if !MEMORYSCREENS/* The following line opens a disk

resident screen library.if ((jam lib = sm l_open (" jam.lib")) < 0){

errorlib = "jam";}

#endif

#if SOFTKEYS & !MEMORYKEYSETS/* keysets are in a separate library

if ((jamsk lib = sm_1_open ("jamsk.lib")) < 0){

errorlib = "jamsk";

}#endif

#if !MEMORY SCREENS I (SOFTKEYS & !MEMORYKEYSETS)if (error lib){

char err buf[256];

sprintf (errbuf, "%s (%s.lib)",smmsg-get (SMNOLIB), errorlib);

sm_qui msg (errbuf);return(RETFATAL);

}#endif

#if BLOCKMODE/* if block mode support is desired */

sm blkinit 0;

Page 68: DATA BROWSER INTERFACE FOR THE COMPOSITE ...web.mit.edu/smadnick/www/wp2/1991-04.pdfChapter 2 - Architecture This chapter describes the architecture that was used to build the CIS

#endifreturn(RETSUCCESS);

}

/ ***********************************************************************

/* START UP:*// ***********************************************************************

static voidstart up(argc, argv)int argc;char **argv;{#define ARGNAME 1

/* initialize the ldb (local data block) */sm ldb init();

/* get name of first screen fromargument passed on the command line,superceded by startscreenname */

if (start screen name == 0 &&argc > ARGNAME && argv[ARGNAME] != 0 && *argv[ARGNAME] != 0)

{start_screen name = argv [ARGNAME];

}

smjtop (startscreenname);

return;

}

/ ***********************************************************************

/* CLEANUP:*// ***********************************************************************

static voidclean up(){

#if !MEMORYSCREENS/* If screen libraries are used, be sure

to close themsm_1_close (jam lib);

#endif

#if SOFTKEYS & !MEMORY KEYSETSsm_1_close (jamsk-lib);

#endif/* reset the terminal for exit */

sm jresetcrt();

Page 69: DATA BROWSER INTERFACE FOR THE COMPOSITE ...web.mit.edu/smadnick/www/wp2/1991-04.pdfChapter 2 - Architecture This chapter describes the architecture that was used to build the CIS

return;

Page 70: DATA BROWSER INTERFACE FOR THE COMPOSITE ...web.mit.edu/smadnick/www/wp2/1991-04.pdfChapter 2 - Architecture This chapter describes the architecture that was used to build the CIS

jxmain.c/* static char id string[] = "@(#)jxmain.c16:37:29"; *// *************************************//* Copyright (C) 1986 - 1990

by/* JYACC, Incorporated/* New York, New York/* All Rights Reserved/* Printed in U.S.A. *//* Property of JYACC, Incorporated *// *************************************/

50.36 90/08/22

/ ********************************************************Modified by: Tom ParkerDate: April 1991

Modified to support the "cisclient" application.

#include "smdefs.h"#include "smerror.h"#include "smcmprs.h"

/* THE FOLLOWING FUNCTIONS ARE IN THIS MODULE */

int main PROTO((int, char **));static int initialize PROTO((void));static void start up PROTO((int, char **, int));static void clean-up PROTO((void));

/* name of first screen to bedisplayed */

static char *start screen name;

intmain (argc, argv)int argc;char **argv;

int editopt;int ret status;

/* Place code to be executed before any JAM initializations here

/* Code calls the server and initializes the schema structure */initclient (;

parse the command linelook for -e and possibly expand */wild cards. prog name will be */removed from argv[0], all argumentswill be shifted, -e removed, argcadjusted to the count of actual */arguments (not counting prog name)

Page 71: DATA BROWSER INTERFACE FOR THE COMPOSITE ...web.mit.edu/smadnick/www/wp2/1991-04.pdfChapter 2 - Architecture This chapter describes the architecture that was used to build the CIS

edit-opt = sm jxeditmode (&argc, &argv);

retstatus = initializeo;

if (ret status == RETSUCCESS){

/* Place all code to be executed before *//* first screen is brought up, here

/* Call function in funclist toinstall user functions */

sm do uinstallso;

/* to hard code the name of the first screen, *//* "TOPSCREEN", replace the following line with *//* start screen name = "TOPSCREEN" */

start screen name = 0;

start up(argc, argv, edit-opt);}

/* Place your clean up code needed before JAM cleans up, here */

cleanupo;

/* Place all your closing code here */

exit (ret status);

}

/ ***********************************************************************

/* Modifying the rest of this file is recommended for advanced usersonly *// ***********************************************************************

/ ***********************************************************************

/* OPTIONAL SUBSYSTEMS:*//*

/* To quickly add or delete several optional subsystems the following*//* macros are provided.*//* To save memory, they are by default set to 0 (not installed)*//* Setting any or all of them to 1 will cause that subsystem to be*//* installed, and consequentially take more memory.*//* Note that they can also be changed by compiler directives.*/

Page 72: DATA BROWSER INTERFACE FOR THE COMPOSITE ...web.mit.edu/smadnick/www/wp2/1991-04.pdfChapter 2 - Architecture This chapter describes the architecture that was used to build the CIS

/* See the Programmer's Guide for additional information.*// ***********************************************************************

#ifndef SOFTKEYS#define SOFTKEYS 0#endif

#ifndef ALT SCROLLING#define ALTSCROLLING#endif

#ifndef MEMORY SCREENS#define MEMORYSCREENS#endif

#ifndef MEMORY KEYSETS#define MEMORYKEYSETS#endif

#ifndef BLOCK MODE#define BLOCKMODE#endif

#ifndef JTERM COMPRESSIO#define JTERM_COMPRESSIO#endif

/* soft keys (keysets) */

0 /* user defined scrolling */

0 /* make screens memory resident */

0 /* make keysets memory resident */

0 /* block mode terminals */

NN /* JTERM with data compression */

/***********************************************************************

/* GLOBAL VARIABLES USED IN FOLLOWING PROCEDURES*// ***********************************************************************

#if !MEMORYSCREENS

static int jxformlib;static int jam lib;#endif

#if SOFTKEYS & !MEMORYKEYSETS

static int jamsk-lib;#endif

/* library descriptor of diskresident screen library */

/* library descriptor of diskresident softkey library

/* library descriptor of diskresident help screens library*/

static int jxhelplib;

/***********************************************************************

/* INITIALIZE:*/

Page 73: DATA BROWSER INTERFACE FOR THE COMPOSITE ...web.mit.edu/smadnick/www/wp2/1991-04.pdfChapter 2 - Architecture This chapter describes the architecture that was used to build the CIS

/***********************************************************************

static intinitialize()

char *error lib = 0; /* for handling library open errors */

#if JTERMCOMPRESSION/* support for data compression in JTERM */

smcprinit (;#endif

#if ALTSCROLLING/* if support for user defined scrolling

functions is desired, call: */sm alscinit 0;

#endif

#if SOFTKEYS/* if soft key support is desired

initialize it by calling:smxskeyinit 0;

#endif/* Initialize JXFORM, specifying the default

search path for screens: */

/* Screens are sought first in the memoryresident screen list, then in open libs,next in the current directory, then thepath specified below (as an argument),and finally in that specified by SMPATH */

sm jxinitcrt ("");

/* JXFORM will use either memory residentscreens or disk resident screens dependingon which of the following lines areused. */

#if MEMORYSCREENS/* The following line installs memory

resident screen lists. */sm jxmem-forms 0;

#endif

#if SOFTKEYS & MEMORY KEYSETSsm xsk-forms (; /* memory resident keysets */

#endif

#if !MEMORYSCREENS/* The following line opens a disk

resident screen library. */if ((jam lib = sm-l_open ("jam.lib")) < 0)

error lib = "jam";}

if ((jxformlib = sm_1_open ("jxform.lib"t)) < 0)

Page 74: DATA BROWSER INTERFACE FOR THE COMPOSITE ...web.mit.edu/smadnick/www/wp2/1991-04.pdfChapter 2 - Architecture This chapter describes the architecture that was used to build the CIS

error lib = "jxform";

#endif

#if SOFTKEYS & !MEMORYKEYSETS/* keysets are in a separate library

if ((jamsklib = sm lopen ("jxsoft.lib")) < 0){

error lib = "jxsoft";

#endif/* help screens, if desired, must come from a library */

if ((jxhelp-lib = sm lopen ("jxhelp.lib")) < 0){

errorlib = " jxhelp";}

if (error lib){

char err buf[256];

sprintf (errbuf, "%s (%s.lib)",sm msg get (SMNOLIB), error_lib);

sm_quimsg (errbuf);return (RETFATAL);

}

#if BLOCK MODE/* if block mode support is desired */

sm blkinit 0;#endif

return (RETSUCCESS);}

/***********************************************************************

/* STARTUP:*// ***********************************************************************

static voidstart-up(argc, argv,int argc;char **argv;int editopt;{#define ARGNAME 0

if (editopt){

editopt)

/* for -e option (editor)

/* enter the screen editor directly */

/* NOTE: argc and argv have beenadjusted by sm jxeditmode

sm xform (argc, argv);

Page 75: DATA BROWSER INTERFACE FOR THE COMPOSITE ...web.mit.edu/smadnick/www/wp2/1991-04.pdfChapter 2 - Architecture This chapter describes the architecture that was used to build the CIS

return;}

/* initialize the ldb (local data block) */sm ldb init();

/* get name of first screen fromargument passed on the command line,superceded by startscreenname */

/* NOTE: argc and argv have beenadjusted by sm jxeditmode */

if (start screen name == 0 &&argc > ARGNAME && argv[ARGNAME] != 0 && *argv[ARGNAME] != 0)

{startscreen name = argv[ARGNAME];

}

sm jtop (start_screen name);

return;}

/ ***********************************************************************

/* CLEANUP:*// ***********************************************************************

static voidclean up(){

#if !MEMORYSCREENS/* If screen libraries are used, be sure

to close themsmlclose (jamlib);sm_1_close (jxformlib);

#endif

#if SOFTKEYS & !MEMORY KEYSETSsm_1_close (jamsklib);

#endif

smlclose (jxhelp_lib);

/* reset the terminal for exit */sm jxresetcrt (;

return;

Page 76: DATA BROWSER INTERFACE FOR THE COMPOSITE ...web.mit.edu/smadnick/www/wp2/1991-04.pdfChapter 2 - Architecture This chapter describes the architecture that was used to build the CIS

lispcomm.c/* static char id string[] = "@(#)jxmain.c16:37:29"; *//*************************************//* Copyright (C) 1986 - 1990

by/* JYACC, Incorporated/* New York, New York/* All Rights Reserved/* Printed in U.S.A. *//* Property of JYACC, Incorporated *// *************************************/

50.36 90/08/22

Modified by: Tom ParkerDate: April 1991

Modified to support the "cisclient" application.

#include "smdefs.h"#include "smerror.h"#include "smcmprs .h"

/* THE FOLLOWING FUNCTIONS ARE IN THIS MODULE */

int main PROTO((int, char **));static int initialize PROTO((void));static void startup PROTO((int, char **, int));static void clean_up PROTO((void));

/* name of first screen to bedisplayed */

static char *start screen name;

intmain (argc, argv)int argc;char **argv;

int editopt;int ret status;

/* Place code to be executed before any JAM initializations here

/* Code calls the server and initializes the schema structure */init client (;

/* parse the command line/* look for -e and possibly expand *//* wild cards. prog name will be *//* removed from argv[0], all arguments/* will be shifted, -e removed, argc/* adjusted to the count of actual *//* arguments (not counting prog name)

Page 77: DATA BROWSER INTERFACE FOR THE COMPOSITE ...web.mit.edu/smadnick/www/wp2/1991-04.pdfChapter 2 - Architecture This chapter describes the architecture that was used to build the CIS

editopt = sm jxeditmode (&argc, &argv);

ret status = initializeo;

if (ret status == RETSUCCESS)

/* Place all code to be executed before *//* first screen is brought up, here */

/* Call function in funclist toinstall user functions */

sm do uinstallso;

/* to hard code the name of the first screen, *//* "TOPSCREEN", replace the following line with *//* start screen name = "TOPSCREEN" */

start screen name = 0;

startup(argc, argv, editopt);

/* Place your clean up code needed before JAM cleans up, here */

cleanup();

/* Place all your closing code here */

exit (ret status);

/ ***********************************************************************

/* Modifying the rest of this file is recommended for advanced usersonly *//***********************************************************************

/***********************************************************************

/* OPTIONAL SUBSYSTEMS:*//**//* To quickly add or delete several optional subsystems the following*//* macros are provided.*//* To save memory, they are by default set to 0 (not installed)*//* Setting any or all of them to 1 will cause that subsystem to be*//* installed, and consequentially take more memory.*//* Note that they can also be changed by compiler directives.*/

Page 78: DATA BROWSER INTERFACE FOR THE COMPOSITE ...web.mit.edu/smadnick/www/wp2/1991-04.pdfChapter 2 - Architecture This chapter describes the architecture that was used to build the CIS

/* See the Programmer's Guide for additional information.*// ***********************************************************************

#ifndef SOFTKEYS#define SOFTKEYS 0#endif

#ifndef ALT SCROLLING#define ALTSCROLLING#endif

#ifndef MEMORY SCREENS#define MEMORYSCREENS#endif

#ifndef MEMORY KEYSETS#define MEMORYKEYSETS#endif

#ifndef BLOCK MODE#define BLOCKMODE#endif

#ifndef JTERM COMPRESSIO#define JTERMCOMPRESSIO#endif

/* soft keys (keysets) */

0 /* user defined scrolling */

0 /* make screens memory resident */

0 /* make keysets memory resident */

0 /* block mode terminals */

NN /* JTERM with data compression */

/***********************************************************************

/* GLOBAL VARIABLES USED IN FOLLOWING PROCEDURES*// ***********************************************************************

#if !MEMORYSCREENS

static int jxformlib;static int jam lib;#endif

#if SOFTKEYS & !MEMORYKEYSETS

static int jamsklib;#endif

static int jxhelp-lib;

/* library descriptor of diskresident screen library */

/* library descriptor of diskresident softkey library *

/* library descriptor of diskresident help screens library*/

/***********************************************************************

/* INITIALIZE:*/

Page 79: DATA BROWSER INTERFACE FOR THE COMPOSITE ...web.mit.edu/smadnick/www/wp2/1991-04.pdfChapter 2 - Architecture This chapter describes the architecture that was used to build the CIS

/***********************************************************************

static intinitialize(){

char *error lib = 0; /* for handling library open errors */

#if JTERMCOMPRESSION/* support for data compression in JTERM */

smcprinit (;#endif

#if ALT SCROLLING/* if support for user defined scrolling

functions is desired, call:sm alscinit 0;

#endif

#if SOFTKEYS/* if soft key support is desired

initialize it by calling: */smxskeyinit 0;

#endif/* Initialize JXFORM, specifying the default

search path for screens: */

/* Screens are sought first in the memoryresident screen list, then in open libs,next in the current directory, then thepath specified below (as an argument),and finally in that specified by SMPATH */

sm jxinitcrt ("");

/* JXFORM will use either memory residentscreens or disk resident screens dependingon which of the following lines areused. */

#if MEMORYSCREENS/* The following line installs memory

resident screen lists.sm jxmem-forms 0;

#endif

#if SOFTKEYS & MEMORY KEYSETSsm xsk forms (; /* memory resident keysets */

#endif

#if !MEMORY SCREENS/* The following line opens a disk

resident screen library. */if ((jam lib = sm_l open ("jam.lib")) < 0)

{error lib = "jam";

if ((jxform lib = sm_1_open ("jxform.lib")) < 0)

Page 80: DATA BROWSER INTERFACE FOR THE COMPOSITE ...web.mit.edu/smadnick/www/wp2/1991-04.pdfChapter 2 - Architecture This chapter describes the architecture that was used to build the CIS

error lib = "jxform";

#endif

#if SOFTKEYS & !MEMORYKEYSETS/* keysets are in a separate library

if ((jamsk-lib = smil-open ("jxsoft.lib")) < 0)

error-lib = "jxsoft";}

#endif/* help screens, if desired, must come from a library */

if ((jxhelplib = sm lopen ("jxhelp.lib")) < 0){

error lib = "jxhelp";I

if (error lib){

char err buf[256];

sprintf (errbuf, "%s (%s.lib)",sm msg get (SMNOLIB), errorlib);

smqui_msg (errbuf);return(RETFATAL);

}

#if BLOCK MODE/* if block mode support is desired */

sm blkinit 0;#endif

return(RETSUCCESS);

/***********************************************************************

/* START UP:*// ***********************************************************************

static voidstart up(argc, argv, edit-opt)int argc;char **argv;int edit-opt; /* for{#define ARGNAME 0

if (editopt){

-e option (editor)

/* enter the screen editor directly */

/* NOTE: argc and argv have beenadjusted by sm jxeditmode

sm xform (argc, argv);

Page 81: DATA BROWSER INTERFACE FOR THE COMPOSITE ...web.mit.edu/smadnick/www/wp2/1991-04.pdfChapter 2 - Architecture This chapter describes the architecture that was used to build the CIS

return;

/* initialize the ldb (local data block) */sm ldb init();

/* get name of first screen fromargument passed on the command line,superceded by startscreenname */

/* NOTE: argc and argv have beenadjusted by smjxeditmode

if (start screen name == 0 &&argc > ARGNAME && argv[ARGNAME] != 0 && *argv[ARGNAME] ! 0)

{startscreenname = argv[ARGNAME];

}

sm_ jtop (startscreenname);

return;

}

/ ***********************************************************************

/* CLEANUP:*// ***********************************************************************

static voidcleanup(){

#if !MEMORYSCREENS/* If screen libraries are used, be sure

to close themsm 1_close (jamlib);smlclose (jxf orm lib);

#endif

#if SOFTKEYS & !MEMORY KEYSETSsm_1_close (jamsk-lib);

#endif

sm 1_close (jxhelplib);

/* reset the terminal for exit */smjxresetcrt();

return;}

Page 82: DATA BROWSER INTERFACE FOR THE COMPOSITE ...web.mit.edu/smadnick/www/wp2/1991-04.pdfChapter 2 - Architecture This chapter describes the architecture that was used to build the CIS

querv.c/ ****************************************************************

query.c - This program handles execution of queries for dbclient

Written by: Tom ParkerDate: May 1991

#include <stdio.h>#include <unistd.h>#include "global.h"#include "schema.h"#include "static.h"

/* the following structure is used for query processing */typedef struct {

entity *ent; /* a pointer to an entity */int depth; /* depth in the query tree */

} querytree;

/ *****************************************************************

doquery() - This function takes a query defined by the user throughJYACC menus and turns it into the cis/tk Global Query Language

inputnone

returns0 if the query is successful, -1 otherwise

int doquery(){querytree *query,*lastent; /* query array, last element in array */entity *firstent,*curent;int entnum;

sm putfield(1, "Parsing query");sm flusho; /* flush the write *//* loop through all entities, resetting selected byte *//* mark the first entity in the query */firstent = NULL;for (entnum=O;entnum<schema .numents; entnum++)

{curent = &schema.ents[entnum];curent->isselected = 0;if (inquery(curent) && (firstent == NULL))firstent = curent;

/* check for an empty query */if (firstent == NULL)

sm close window();return (-1) ;

/* create an array big enough to hold pointers to all entities */query = (querytree *) calloc(schema.numents,sizeof(querytree));

Page 83: DATA BROWSER INTERFACE FOR THE COMPOSITE ...web.mit.edu/smadnick/www/wp2/1991-04.pdfChapter 2 - Architecture This chapter describes the architecture that was used to build the CIS

/* initialize first array element */firstent->isselected = 1;query->ent = firstent;query->depth = 0;/* initialize the pointer to the end of the array */lastent = query;/* call recursive routine to build the query tree */maketree (firstent, &lastent, 1);

/* check to make sure all entities joined and no complex joins */if (checkquery(query,lastent) !=0)

{free (query);sm close-windowo;return (-1) ;

I

/* call tree optimization rountine */optquery (query, lastent);

sm putfield (1, "Sending query");sm flusho;/* send the query */sendquery (query, lastent);

/* deallocate the query tree, problems with moving pointer */f ree (query) ;

/* receive the query */smyputfield(1, "Waiting for result");sm flusho;getresult (;

return (0) ;

/ *****************************************************************

maketree() - recursive routine to build the query tree

inputsqueryplace - pointer to the current place in the query treequerylast - pointer to the last place in the query treedepth - current depth of the tree

returnsnothing

maketree (curent, lastent, depth)entity *curent;querytree **lastent;int depth;

relation *currel;entity *relent;int relnum;

/* loop for all related entities */

Page 84: DATA BROWSER INTERFACE FOR THE COMPOSITE ...web.mit.edu/smadnick/www/wp2/1991-04.pdfChapter 2 - Architecture This chapter describes the architecture that was used to build the CIS

for (relnum=O; relnum<curent->numrels; relnum++)

currel = &curent->rels[relnum];relent = (entity *) findent(currel->relent);/* if the related entity is in the query and has not yet been

selected *//* add it to the array and go to next level of the tree */if (inquery(relent) && (relent->isselected == 0))

relent->isselected = 1;(*lastent) ++;(*lastent)->ent = relent;(*lastent)->depth = depth;maketree(relent,lastent,depth+1);

return;

/ *****************************************************************

inquery() - This function determines whether or not an entity is ina query. There are two conditions under which a an entity is in aquery:

1. One or more of the fields is selected2. One or more of the fields has scope conditions

inputcurent - This is a pointer to the current entity to be checked

returns0 if not in query, 1 if in query, 2 if in query and scope

conditions exist

int inquery (curent)entity * curent;

attribute *curatt;int attnum, result=0;

/* go through the attribute list and see if it is in the query */for (attnum=O; (attnum<curent->numatts) && (result<2) ;attnum++)

curatt = &curent->atts [attnum];/* if in the query return a 1 */if (curatt->scope[0}) result = 2;else if (curatt->isselected) result = 1;;

}

return (result) ;

}

checkquery() - This function checks the query forcomplexity that means that a query can not be made. It alsochecks to make sure that all entities which are in the querycan be joined.

input

Page 85: DATA BROWSER INTERFACE FOR THE COMPOSITE ...web.mit.edu/smadnick/www/wp2/1991-04.pdfChapter 2 - Architecture This chapter describes the architecture that was used to build the CIS

query - a pointer to the top of the query treelastquery - a pointer to the end of the query tree

returns0 - query OK-1 - can't join a query file-2 - can't handle join complexity

int checkquery(begin, end)querytree *begin,*end;

entity *curent;int entnum;querytree *curq;char message[80];

/* check to make sure all entities are joined */for (entnum=O;entnum<schema.numents;entnum++)

curent = &schema.ents[entnum];/* if it should be in the query but is not we have a join problem

*/if (inquery(curent) && (curent->isselected==O))

strcpy(message, "Can't join entity: ");strcat(message, curent->name);strcat(message,". Execution aborted.");smemsg(message);return(-1);

/* now look for complex joins *//* a complex join is any join that involves more than *//* two entities */curq = begin;while (curq<end)

if (countjoins(curq,end) > 2){strcpy(message,"Can't do complex join on entity: ");strcat(messagecurq->ent->name);strcat(message,". Execution aborted.");smemsg(message);return(-2);

}curq++;

return(0);

/ ****************************************************************countjoins() - This function counts the number of joins between anentity in the query and other entities in the query.

inputbegin - the begining of querytree list

Page 86: DATA BROWSER INTERFACE FOR THE COMPOSITE ...web.mit.edu/smadnick/www/wp2/1991-04.pdfChapter 2 - Architecture This chapter describes the architecture that was used to build the CIS

end - the end of the querytree list

returnsthe number of joins

int countjoins(begin,end)querytree *begin, *end;

int joincount;querytree *joinq;

/* initialize the count of joins */if (begin->depth > 0) joincount = 1; /* it has a parent */else joincount = 0; /* it has no parent */

joinq = begin+l;/* do until we find another entity at the same depth or less *//* or there are no more entities */while ( (joinq<=end) && (joinq->depth>begin->depth))

{/* depth + 1 signifies it is a join */if (joinq->depth==begin->depth+1) joincount++;joinq++;

}

/* return the count */return(joincount);

}

/ ************************************************************optquery() - This function optomizes the query tree by:Putting at the top, those entities on which there areconstraints. Making sure that the entity at the top onlyhas one join.

inputbegin - begining of the query treeend - end of the query tree

returnsnothing

optquery (begin, end)querytree *begin, *end;

querytree *curq,*flipq;entity *temp;

/* find the first entity that has only one join and has a constraint

curq = begin;while (curq<end)

if ((countjoins(curq,end) == 1) && (inquery(curq->ent) == 2))break;

curq++;

Page 87: DATA BROWSER INTERFACE FOR THE COMPOSITE ...web.mit.edu/smadnick/www/wp2/1991-04.pdfChapter 2 - Architecture This chapter describes the architecture that was used to build the CIS

/* use algorithm 1 */if (curq->depth>begin->depth+1)

{/* this algorithm reverses the tree between begin and curq */flipq=begin;while (flipq<curq){

/* swap the entities */temp = flipq->ent;flipq->ent = curq->ent;curq->ent = temp;/* move the pointers towards one another */curq--;flipq++;

}

/* use algorithm 2 *//* this algorithm puts the found entity to the top moves all others

down 1 */else

{temp = curq->ent;while(curq>begin)

curq->ent=(curq-1)->ent;curq->depth = (curq-1)->depth+1;curq--;

begin->ent = temp;}

/* if we still don't have an end node *//* we must repeat the algorithm for a node which *//* does not have a constraint */if (countjoins(beginend) > 1)/* find the first entity that has only one join */

{curq = begin;while(curq<end){if (countjoins(curq,end) == 1) break;curq++;

}

/* use algorithm 1 */if (curq->depth>begin->depth+1)

/* this algorithm reverses the tree between begin and curq */flipq==begin;while (flipq<curq)

/* swap the entities */temp = flipq->ent;flipq->ent = curq->ent;curq->ent = temp;/* move the pointers towards one another */curq--;flipq++;

Page 88: DATA BROWSER INTERFACE FOR THE COMPOSITE ...web.mit.edu/smadnick/www/wp2/1991-04.pdfChapter 2 - Architecture This chapter describes the architecture that was used to build the CIS

}/* use algorithm 2 *//* this algorithm puts the found entity to the top *//* and moves all others down 1 */else

temp = curq->ent;while(curq>begin)

curq->ent=(curq-l)->ent;curq--;

begin->ent = temp;

return;}

/ *************************************************************sendquery - This function takes the optimized query, turns itinto GRL, and submits it to the server

inputbegin - pointer to the begining of the query treeend - pointer to the end of the query tree

returnsnothing

sendquery(begin,end)querytree *begin, *end;

FILE *outfile;qmessage outmessage;querytree *curq;entity *curent;attribute *curatt;int attnum;

/* address the outgoing message */outmessage.from = getpid();outmessage.to = 1;strcpy (outmessage. command, "QUERY");/* get the name of the output file */gettempname(outmessage.textcisdbtmpdir);

outfile = fopen(outmessage.text,"w");

/* go through the queue and put it out */curq = begin;while (curq<=end)

curent = curq->ent;if (curq<end) /* we need a join */

fprintf (outfile, "(join \n");fprintf(outfile,"(select %s (",curent->name);for (attnum=O; attnum<curent->numatts; attnum++)

Page 89: DATA BROWSER INTERFACE FOR THE COMPOSITE ...web.mit.edu/smadnick/www/wp2/1991-04.pdfChapter 2 - Architecture This chapter describes the architecture that was used to build the CIS

curatt = &curent->atts(attnum];if (curatt->isselected)fprintf(outfile, "%s ", curatt->name);

Ifprintf (outfile, ") ");if (inquery(curent) == 2) /* we have constraints */

for (attnum=O;attnum<curent->numatts;attnum++){curatt = &curent->atts[attnum];if (curatt->scope(O] != 0){'

fprintf (outfile, "where ( = %s \"%s\")",curatt->name, curatt->scope);

break;}

}/* close the select */fprintf (outfile, ") \n");curq++;

/* close all the joins *1curq = begin;while (curq++<end)

fprintf (outfile,")");

/* close the output file */fclose(outfile);

/* put the query to the queue */qput (qnumber, &outmessage);

return;

/ ***************************************************************getresult() - This function gets the result of the query anddisplays it.

inputsnone

returns0 if successful, 1 if lisp error

int getresult()

qmessage inmessage;char inline[80];int linecount=0;FILE *infile;

/* get the result of the query */inmessage.to = getpido;inmessage.from = 1;qget (qnumber, &inmessage);

/* check for error on return */if (strcmp(inmessage.text, "ERROR")==O)

Page 90: DATA BROWSER INTERFACE FOR THE COMPOSITE ...web.mit.edu/smadnick/www/wp2/1991-04.pdfChapter 2 - Architecture This chapter describes the architecture that was used to build the CIS

sm close window();sm bel();sm-emsg("I%AO01OLisp error detected. Can not process query.");return(-1);

/* close the message window */sm close window();

infile = fopen(inmessage.text,"r");/* open the window */sm_r_window("queryres.scr",1,1);

while (fgets(inline,sizeof(inline),infile) ! NULL)

linecount++;/* remove the trailing line feed */inline[strlen(inline)-1] = 0;/* put the line on the screensm o_putfield(llinecount,inline);

sm home();/*close and unlink the file */fclose(infile);unlink(inmessage.text);return(0);

Page 91: DATA BROWSER INTERFACE FOR THE COMPOSITE ...web.mit.edu/smadnick/www/wp2/1991-04.pdfChapter 2 - Architecture This chapter describes the architecture that was used to build the CIS

queue.c/ ******************************************************************queue.c- program handles all queue functions for both server and clientprograms (dbserver, dbclient)

Written by: Tom ParkerDate: 4/19/1991

#include <stdio.h>#include <sys/types.h>#include <sys/ipc.h>#include <sys/msg.h>#include "global.h"

/ **********************************************************************function qopen

inputs:flag - flag is either 0 for server, 1 for client

returns:qnumber - the number of the input queue

int qopen (flag, servername)char flag;{keyt qkey; /* unique value of queue key */int qnumber; /* the number of the queue opened */int msgflag; /* the flag passed to msgget */

/* create unique qnumber using ftok function to create key *//* global variable "cisdbtmpdir" is used to create the name */qkey = ftok(cisdbtmpdir,5);

/* set flags for queue opening */if (flag == 1) /* this is the client */

msgflag = 0;if ((qnumber = msgget(qkey,msgflag))== -1){printf ("%s\n%s\n",

"Can't connect to server process. Please startserver.. .",

"Program terminated.");exit (1);

}}

else /* this is the server */{/* msgflag is: create queue, make sure it has not been created,all users have permission to read and write the queue */

msgflag = IPCCREAT I IPCEXCL 1 0666;if ((qnumber = msgget(qkey,msgflag)) == -1)

perror ("");printf ("\n%s\n\n%s\n%s\n\n%s\n%s\n\n",

Page 92: DATA BROWSER INTERFACE FOR THE COMPOSITE ...web.mit.edu/smadnick/www/wp2/1991-04.pdfChapter 2 - Architecture This chapter describes the architecture that was used to build the CIS

"Server process already exists.","If you want to start a client session:"," type \"dbclient main menu.scr\" to start session.",

"If you are sure no one is using the server:",type \"qutil -k\" to terminate the server process.");

exit(1);

}

return qnumber;}

/ **********************************************************************

function qcloseinputs:qnumber - the number of the queue to close

returns:none

void qclose(qnumber)int qnumber;{

struct msqid-ds qbuf;

if (msgctl(qnumber,IPCRMID,qbuf) == -1){printf("%s\n", "Can't remove message queue.");

/ **********************************************************************

function qget:gets messages from the message queue

inputs:qnumber - the number of the queue to read frominmessage - the message structure

.to - the addressee of the message - 1 if server, PID if clientreturns:

inmessage - the message structure.from - the sender of the message - 1 if server, PID if client.message - the message

void qget (qnumber, inmessage)int qnumber;qmessage *inmessage;f

/* check the read for errors */if (msgrcv(qnumber,inmessage,sizeof (qmessage) -sizeof (long),

inmessage->to,MSGRWAIT) == -1)

{printf("Unable to read from queue... Program terminated.\n");exit(1);

}/* return of all data is implicit in the qmessage structure */

}

Page 93: DATA BROWSER INTERFACE FOR THE COMPOSITE ...web.mit.edu/smadnick/www/wp2/1991-04.pdfChapter 2 - Architecture This chapter describes the architecture that was used to build the CIS

/ **********************************************************************

function qputinputs:qnumber - the number of the queue to write tooutmessage - the qmessage structure

.to - the addressee of the message - 1 for server, PID for clients

.from - the sender of the message - 1 for server, PID for clients

.message - message to sendreturns:

none

void qput (qnumber, outmessage)int qnumber;qmessage *outmessage;{

/* check the write for errorsif (msgsnd(qnumber, outmessage,sizeof(qmessage) -sizeof (long) ,MSGWWAIT)

== -1){printf ("Unable to write to queue... Program terminated.\n");exit (1);

}

Page 94: DATA BROWSER INTERFACE FOR THE COMPOSITE ...web.mit.edu/smadnick/www/wp2/1991-04.pdfChapter 2 - Architecture This chapter describes the architecture that was used to build the CIS

gutil.c/* qutil.c - utility program for queue diagnositics

Developed by: Tom ParkerDate: April 1991

This program performs queue utility and diagnostics for the CIS databrowserprograms.

currently supported flags:-k - kill the queue-c - count the message in the queue*/

#include <stdio.h>#include <string.h>#include <sys/types.h>#include <sys/ipc.h>#include <sys/msg.h>#include "global.h"

/* these are defined to eliminate compiler error but are never used */char *cisdbdir, *cisdbtmpdir;

main (argc, argv)int argc;char *argv[];

int qnumber;int inmsgs = 0;qmessage inmessage;

/* initialize directory variables */initdirs(&cisdbdir,&cisdbtmpdir);

/* open the queue */qnumber = qopen(1);

/* kill the queue */if (strcmp(argv[l],"-k") == 0)

qclose (qnumber);

/* count the messages in the queue */else if (strcmp(argv[1],"-c") == 0)

while (msgrcv(qnumber,&inmessage,sizeof (qmessage) , 0, IPCNOWAIT)!= -1)

printf("\nFrom: %d\nTo: %d\nCommand: %s\n",inmessage.from, inessage.to,inmessage.command);

inmsgs++;printf("\nNumber of messages in queue: %d\n\n",inmsgs);

Page 95: DATA BROWSER INTERFACE FOR THE COMPOSITE ...web.mit.edu/smadnick/www/wp2/1991-04.pdfChapter 2 - Architecture This chapter describes the architecture that was used to build the CIS

schema.c

schema.c - Functions in this file are used to manipulate the schema.

Written by: Tom ParkerDate: May 1991

#include <stdio.h>#include "schema.h"#include "static.h"

findent() - This function finds an entity in the schema tree,given that entity's name.

inputentname - name of the entity to find

returnsNULL if the entity is not found, otherwise a pointer to the named

entity

entity *findent (entname)char *entname;{

int entnum;

/* get to the correct entity */for (entnum = 0;

(strcmp(schema.ents(entnum] .nameentname) != 0) &&(entnum < schema.numents);entnum++)

/* if it is not in the list return a NULL */if (entnum == schema.numents) return(NULL);

/* otherwise return a pointer to the entity */return(&schema.ents(entnum]);

findatt() - This function finds an attirbute for a given entityin the schema tree, given a pointer to the entity and theattribute's name.

inputcurent - pointer to the entity which contains the attributeattname - the name of the attribute to find

returnsNULL if the attribute is not found,otherwise a pointer to the named attribute

entity *findatt (curentattname)entity *curent;

Page 96: DATA BROWSER INTERFACE FOR THE COMPOSITE ...web.mit.edu/smadnick/www/wp2/1991-04.pdfChapter 2 - Architecture This chapter describes the architecture that was used to build the CIS

char *attname;

int attnum;

/* get to the correct entity */for (attnum = 0;

(strcmp(curent->atts[attnum].nameattname) != 0) &&(attnum<curent->numatts);

attnum++)

/* if it is not in the list return a NULL */if (attnum == curent->numatts) return(NULL);

/* otherwise return a pointer to the attribute */return(&curent->atts[attnum]);

Page 97: DATA BROWSER INTERFACE FOR THE COMPOSITE ...web.mit.edu/smadnick/www/wp2/1991-04.pdfChapter 2 - Architecture This chapter describes the architecture that was used to build the CIS

global.h

global.h - global structure declarations for cisserver and cisclient

Developed by: Tom ParkerDate: April 1991

#define QMSGSIZE 200 /* the size of queue text section */

extern char *cisdbdir; /* pointer to the cis main dir */extern char *cisdbtmpdir; /* pointer to the cis temp dir */extern int qnumber; /* the queue number */

/* structure of queue messages */typedef struct qmessage{long to;int from;char command[20);char text[QMSGSIZE);qmessage;

Page 98: DATA BROWSER INTERFACE FOR THE COMPOSITE ...web.mit.edu/smadnick/www/wp2/1991-04.pdfChapter 2 - Architecture This chapter describes the architecture that was used to build the CIS

schema.h/ *********************************************************schema.h - This file contains the data structures that are used tostore and manipulate the global schema from cis/tk.

Written by: Tom ParkerDate: April 1991

#define MAX ENT LENGTH 20#define MAXATTLENGTH 30

typedef struct{char name[MAX ATT LENGTH];char isselected; /* 0 not in query, 1 in query */char scopeoper(2]; /* =,>=,<=,<,> */char scope(31]; /* limit set on field */

} attribute;

typedef struct{char name(MAX ATT LENGTH]; /* relation name */char relent(MAX_ENT_LENGTH]; /* name of related entity */

} relation;

typedef struct

char name[MAX ENT LENGTH];int numatts; /* number of attributes in entity */attribute *atts; /* pointer to attributes */int numrels; /* number of relations in entity */relation *rels; /* pointer to relations */char isselected; /* whether or not it is in the active query */

} entity;

struct schema{

int numents; /* number entities */entity *ents; /* pointer to entities */

} ;

extern struct schema schema;

Page 99: DATA BROWSER INTERFACE FOR THE COMPOSITE ...web.mit.edu/smadnick/www/wp2/1991-04.pdfChapter 2 - Architecture This chapter describes the architecture that was used to build the CIS

static.h

static.h - this file contains the global variables that are usedin the cisclient application. This file needs to be includedafter the file schema.h

Written by: Tom ParkerDate: April 1991 (May is coming on fast)

/* global directory environment variables */char *cisdbdir, *cisdbtmpdir;/* global schema and query structure */struct schema schema;

100

Page 100: DATA BROWSER INTERFACE FOR THE COMPOSITE ...web.mit.edu/smadnick/www/wp2/1991-04.pdfChapter 2 - Architecture This chapter describes the architecture that was used to build the CIS

jmake#* @(#)makefile.distrib 50.2 90/04/22 15:50:00

#* Copyright (C) 1990#* by#* JYACC, Incorporated */#* New York, New York#* All Rights Reserved */#* Printed in U.S.A. */#* Confidential, Unpublished */#* Property of JYACC, Incorporated */

SHELL=/bin/sh

# BASE is the full path name that specifies the parent directory# where JAM is installed. If you have not installed JAM in# /usr/jam then you will need to modify this path.# JPATH specifies the link directory where you can relink jxform# and link a runtime version of jam with your functions.# LPATH specifies the directory that contains all JAM libraries.# CFLAGS specifies compile and link options passed to the Ccompiler# JMMODS lists all objects that are needed to create a runtimeJAM# executable. To link in your C functions you would need to# add the name of the object module that contains yourfunctions.

# Modified by Tom Parker to support the cisclient applicationBASE = /usr/jam5/JPATH = $(BASE)link/LPATH = $(BASE)lib/

# You should not have to modify this line.CFLAGS=-I$ (BASE) include -O

# Modify this variable to add your functions to a runtime jam.JMMODS = jmain.o\

$ (JPATH) jtmouse.o

# Modify this variable to add your functions to jxform for testing.JXMODS = jxmain.o\

$ (JPATH) jtmouse.o

# This is the cisclient applicationCISCLIENT- funclist.o clientinit.o clienthook.o queue.o futil.o\

schema.o query.o

# You should not need to modify the following lines. Please make# sure you are familiar with JAM and makefiles before editing the# following lines.

# need to add back jam hereALL= jam\

njxform

101

Page 101: DATA BROWSER INTERFACE FOR THE COMPOSITE ...web.mit.edu/smadnick/www/wp2/1991-04.pdfChapter 2 - Architecture This chapter describes the architecture that was used to build the CIS

all: $(ALL)

jam: $(CISCLIENT) $(JMMODS) $(LPATH)libjm.a $(LPATH)libsm.arm -f dbclientcc -o -o dbclient \

$(JMMODS) \$(CISCLIENT) \$(LPATH)libjm.a $(LPATH)libsm.a -lm

njxform: $(CISCLIENT) $(JXMODS) $(LPATH)libjx.a $(LPATH)libjm.a$(LPATH)libsm.a

cc -O -o dbclientjx \$(JXMODS) \$(CISCLIENT) \$(LPATH)libjx.a $(LPATH)libjm.a $(LPATH)libsm.a -lm

query.o clienthook.o clientinit.o: global.h schema.h static.h

futil.o:

queue.o: global.h

schema.o: schema.h

102

Page 102: DATA BROWSER INTERFACE FOR THE COMPOSITE ...web.mit.edu/smadnick/www/wp2/1991-04.pdfChapter 2 - Architecture This chapter describes the architecture that was used to build the CIS

makefileSERVER = dbserver.o lispcomm.o queue.o futil.o

CLIENT = cisclient.o queue.o futil.o

UTIL = qutil.o queue.o futil.o

all: dbserver qutil

dbserver: $ (SERVER)cc $(SERVER) -lm -o dbserver

cisclient: $(CLIENT)cc $(CLIENT) -lm -o cisclient

qutil: $(UTIL)cc $(UTIL) -lm -o qutil

dbserver.o lispcomm.o queue.o cisclient.o qutil.o : global.h

103

Page 103: DATA BROWSER INTERFACE FOR THE COMPOSITE ...web.mit.edu/smadnick/www/wp2/1991-04.pdfChapter 2 - Architecture This chapter describes the architecture that was used to build the CIS

B.2 Screen Files

The screen files are used by the JAM software to display screens and define theactions related to screens. The screens that are used by JAM are in binaryformat. They have been converted to ascii format for purposes of listingusing the JAM utility f2asc.

B.2.1 Summary of Filesdisp-query.scr Screen used to display the currently defined query.do-query.scr Screen diplays status messages during query execution.load-query.scr Screen prompts user for the name of a query to load.main menu.scr Main menu screen.query-res.scr Screen used to display the results of query.save-query.scr Screen prompts the user for the name of a file in which

to save a query.scopeatt.scr Attribute selection menu for setting constraints.scope-ent.scr Entity selection menu for setting constraints.scope-set.scr Screen used to enter a constraint.selatt.scr Attribute selection menu for selecting attributes in

query.

selent.scr Entity selection menu for selecting attributes in query.show att.scr Attribute window for listing attributes.show ent.scr Entity selection menu for listing attributes.

104

Page 104: DATA BROWSER INTERFACE FOR THE COMPOSITE ...web.mit.edu/smadnick/www/wp2/1991-04.pdfChapter 2 - Architecture This chapter describes the architecture that was used to build the CIS

B.2.2 Listing of Files

disp query.scrS:dispquery.scr

LINES=10 COLUMNS=80 BACKGROUND=BLUEBORDER=(WHITE) STYLE1

DISPLAY(2,2) (WHITE)=Query:DISPLAY(3,2) (WHITE)=Attributes:DISPLAY(7,2) (WHITE)=Constraints:

F:# NUMBER=1

LINE=2 COLUMN=8UNFILTEREDLENGTH=72 ARRAY-SIZE=1MAX-LENGTH=200 SHIFT-INCR=1WHITE REVERSE

F:# NUMBERS=2, 3, 4

LINE=4 COLUMN=2# (5,2 6,2)

UNFILTEREDLENGTH=78 ARRAY-SIZE=3 VERT-DISTANCE=1WHITE REVERSE

F:# NUMBERS=5, 6

LINE=8 COLUMN=2# (9,2)

UNFILTEREDLENGTH=78 ARRAY-SIZE=2 VERT-DISTANCE=1WHITE REVERSE

105

Page 105: DATA BROWSER INTERFACE FOR THE COMPOSITE ...web.mit.edu/smadnick/www/wp2/1991-04.pdfChapter 2 - Architecture This chapter describes the architecture that was used to build the CIS

do query.scrS:disp_query.scr

LINES=10 COLUMNS=80 BACKGROUND=BLUEBORDER=(WHITE) STYLE1

DISPLAY(2,2) (WHITE)=Query:DISPLAY(3,2) (WHITE)=Attributes:DISPLAY(7,2) (WHITE)=Constraints:

F:# NUMBER=1

LINE=2 COLUMN=8UNFILTEREDLENGTH=72 ARRAY-SIZE=1MAX-LENGTH=200 SHIFT-INCR=1WHITE REVERSE

F:# NUMBERS=2, 3, 4

LINE=4 COLUMN=2# (5,2 6,2)

UNFILTEREDLENGTH=78 ARRAY-SIZE=3 VERT-DISTANCE=1WHITE REVERSE

F:# NUMBERS=5, 6

LINE=8 COLUMN=2# (9,2)

UNFILTEREDLENGTH=78 ARRAY-SIZE=2 VERT-DISTANCE=1WHITE REVERSE

106

Page 106: DATA BROWSER INTERFACE FOR THE COMPOSITE ...web.mit.edu/smadnick/www/wp2/1991-04.pdfChapter 2 - Architecture This chapter describes the architecture that was used to build the CIS

load query.scrS:disp_query.scr

LINES=10 COLUMNS=80 BACKGROUND=BLUEBORDER=(WHITE) STYLE1

DISPLAY(2,2) (WHITE)=Query:DISPLAY(3,2) (WHITE)=Attributes:DISPLAY(7,2) (WHITE)=Constraints:

F:# NUMBER=1

LINE=2 COLUMN=8UNFILTEREDLENGTH=72 ARRAY-SIZE=1MAX-LENGTH=200 SHIFT-INCR=1WHITE REVERSE

F:# NUMBERS=2, 3, 4

LINE=4 COLUMN=2# (5,2 6,2)

UNFILTEREDLENGTH=78 ARRAY-SIZE=3 VERT-DISTANCE=1WHITE REVERSE

F:# NUMBERS=5, 6

LINE=8 COLUMN=2# (9,2)

UNFILTEREDLENGTH=78 ARRAY-SIZE=2 VERT-DISTANCE=1WHITE REVERSE

107

Page 107: DATA BROWSER INTERFACE FOR THE COMPOSITE ...web.mit.edu/smadnick/www/wp2/1991-04.pdfChapter 2 - Architecture This chapter describes the architecture that was used to build the CIS

main menu.scrS:main menu.scr

LINES=12 COLUMNS=24 BACKGROUND=BLUEBORDER=(WHITE) STYLE1ENTRY-FUNC=appinit "&(13, 1)dispquery.scr"

DISPLAY(2,8) (WHITE)=Main Menu

F:# NUMBERS=1, 3, 5, 7, 9, 11, 13, 15

LINE=4 COLUMN=2# (5,2 6,2 7,2 8,2 9,2 10,2 11,2)

UNFILTEREDLENGTH=20 ARRAY-SIZE=8 VERT-DISTANCE=1WHITEMENU-FIELDPROTECTED FROM DATA-ENTRY TABBING-INTO CLEARINGTEXT=%AO010%KXMIT/%KNL%A0007 Select option %A0010%KEXIT%A0007 Quit

OCCUR 1=List attributesOCCUR 2=sElect attributesOCCUR 3=Constrain queryOCCUR 4=eXecute queryOCCUR 5=Open queryOCCUR 6=Save queryOCCUR 7=New queryOCCUR 8=Quit

F:# NUMBERS=2, 4, 6, 8, 10, 12, 14, 16

LINE=4 COLUMN=23

# (5,23 6,23 7,23 8,23 9,23 10,23 11,23)UNFILTEREDLENGTH=1 ARRAY-SIZE=8 VERT-DISTANCE=1MAX-LENGTH=30 SHIFT-INCR=1WHITE NON-DISPLAYPROTECTEDOCCUR 1=&(5,15)showent.scrOCCUR 2=&(5,15)selent.scrOCCUR 3=&(5,15)scope-ent.scrOCCUR 4=&(11,30)do_query.scrOCCUR 5=^fileprompt "loadquery.scr"OCCUR 6=Afileprompt "save query.scr"OCCUR 7=Aclosequery 0OCCUR 8=^jm exit

108

Page 108: DATA BROWSER INTERFACE FOR THE COMPOSITE ...web.mit.edu/smadnick/www/wp2/1991-04.pdfChapter 2 - Architecture This chapter describes the architecture that was used to build the CIS

query res.scrS:queryres.scr

LINES=23 COLUMNS=80 BACKGROUND=BLUE MENU-MODEBORDER=(WHITE) STYLE1

DISPLAY(2,33) (WHITE)=Query Results

F:# NUMBERS=1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,18, 19

LINE=3 COLUMN=2# (4,2 5,2 6,2 7,2 8,2 9,2 10,2 11,2 12,2 13,2 14,2 15,2 16,2 17,218,2)# (19,2 20,2 21,2)

UNFILTEREDLENGTH=78 ARRAY-SIZE=19 VERT-DISTANCE=1MAX-OCCUR=500 PAGE-SIZE=18WHITEPROTECTED FROM DATA-ENTRY CLEARING VALIDATIONTEXT=%AO010%KSPGU%A0007 Next page %A0010%KSPGD%A0007 Prev page\

%AO010%KEXIT%A0007 Done

109

Page 109: DATA BROWSER INTERFACE FOR THE COMPOSITE ...web.mit.edu/smadnick/www/wp2/1991-04.pdfChapter 2 - Architecture This chapter describes the architecture that was used to build the CIS

save query.scrS:save_query.scr

LINES=3 COLUMNS=60 BACKGROUND=BLUEBORDER=(WHITE) STYLE1

DISPLAY(2,2) (WHITE)=Output file name:

F:# NUMBER=l

LINE=2 COLUMN=20UNFILTEREDLENGTH=40 ARRAY-SIZE=1MAX-LENGTH=120 SHIFT-INCR=1WHITE REVERSETEXT=%AO010%KXMIT/%KNL%AO007 Accept %AO010%KEXIT%AO007 CancelVAL-FUNC=filevalid 0

110

Page 110: DATA BROWSER INTERFACE FOR THE COMPOSITE ...web.mit.edu/smadnick/www/wp2/1991-04.pdfChapter 2 - Architecture This chapter describes the architecture that was used to build the CIS

scope att.scrS:scopeatt.scr

LINES=15 COLUMNS=34 BACKGROUND=BLUE MENU-MODEBORDER=(WHITE) STYLE1

DISPLAY (2, 6) (WHITE)=Select Attribute

F:attribute# NUMBERS=1, 3, 5, 7, 9, 11, 13, 15, 17, 19

LINE=4 COLUMN=2# (5,2 6,2 7,2 8,2 9,2 10,2 11,2 12,2 13,2)

UNFILTEREDLENGTH=30 ARRAY-SIZE=10 VERT-DISTANCE=1MAX-OCCUR=100 PAGE-SIZE=9WHITEMENU-FIELDPROTECTED FROM DATA-ENTRY TABBING-INTO CLEARINGSYNCHRONIZED-ARRAYS=SET 1TEXT=%AO010%KXMIT/%KNL%A0007 Select att %A0010%KSPGU%A0007 Next page\

%A0010%KSPGD%A0007 Prev page %AO010%KEXIT%A0007 Prev menuVAL-FUNC=set scope "scope_set. scr"

F:# NUMBERS=2, 4, 6, 8, 10, 12, 14, 16, 18, 20

LINE=4 COLUMN=33# (5,33 6,33 7,33 8,33 9,33 10,33 11,33 12,33 13,33)

UNFILTEREDLENGTH=1 ARRAY-SIZE=10 VERT-DISTANCE=1MAX-OCCUR=100 PAGE-SIZE=9WHITE NON-DISPLAYPROTECTEDSYNCHRONIZED-ARRAYS=SET 1

111

Page 111: DATA BROWSER INTERFACE FOR THE COMPOSITE ...web.mit.edu/smadnick/www/wp2/1991-04.pdfChapter 2 - Architecture This chapter describes the architecture that was used to build the CIS

scope ent.scrS:scopeent.scr

LINES=15 COLUMNS=24 BACKGROUND=BLUE MENU-MODEBORDER=(WHITE) STYLE1ENTRY-FUNC=putents

DISPLAY(2,5) (WHITE)=Select Entity

F:# NUMBERS=1, 3, 5, 7, 9, 11, 13, 15, 17, 19

LINE=4 COLUMN=2# (5,2 6,2 7,2 8,2 9,2 10,2 11,2 12,2 13,2)

UNFILTEREDLENGTH=20 ARRAY-SIZE=10 VERT-DISTANCE=1MAX-OCCUR=100 PAGE-SIZE=9WHITEMENU-FIELDPROTECTED FROM DATA-ENTRY TABBING-INTO CLEARINGSYNCHRONIZED-ARRAYS=NONETEXT=%AO010%KXMIT/%KNL%A0007 Select ent %A0010%KSPGU%A0007 Next page\

%A0010%KSPGD%A0007 Prev page %A0010%KEXIT%A0007 Prev menuVAL-FUNC=putatts 0 "(8,35)scope_att.scr"

F:# NUMBERS=2, 4, 6, 8, 10, 12, 14, 16, 18, 20

LINE=4 COLUMN=23# (5,23 6,23 7,23 8,23 9,23 10,23 11,23 12,23 13,23)

UNFILTEREDLENGTH=1 ARRAY-SIZE=10 VERT-DISTANCE=1MAX-LENGTH=50 SHIFT-INCR=1WHITE NON-DISPLAYPROTECTED

112

Page 112: DATA BROWSER INTERFACE FOR THE COMPOSITE ...web.mit.edu/smadnick/www/wp2/1991-04.pdfChapter 2 - Architecture This chapter describes the architecture that was used to build the CIS

scope set.scrS:scope set.scr

LINES=3 COLUMNS=44 BACKGROUND=BLUEBORDER=(WHITE HILIGHT) STYLE1

DISPLAY(2,2) (WHITE)=Constraint:

F:# NUMBER=1

LINE=2 COLUMN=14UiNFILTEREDLENGTH=30 ARRAY-SIZE=1WHITE REVERSETEXT=%AO010%KXMIT/%KNL%AO007 Accept %AO010%KEXIT%A0007 CancelVAL-FUNC=savescope

113

Page 113: DATA BROWSER INTERFACE FOR THE COMPOSITE ...web.mit.edu/smadnick/www/wp2/1991-04.pdfChapter 2 - Architecture This chapter describes the architecture that was used to build the CIS

sel att.scrS:sel att.scr

LINES=15 COLUMNS=34 BACKGROUND=BLUEBORDER= (WHITE) STYLE1

JAM-CTRL(PF1)=^setscope "scope_set.scr"

DISPLAY(2,7) (WHITE)=Select Attributes

G:attgroupCHECKLIST BOUNCE-BARVAL-FUNC=saveattsBOX(WHITE) OFFSET=2

F:attribute# NUMBERS=1, 2, 3, 4, 5, 6, 7, 8, 9, 10

LINE=4 COLUMN=4# (5,4 6,4 7,4 8,4 9,4 10,4 11,4 12,4 13,4)

UNFILTEREDLENGTH=30 ARRAY-SIZE=10 VERT-DISTANCE=1MAX-OCCUR=100 PAGE-SIZE=9WHITEGROUP=att groupSELECTED-OCCUR=40SELECTED-OCCUR=41SELECTED-OCCUR=44SELECTED-OCCUR=48SELECTED-OCCUR=52SELECTED-OCCUR=53SELECTED-OCCUR=57SELECTED-OCCUR=59SELECTED-OCCUR=60SELECTED-OCCUR=63SELECTED-OCCUR=65SELECTED-OCCUR=70SELECTED-OCCUR=71SELECTED-OCCUR=73SELECTED-OCCUR=81SELECTED-OCCUR=82SELECTED-OCCUR=84SELECTED-OCCUR=85SELECTED-OCCUR=90SELECTED-OCCUR=91SELECTED-OCCUR=92SELECTED-OCCUR=93SELECTED-OCCUR=95SELECTED-OCCUR=97SELECTED-OCCUR=98TEXT=%AO010%KXMIT%A0007 Accept %A0010%KNL%A0007 Select/Deselect\

%AO010%KPF1%A0007 Constrain %A0010%KSPGU%A0007 Next page%A0010%KSPGD%A0007\Prev page %AO010%KEXIT%A0007 Cancel

114

Page 114: DATA BROWSER INTERFACE FOR THE COMPOSITE ...web.mit.edu/smadnick/www/wp2/1991-04.pdfChapter 2 - Architecture This chapter describes the architecture that was used to build the CIS

sel ent.scrS:sel ent.scr

LINES=15 COLUMNS=24 BACKGROUND=BLUE MENU-MODEBORDER=(WHITE) STYLE1ENTRY-FUNC=putents

DISPLAY(2,5) (WHITE)=Select Entity

F:# NUMBERS=1, 3, 5, 7, 9, 11, 13, 15, 17, 19

LINE=4 COLUMN=2# (5,2 6,2 7,2 8,2 9,2 10,2 11,2 12,2 13,2)

UNFILTEREDLENGTH=20 ARRAY-SIZE=10 VERT-DISTANCE=1MAX-OCCUR=100 PAGE-SIZE=9WHITEMENU-FIELDPROTECTED FROM DATA-ENTRY TABBING-INTO CLEARINGSYNCHRONIZED-ARRAYS=NONETEXT=%AO010%KXMIT/%KNL%A0007 Select ent %A0010%KSPGU%A0007 Next page\

%A0010%KSPGD%A0007 Prev page %A0010%KEXIT%A0007 Prev menuVAL-FUNC=putatts 1 "(8,35)selatt.scr"

F:# NUMBERS=2, 4, 6, 8, 10, 12, 14, 16, 18, 20

LINE=4 COLUMN=23# (5,23 6,23 7,23 8,23 9,23 10,23 11,23 12,23 13,23)

UNFILTEREDLENGTH=1 ARRAY-SIZE=10 VERT-DISTANCE=1MAX-LENGTH=50 SHIFT-INCR=1WHITE NON-DISPLAYPROTECTED

115

Page 115: DATA BROWSER INTERFACE FOR THE COMPOSITE ...web.mit.edu/smadnick/www/wp2/1991-04.pdfChapter 2 - Architecture This chapter describes the architecture that was used to build the CIS

show att.scrS:show att.scr

LINES=15 COLUMNS=34 BACKGROUND=BLUE MENU-MODEBORDER= (WHITE) STYLE1

DISPLAY(2,4) (WHITE)=Available Attributes

F:# NUMBERS=1, 3, 5, 7, 9, 11, 13, 15, 17, 19

LINE=4 COLUMN=2# (5,2 6,2 7,2 8,2 9,2 10,2 11,2 12,2 13,2)

UNFILTEREDLENGTH=30 ARRAY-SIZE=10 VERT-DISTANCE=1MAX-OCCUR=100 PAGE-SIZE=9WHITE-MENU-FIELDPROTECTED FROM DATA-ENTRY TABBING-INTO CLEARINGSYNCHRONIZED-ARRAYS=SET 1TEXT=%A0010%KSPGU%A0007 Next page %A0010%KSPGD%A0007 Prev page\

%A0010%KEXIT%A0007 Cancel

F:# NUMBERS=2, 4, 6, 8, 10, 12, 14, 16, 18, 20

LINE=4 COLUMN=33# (5,33 6,33 7,33 8,33 9,33 10,33 11,33 12,33 13,33)

UNFILTEREDLENGTH=1 ARRAY-SIZE=10 VERT-DISTANCE=1MAX-OCCUR=100 PAGE-SIZE=9WHITE NON-DISPLAYPROTECTEDSYNCHRONIZED-ARRAYS=SET 1

116

Page 116: DATA BROWSER INTERFACE FOR THE COMPOSITE ...web.mit.edu/smadnick/www/wp2/1991-04.pdfChapter 2 - Architecture This chapter describes the architecture that was used to build the CIS

show ent.scrS:show ent.scr

LINES=15 COLUMNS=24 BACKGROUND=BLUE MENU-MODEBORDER=(WHITE) STYLE1ENTRY-FUNC=putents

DISPLAY(2,5) (WHITE)=Select Entity

F:# NUMBERS=1, 3, 5, 7, 9, 11, 13, 15, 17, 19

LINE=4 COLUMN=2# (5,2 6,2 7,2 8,2 9,2 10,2 11,2 12,2 13,2)

UNFILTEREDLENGTH=20 ARRAY-SIZE=10 VERT-DISTANCE=1MAX-OCCUR=100 PAGE-SIZE=9WHITEMENU-FIELDPROTECTED FROM DATA-ENTRY TABBING-INTO CLEARINGSYNCHRONIZED-ARRAYS=NONETEXT=%AO01.0%KXMIT/%KNL%A0007 Select option %A0010%KSPGU%A0007 Next

page\%A0010%KSPGD%A0007 Prev page %A0010%KEXIT%A0007 Prev menuVAL-FUNC=putatts 0 "(8,35)showatt.scr"

F:# NUMBERS=2, 4, 6, 8, 10, 12, 14, 16, 18, 20

LINE=4 COLUMN=23# (5,23 6,23 7,23 8,23 9,23 10,23 11,23 12,23 13,23)

UNFILTEREDLENGTH=1 ARRAY-SIZE=10 VERT-DISTANCE=1MAX-LENGTH=50 SHIFT-INCR=1WHITE NON-DISPLAYPROTECTED

117

Page 117: DATA BROWSER INTERFACE FOR THE COMPOSITE ...web.mit.edu/smadnick/www/wp2/1991-04.pdfChapter 2 - Architecture This chapter describes the architecture that was used to build the CIS

B.3 Miscellaneous Files

118

Page 118: DATA BROWSER INTERFACE FOR THE COMPOSITE ...web.mit.edu/smadnick/www/wp2/1991-04.pdfChapter 2 - Architecture This chapter describes the architecture that was used to build the CIS

B.3.2 Listing of Files

cistkconn.lsp;;; cisserver.lsp;;; written by: Tom Parker;;; date: April 1991

;;; Programs to interface with cisservers;;; functions:;;; getschema - prints the global schema;;; getquery - prints the results of a query

;;; function getschma;;; This function prints out the structure of the global schema.;;; It is based on programs written by Will Martinez SB '89

;;; Structure of the output file:;;; 1st line: Number of entities;;; 2nd line: Name of first entity;;; ATTRIBUTES:;;; 3rd line: Number of attributes in entity;;; 4th line: Name of first attribute in entity;;; RELATIONS:;;; 4+(value in 3rd line): Number of relations in entity;;; 5+(value in 3rd line): Name of first relation in entity;;; 6+(value in 3rd line): Name of related entity in first relation;;; This scheme repeats for each entity(defun getschema (ofile)(with-open-file(ostream ofile :direction :output)(let* ((entities (get-object 'entity 'instances))

(nb-entities (length entities)))(princ nb-entities ostream)(terpri o stream)(dolist (nthentity entities)

(princ nthentity o stream)(terpri o_stream)(let* ((atts (get-object nthentity 'Ilattributesl))

(nb-attributes (length atts)))(princ nb-attributes ostream)(terpri o_stream)(dolist (nthatts atts)

(princ nthatts ostream)(terpri o_stream)))

(let* ((rels (get-object nthentity 'Irelationsi))(nb-rels (length rels)))

(princ nb-rels ostream)(terpri o stream)(dolist

(nthrels rels)(princ nthrels ostream)(terpri oIstream)(if (equal nthentity

(get-object nthrels 'lentitytol))(progn

(princ (get-object nthrels 'lentity_froml) ostream)

119

Page 119: DATA BROWSER INTERFACE FOR THE COMPOSITE ...web.mit.edu/smadnick/www/wp2/1991-04.pdfChapter 2 - Architecture This chapter describes the architecture that was used to build the CIS

(terpri ostream))(progn

(princ (get-object nthrels 'lentitytol) ostream)(terpri ostream))

;;; function getquery;;; Function submits a query to the global query processor and returnsthe;;; results

(defun getquery (query ofile)(with-open-file

(o stream o file :direction :output)(setq result (gqp query))(print result o stream)

120

Page 120: DATA BROWSER INTERFACE FOR THE COMPOSITE ...web.mit.edu/smadnick/www/wp2/1991-04.pdfChapter 2 - Architecture This chapter describes the architecture that was used to build the CIS

dbserver.cfg# This file contains commands to send to IBCL on startup in order# to select the right version and get to the lisp prompt# Created by: Tom Parker# Date: 4/22/91

# The following does it for V3.0:# Select the version number1# Exit the main menu4# Exit to lisp2

# The following does is for V3.1:# Select the version number#2# Access remote databases - only works of user is "demo"#y# LQP manager#y# test query#y# exit configuration#9# exit configuration#11# exit to lisp2# load up the PAS schema#1

121

Page 121: DATA BROWSER INTERFACE FOR THE COMPOSITE ...web.mit.edu/smadnick/www/wp2/1991-04.pdfChapter 2 - Architecture This chapter describes the architecture that was used to build the CIS

Appendix C - File Formats

C.1 Global Schema Exchange File

Whenever a client process begins execution, a copy of the global schema ispassed from CIS/TK to CIS/DB. The copied schema is passed in a file with theformat shown below. The key words SCHEMA, ENTITY, ATTRIBUTES andRELATIONS do not actually appear in the file but are shown below in orderto demonstrate the hierarchy of the file.

SCHEMAline 1 Number of entities in the file

ENTITYline 1 - Entity name.line 2 - Number or attributes in the entity.

ATTRIBUTESline 1-line n- Name of attribute.

line 3 - Number of relations in the entity.

RELATIONSline 1 - (line 1 + 2n) - Name of relationline 2 - (line 2 + 2n) - Name of related entity.

The above sequence repeats for each entity in the schema.

C.2 Query Files

Query files are used to save a query so that it can be called up in a latersession. The file contains one line for each attribute that has been selected aspart of a query. An attribute is considered selected if it either is selected fordisplay or is part of a constraint on the query. Each line of the file has thefollowing format:

<ENTITY> <ATTRIBUTE> <1 if selected, otherwise 0> "<CONSTRAINT>"

C.3 Messages

As documented in Chapter 3, message queues are used by the Client andServer modules to communicate. It should be noted that message queues arenot used to actually exchange data. This is done with temporary files. Thequeue is used to communicate the name of the file in which the data is beingsent. Figure C-1 below shows the structure of a message that is sent through

122

Page 122: DATA BROWSER INTERFACE FOR THE COMPOSITE ...web.mit.edu/smadnick/www/wp2/1991-04.pdfChapter 2 - Architecture This chapter describes the architecture that was used to build the CIS

the queue. The To: field is the address of the process to which the message isbeing sent. It is either 1 for messages to the Server process, or the Unixprocess ID for messages to a Client process. This field allows each process toonly read messages that are addressed to it. The From: field is the address ofthe process that originated the message. The format is exactly the same as theTo: field.

The Command: field is used to determine what action should be taken as aresult of the message. Client processes send the commands, SIGNON torequest a copy of the global schema and QUERY to submit a query. TheServer process sends the command RESULT to indicate that it is returning aresult to a Client process.

The text field is used to send the name of the data file that is associated with amessage. This field is blank for the command SIGNON. It is the name of afile containing a GRL query for QUERY. Is the name of either the globalschema file (documented above) or the query result file for the commandRESULT. If there is an error in CIS/TK, this field contains the text ERRORinstead of a file name.

To:

From:

Command:

Text:

Figure C-1 Queue Message Structure

123