+ All Categories
Home > Documents > 05fd4Basic Concepts

05fd4Basic Concepts

Date post: 04-Jun-2018
Category:
Upload: vinay-sharma
View: 215 times
Download: 0 times
Share this document with a friend

of 69

Transcript
  • 8/13/2019 05fd4Basic Concepts

    1/69

    Basic Concepts

  • 8/13/2019 05fd4Basic Concepts

    2/69

    Rapid Application Development Tools

    and Technologies

    These tools and technologies include:

    Cach Studio: An integrated development environment that

    supports the object-oriented approach to designing andbuilding applications. With Studio you can define classes usingseveral languages including Cach ObjectScript, Cach Basic,and MVBasic.

    Cach Terminal: A command-line interface to the Cachdatabase. The Terminal allows you to open objects to executetheir methods and view their data. You can also execute anumber of commands and access a number of Cach utilitiesincluding the autopopulation utility.

  • 8/13/2019 05fd4Basic Concepts

    3/69

    Zen: A framework for creating dynamic, data intensive, and

    richly interactive Web pages. You can create Zen pages usingCach Studio.

    The System Management Portal: A browser-based interfacefor system management. Using the portal you can perform

    many tasks including defining, viewing, and accessing yourdata in a relational format. You can define your databasetables and query your data using standard SQL.

    Cach Studio, Cach Terminal, and the System ManagementPortal, can all be launched from the Cach Cube. Simply clickthe cube and then click a tool on the the menu.

  • 8/13/2019 05fd4Basic Concepts

    4/69

    Cach Cube

    The primary Cach interface on Microsoft Windows platforms

    is the Cach Cube.

    From the Cach Cube, you can start all of the Cach

    configuration and management tools.

    You can also invoke each Cube command from a shortcut or

    command line.

    When you click the Cach Cube, a menu appears with

    commands to use the Cach utilities and programming

    environments.

  • 8/13/2019 05fd4Basic Concepts

    5/69

    Cach Cube

    Getting Started Displays links to tutorials, release notes,documentation etc.

    Start Cach Starts the default instance specified in the square

    brackets after the menu item, for example [CACHE]. If the

    Cach server is already started, this option appears dimmed

    it is unavailable.

    Stop Cach Shuts down or restarts the local Cach instance. If

    the Cach server is stopped, this option appears dimmedit

    is unavailable.

    Studio -Creates, edits, deletes, and compiles Cach class

    definitions, CSP (Cach Server Pages) pages, Cach Basic

    routines, and Cach ObjectScript routines.

    Terminal Invokes the command line interpreter in the Cach

    programming environment.

  • 8/13/2019 05fd4Basic Concepts

    6/69

    Cache Cube

  • 8/13/2019 05fd4Basic Concepts

    7/69

    Cach Cube System Management Portal- Performs common system management

    tasks. Creates databases and namespaces, and adjusts all Cachconfiguration settings. Displays classes, globals, and routines, andfunctions for managing each. Displays tables and views, perform queriesand SQL management functions.

    Documentation-Displays Cach online documentation.

    DeepSee-Invokes the InterSystems DeepSee login page. See the Overviewof DeepSeeguide for more information.

    Preferred Server [server name] Shows a list of remote servers andmaintains server connections by using the Add/Edit command on the

    submenu. The preferred server appears in brackets and has a check marknext to it in the server list.

    AboutDisplays Cach version and build information.

    Exit Removes the Cach Cube icon from the system tray; this does notstop Cach. elated information

    http://localhost:57772/csp/docbook/DocBook.UI.Page.cls?KEY=DOV_prefacehttp://localhost:57772/csp/docbook/DocBook.UI.Page.cls?KEY=DOV_prefacehttp://localhost:57772/csp/docbook/DocBook.UI.Page.cls?KEY=DOV_prefacehttp://localhost:57772/csp/docbook/DocBook.UI.Page.cls?KEY=DOV_prefacehttp://localhost:57772/csp/docbook/DocBook.UI.Page.cls?KEY=DOV_prefacehttp://localhost:57772/csp/docbook/DocBook.UI.Page.cls?KEY=DOV_prefacehttp://localhost:57772/csp/docbook/DocBook.UI.Page.cls?KEY=DOV_prefacehttp://localhost:57772/csp/docbook/DocBook.UI.Page.cls?KEY=DOV_prefacehttp://localhost:57772/csp/docbook/DocBook.UI.Page.cls?KEY=DOV_preface
  • 8/13/2019 05fd4Basic Concepts

    8/69

    Namespace It refers to a logical entity that serves as a container for

    programs and data.

    a namespace allows you to collect objects from multiple

    databases into a single frame of reference so that they appear

    as if they were all stored together.

    Users need only make a simple reference to a global no

    matter where it resides

    namespace mapping specifies the globalsdatabase location.

  • 8/13/2019 05fd4Basic Concepts

    9/69

    Namespace Name

    A namespace name can be up 31 characters long using acombination of letters, numbers, and the characters %, &, and

    $.

    It must be unique within the dataset (same rules as for a localvariable).

    The use of namespace is not case-sensitive, that is, letters can

    be uppercase or lowercase.

    All namespaces are converted to uppercase internally.

  • 8/13/2019 05fd4Basic Concepts

    10/69

    Creating a Namespace

    [Namespaces] Name=a,b,c

    Only the first field is required. If the other fields are notspecified, they are set to the system default.

    From left to right: a: Default database name for globals.

    b: Default database name for routines and classes. Ifthe database is not specified, it defaults to the globals

    database. c: Default database name for temporary storage. If the

    database is not specified, it defaults to CACHETEMP

  • 8/13/2019 05fd4Basic Concepts

    11/69

    Datasets

    A logical entity that represents a directory

    name or directory and system name in Cach

  • 8/13/2019 05fd4Basic Concepts

    12/69

    Cach object modelThe Cach object model defines the behavior and features of both

    persistent (database) objects as well as transient objects (those notstored). The Cach object model supports the following features:

    PersistenceObjects can be stored within the Cach database orin an external database. Stored objects are simultaneouslyprojected as relational tables and can be queried using standard

    SQL. The object model is rich enough to define the complete information

    required for complex database applications, such as indices, storagestructure, integrity constraints, and so on.

    Properties Objects can contain both simple (literal) or object-valued properties. Object-valued properties can be references to

    external objects or embedded objects. There are also a variety ofrelationship, collection, and stream properties.

    Custom data types Objects can use application-specific datatypes which are themselves defined as classes.

  • 8/13/2019 05fd4Basic Concepts

    13/69

    Methods Objects have behavior associated withthem.

    PolymorphismApplications can easily adapt to newcircumstances by providing specializedimplementations of operations. The runtime systemautomatically invokes the correct implementation

    based on object type. InheritanceApplications can reuse code by deriving

    new components from pre-existing classes.

    Each class describes an entity, such as a person, a

    record, or an account. An object is a specific instance of a class. An object can

    exist on disk, in memory, or in a client application.

  • 8/13/2019 05fd4Basic Concepts

    14/69

    Cach Objects Architecture

    The class dictionary A repository of class definitions which isstored within a Cach database. The class dictionary is also used bythe Cach SQL engine and is responsible for maintainingsynchronized object and relational access to Cach data.

    The class compiler A set of programs that convert class

    definitions into executable code. The object runtime systemA set of features built into the Cach

    virtual machine that support object operations (such as objectinstantiation, method invocation, and polymorphism) within arunning program.

    The Cach class library A set of prebuilt classes that come withevery Cach installation. This includes classes that are used toprovide behaviors for user-defined classes (such as persistence ordata types) as well as classes that are intended for direct use withinapplications (such as email classes).

  • 8/13/2019 05fd4Basic Concepts

    15/69

    Every Cach namespace contains its own class dictionary whichdefines the available classes for that namespace.

    There is a special CACHELIBdatabase, installed as part of Cach,that contains the definitions and executable code for the classes ofthe Cach class library.

    These classes are referred to as system classes and all are part ofpackages whose names start with a % character, such as

    %Library.Persistent(the names ofmembers of the %Library packagecan be abbreviated, so that %String is an abbreviation for%Library.String).

    The class dictionary contains two distinct types of data:

    Definition data The actual class definitions that users create. Compilation data Data generated as a result of compiling class

    definitions is also stored.

    The class dictionary stores its data in a set of globals (persistentarrays) whose names start with ^odd.

    http://localhost:57772/csp/documatic/%CSP.Documatic.cls?APP=1&LIBRARY=%SYS&CLASSNAME=%Library.Persistenthttp://localhost:57772/csp/documatic/%CSP.Documatic.cls?APP=1&LIBRARY=%SYS&CLASSNAME=%Library.Persistenthttp://localhost:57772/csp/documatic/%CSP.Documatic.cls?APP=1&LIBRARY=%SYS&CLASSNAME=%Library.Stringhttp://localhost:57772/csp/documatic/%CSP.Documatic.cls?APP=1&LIBRARY=%SYS&CLASSNAME=%Library.Stringhttp://localhost:57772/csp/documatic/%CSP.Documatic.cls?APP=1&LIBRARY=%SYS&CLASSNAME=%Library.Stringhttp://localhost:57772/csp/documatic/%CSP.Documatic.cls?APP=1&LIBRARY=%SYS&CLASSNAME=%Library.Stringhttp://localhost:57772/csp/documatic/%CSP.Documatic.cls?APP=1&LIBRARY=%SYS&CLASSNAME=%Library.Stringhttp://localhost:57772/csp/documatic/%CSP.Documatic.cls?APP=1&LIBRARY=%SYS&CLASSNAME=%Library.Stringhttp://localhost:57772/csp/documatic/%CSP.Documatic.cls?APP=1&LIBRARY=%SYS&CLASSNAME=%Library.Stringhttp://localhost:57772/csp/documatic/%CSP.Documatic.cls?APP=1&LIBRARY=%SYS&CLASSNAME=%Library.Stringhttp://localhost:57772/csp/documatic/%CSP.Documatic.cls?APP=1&LIBRARY=%SYS&CLASSNAME=%Library.Stringhttp://localhost:57772/csp/documatic/%CSP.Documatic.cls?APP=1&LIBRARY=%SYS&CLASSNAME=%Library.Stringhttp://localhost:57772/csp/documatic/%CSP.Documatic.cls?APP=1&LIBRARY=%SYS&CLASSNAME=%Library.Persistenthttp://localhost:57772/csp/documatic/%CSP.Documatic.cls?APP=1&LIBRARY=%SYS&CLASSNAME=%Library.Persistenthttp://localhost:57772/csp/documatic/%CSP.Documatic.cls?APP=1&LIBRARY=%SYS&CLASSNAME=%Library.Persistenthttp://localhost:57772/csp/documatic/%CSP.Documatic.cls?APP=1&LIBRARY=%SYS&CLASSNAME=%Library.Persistent
  • 8/13/2019 05fd4Basic Concepts

    16/69

    Cach class library

    The Cach class library contains a set ofprebuilt classes.

    It is automatically installed with every Cach

    system within the CACHELIB database. You can view the contents of the Cach class

    library using the online class documentation

    system provided with Cach. The Cach class library contains a number of

    packages, each of which contains a family of

    classes.

  • 8/13/2019 05fd4Basic Concepts

    17/69

    Globals

    Cach stores its data in multidimensional

    sparse arrays, known as globals.

    A global is a named multidimensional array

    that is stored within a physical Cach

    database.

    Within an application, the mapping of globals

    to physical databases is based on the current

    namespace

  • 8/13/2019 05fd4Basic Concepts

    18/69

    There are two types of globals :

    An extended global referenceThis is a

    global located in a namespace other than the

    current namespace.

    A process-private globalThis is an array

    variable that is only accessible to the process

    that created it.

    http://localhost:57772/csp/docbook/DocBook.UI.Page.cls?KEY=GGBL_structurehttp://localhost:57772/csp/docbook/DocBook.UI.Page.cls?KEY=GCOS_variableshttp://localhost:57772/csp/docbook/DocBook.UI.Page.cls?KEY=GCOS_variableshttp://localhost:57772/csp/docbook/DocBook.UI.Page.cls?KEY=GCOS_variableshttp://localhost:57772/csp/docbook/DocBook.UI.Page.cls?KEY=GCOS_variableshttp://localhost:57772/csp/docbook/DocBook.UI.Page.cls?KEY=GGBL_structure
  • 8/13/2019 05fd4Basic Concepts

    19/69

    The naming conventions for globals are:

    A global name begins with a caret character (^) prefix. This

    caret distinguishes a global from a local variable. The first character after the caret (^) prefix in a global name

    can be: A letter or the percent character (%) .

    % globals are typically stored within either the %SYS or

    %CACHELIB databases. The other characters of a global name may be letters,

    numbers, or the period (.) character. The percent (%)

    character cannot be used, except as the first character of a

    global name. The period (.) character cannot be used as the

    last character of a global name.

    A global name may be up to 31 characters long (exclusive of

    the caret character prefix). You can specify global names that

    are significantly longer, but Cach treats only the first 31

    characters as significant.

  • 8/13/2019 05fd4Basic Concepts

    20/69

    Physical Structure of Globals

    Globals are stored within physical files using ahighly optimized structure.

    Globals are stored on disk within a series of datablocks; the size of each block (typically 8KB) isdetermined when the physical database iscreated.

    Cach maintains a sophisticated B-tree-likestructure that uses a set of pointer blocks to link

    together related data blocks. Within data blocks, globals are stored

    sequentially

  • 8/13/2019 05fd4Basic Concepts

    21/69

    Routines

    routine is the unit of execution in a Cach

    server.

    Routines are portable to all platforms

    supported by Cach and automatically

    shareable across a Cach environment

  • 8/13/2019 05fd4Basic Concepts

    22/69

    Create a Project

    First, create a new project named Phone Book to manage thesource files for the application, as follows:

    Start Cach Studio: Right-click the Cach cube and select Studio.

    Studio connects to the local Cach server using the namespaceused most recently by Studio (or the USER namespace if this is the

    first time Studio is connecting). If Studio is not connected to the namespace in which you want to

    work, connect to a different namespace using the File > ChangeNamespace.

    By default, Studio displays the Workspace window and creates anew project called Default_system. The Studio Workspace windowindicates the name of the current project as well as the serverconnection and namespace name. The Workspace window shouldbe displayed by default; if you don't see it, display it using the View> Workspace or with the Alt-3 keyboard accelerator.

  • 8/13/2019 05fd4Basic Concepts

    23/69

    To save the new project, use the File > Save

    Project As and enter Phone Book.

    You can save this project to the Cach server

    at any time using the File > Save Project.

  • 8/13/2019 05fd4Basic Concepts

    24/69

    Creating a class

    Defining a New Class

    You can define this new Person class using Studio's New Classwizard by following these steps:

    Start the New Class wizard by selecting File > New > General tab.

    Select Cach Class Definition and click OK.

    On the first page of the New Class wizard, enter a package name,PhoneBook, a class name, Person, and click Next.

    Select Persistent from the list of available class types and clickFinish.

    You see a Class Editor window containing the definition of your new

    class: Class PhoneBook.Person Extends %Persistent

    {

    }

  • 8/13/2019 05fd4Basic Concepts

    25/69

    Adding Properties

    Add the Name and PhoneNumber properties to thedefinition of the Person class with the New Property wizardas follows:

    Select Class > Add > New Property to start the NewProperty wizard.

    Enter a name for the new property, Name, and click Finish.

    Your class definition includes a property definition:

    Class PhoneBook.Person Extends %Persistent [ClassType=Persistent ]

    {Property Name As %String;

    }

  • 8/13/2019 05fd4Basic Concepts

    26/69

    Add a PhoneNumber property to the class definition in the sameway as you did the Name property by running the New Propertywizard again. You could have also added this new property bycopying, pasting, and modifying the Name property directly into theClass Editor window. Items are indented to structure the code toimprove readability. A plus/minus expansion box is provided to theleft of each item so that you can collapse sections of the code thatyou are not currently looking at.

    Class PhoneBook.Person Extends %Persistent [ClassType=Persistent]

    {

    Property Name As %String;Property PhoneNumber As %String;

    }

  • 8/13/2019 05fd4Basic Concepts

    27/69

    Saving and Compiling Your Class

    Save this class definition to the database and

    compile it into executable code with

    Build > Compile or click the Compile icon .

    You now have a PhoneBook.Person class

    defined in your database.

  • 8/13/2019 05fd4Basic Concepts

    28/69

    Viewing Documentation for Your Class

    View the automatically generated documentation for this class inthe Cach online class reference with View > Show ClassDocumentation. To enter descriptions for your class and propertiesso that they appear in the online documentation, you can enterdescriptions above class member declarations using /// (threeslashes) or you can do the following:

    Click the Class Inspector and view Class keywords (make the leftcolumn header of the inspector display the word Class)

    In the Inspector, double-click the keyword Description.

    This opens an editor in which you can enter a description for yourclass, such as the following:

    Click OK when you are finished.

    Save your class and view the documentation again.

  • 8/13/2019 05fd4Basic Concepts

    29/69

    Introduction to Management PortalThere are four types of users for the portal

    Security Manager -View and edit list of users,roles, and other security tasks.

    Manager-Change system configuration anddefine backup sets.

    Operator- View system status pages andperform backups.

    Explorer (public user)- View home page, view

    classes, routines, and globals, and use SQL pages,provided the user has access to the appropriateresources

    P t l Titl B

  • 8/13/2019 05fd4Basic Concepts

    30/69

    Portal Title Bar

    The left side of the title bar displays the following

    information: Page name displays the name of the current portal

    page

    Licensee displays the value of the Customer Name

    field in the cache.key file Beneath the InterSystems logo are the following links:

    Home brings you to the System Management Portal[Home]page

    About displays system overview information

    Help opens the online documentation at anappropriate topic

    http://localhost:57772/csp/sys/UtilHome.csphttp://localhost:57772/csp/docbook/DocBook.UI.Page.cls?KEY=GSA_using_portalhttp://localhost:57772/csp/docbook/DocBook.UI.Page.cls?KEY=GSA_using_portalhttp://localhost:57772/csp/sys/UtilHome.csp
  • 8/13/2019 05fd4Basic Concepts

    31/69

    Feedback opens the Feedback page, which allowsyou to report problems or make enhancement requests

    specific to the SMP Help opens the online documentation at an

    appropriate topic

    Logout brings you to the Login page of the portal

    The upper right corner of the title bar displays thefollowing information:

    Server name the name of the server running Cach

    Instance name the name of the Cach instancerunning on the server

    User name the name of the user logged into theportal

  • 8/13/2019 05fd4Basic Concepts

    32/69

    functional areas

    The portal is divided into three functional

    areas:

    System AdministrationSystem

    administration tasks

    Data ManagementDatabase management

    tasks

    OperationsSystem operation tasks

    http://localhost:57772/csp/docbook/DocBook.UI.Page.cls?KEY=GSA_using_portalhttp://localhost:57772/csp/docbook/DocBook.UI.Page.cls?KEY=GSA_using_portalhttp://localhost:57772/csp/docbook/DocBook.UI.Page.cls?KEY=GSA_using_portalhttp://localhost:57772/csp/docbook/DocBook.UI.Page.cls?KEY=GSA_using_portalhttp://localhost:57772/csp/docbook/DocBook.UI.Page.cls?KEY=GSA_using_portalhttp://localhost:57772/csp/docbook/DocBook.UI.Page.cls?KEY=GSA_using_portal
  • 8/13/2019 05fd4Basic Concepts

    33/69

    Introduction to Management Portal

    System Administration Menu

    Configuration

    Security Management

    Licencing

    Database Encryption

    C fi ti

  • 8/13/2019 05fd4Basic Concepts

    34/69

    Configuration

    Cach configuration is composed of system

    configuration information, namespaces,

    databases, operator task configurations,

    network connections, and other advanced

    settings.

  • 8/13/2019 05fd4Basic Concepts

    35/69

    Memory and Startup Settings

    You can choose whether to configure memory

    automatically or manually. If you choose Automatically, the system allocates the

    amount of memory best suited to Cach given the availablememory.

    If you choose Manually, you can specify how global buffer

    pool memory is allocated: Memory allocated for Routine Cache (MB) System memory

    allocated and used for caching server code.

    Memory allocated for 2KB Database Cache (MB) Systemmemory allocated and used for buffering data for legacy 2KBdatabases.

    Memory allocated for 8KB Database Cache (MB) Systemmemory allocated and used for buffering data for 8KB databases

    See the Memory Configurationsection for details.

    http://localhost:57772/csp/docbook/DocBook.UI.Page.cls?KEY=GSA_confighttp://localhost:57772/csp/docbook/DocBook.UI.Page.cls?KEY=GSA_config
  • 8/13/2019 05fd4Basic Concepts

    36/69

    You can set your Cach instance to start

    automatically when the system starts by selecting

    the Auto-start on System Boot check box.

    If you select the Enable Long Strings check box,

    Cach allocates a large string stack to handle long

    strings for each process. You can change the Superserver Port Number

    (TCP port used to accept incoming client

    requests) for this Cach instance. Click Save to save your modifications; restart

    Cach to activate them.

  • 8/13/2019 05fd4Basic Concepts

    37/69

    Namespaces

    Cach comes with the following predefined

    namespaces:

    %SYS System management information and

    utilities.

    DOCBOOK Documentation.

    SAMPLES Sample code and applications.

    USER Empty at installation. Typically used

    for application development

  • 8/13/2019 05fd4Basic Concepts

    38/69

    Perform the following procedures for

    configuring namespaces

    Create a Namespace

    Modify Default Database Mapping

    Add Global, Routine, and Package Mapping to

    a Namespace

    Delete a Namespace

    http://localhost:57772/csp/docbook/DocBook.UI.Page.cls?KEY=GSA_confighttp://localhost:57772/csp/docbook/DocBook.UI.Page.cls?KEY=GSA_confighttp://localhost:57772/csp/docbook/DocBook.UI.Page.cls?KEY=GSA_confighttp://localhost:57772/csp/docbook/DocBook.UI.Page.cls?KEY=GSA_confighttp://localhost:57772/csp/docbook/DocBook.UI.Page.cls?KEY=GSA_confighttp://localhost:57772/csp/docbook/DocBook.UI.Page.cls?KEY=GSA_confighttp://localhost:57772/csp/docbook/DocBook.UI.Page.cls?KEY=GSA_confighttp://localhost:57772/csp/docbook/DocBook.UI.Page.cls?KEY=GSA_confighttp://localhost:57772/csp/docbook/DocBook.UI.Page.cls?KEY=GSA_confighttp://localhost:57772/csp/docbook/DocBook.UI.Page.cls?KEY=GSA_config
  • 8/13/2019 05fd4Basic Concepts

    39/69

    Create New Namespace Enter a Name for the namespace.

    Do not specify the following reserved system names:BIN, BROKER, DOCBOOK, DOCUMATIC, SYS.

    Select an existing database for the default mapping ofthis namespace, or click Create New Database

    Select the Create a default CSP application for thisnamespace check box if you are creating a CSPapplication that accesses this namespace.

    You can also Copy namespace mappings from anexisting namespace.

    After entering the required information, click Save toadd your namespace to the configuration

  • 8/13/2019 05fd4Basic Concepts

    40/69

    Modify Default Database Mapping You can change the database to which your

    namespace is mapped without restarting Cach: Navigate to the [Home] > [Configuration] >

    [Namespaces]page to see a list of definednamespaces.

    Click Edit in the row of the namespace you wishto modify.

    Choose the Default Database for Globals, the

    Default Database for Routines, and the DefaultDatabase for Temporary Storage from the list ofdefined databases.

    Click Save

    http://localhost:57772/csp/sys/mgr/UtilSysNamespaces.csphttp://localhost:57772/csp/sys/mgr/UtilSysNamespaces.csphttp://localhost:57772/csp/sys/mgr/UtilSysNamespaces.csphttp://localhost:57772/csp/sys/mgr/UtilSysNamespaces.csp
  • 8/13/2019 05fd4Basic Concepts

    41/69

    In addition to having access to the globals and routinesin the mapped database, you can also map globals,routines, and class packages from other databases onthe same or different systems. This allows simplereferences to data which can exist anywhere and is theprimary feature of a namespace.

    Click the appropriate choice to begin mapping:

    Global Mappings

    Routine Mappings

    Package Mappings

    Mapping Data to All Namespaces

    http://localhost:57772/csp/docbook/DocBook.UI.Page.cls?KEY=GSA_confighttp://localhost:57772/csp/docbook/DocBook.UI.Page.cls?KEY=GSA_confighttp://localhost:57772/csp/docbook/DocBook.UI.Page.cls?KEY=GSA_confighttp://localhost:57772/csp/docbook/DocBook.UI.Page.cls?KEY=GSA_confighttp://localhost:57772/csp/docbook/DocBook.UI.Page.cls?KEY=GSA_confighttp://localhost:57772/csp/docbook/DocBook.UI.Page.cls?KEY=GSA_confighttp://localhost:57772/csp/docbook/DocBook.UI.Page.cls?KEY=GSA_confighttp://localhost:57772/csp/docbook/DocBook.UI.Page.cls?KEY=GSA_config
  • 8/13/2019 05fd4Basic Concepts

    42/69

    Sample Namespace Mapping

    Data and programs are stored in Cach

    databases, the physical storage locations, and

    referred to by namespaces, the logical

    references.

  • 8/13/2019 05fd4Basic Concepts

    43/69

    Delete a Namespace

    You can delete a namespace, including allmappings associated with it:

    Navigate to the [Home] > [Configuration] >

    [Namespaces]page, and click Delete in the row ofthe namespace you want to delete.

    On the Delete Namespaces page, if you want todelete the CSP pages from the physical path,

    select the check box. To delete the namespace and associated

    mappings, click Perform Action Now.

    http://localhost:57772/csp/sys/mgr/UtilSysNamespaces.csphttp://localhost:57772/csp/sys/mgr/UtilSysNamespaces.csphttp://localhost:57772/csp/sys/mgr/UtilSysNamespaces.csphttp://localhost:57772/csp/sys/mgr/UtilSysNamespaces.csp
  • 8/13/2019 05fd4Basic Concepts

    44/69

    Configuring Databases

    A database is a cache.dat file you create using the Database

    Wizard. A Cach database holds data in multidimensional arrays

    called globals and executable content called routines, aswell as class and table definitions.

    Globals and routines encompass such things as methods,

    classes, Web pages (CSP and HTML), SQL, BASIC, andJavaScript files.

    Cach databases dynamically expand as needed, thoughyou can set a maximum limit.

    Cach automatically mounts the databases, which can grow

    to be 32 terabytes. Cach provides wizards for both local and remote database

    creation

  • 8/13/2019 05fd4Basic Concepts

    45/69

    Journal

    Each instance of Cach keeps a journal.

    The journal is a set of files that keeps a time-sequenced log of changes that have been

    made to the databases since the last backup. Cach transaction processingworks with

    journaling to maintain the logical integrity ofdata.

    Backups and journaling are daily operationsthat allow you to recreate your database

    http://localhost:57772/csp/docbook/DocBook.UI.Page.cls?KEY=GCOS_tphttp://localhost:57772/csp/docbook/DocBook.UI.Page.cls?KEY=GCOS_tp
  • 8/13/2019 05fd4Basic Concepts

    46/69

    Class Type

    Class MyApp.MyClass [ClassType = persistent] {}

    datatype the class is a datatype class used to represent a literalvalue.

    persistent the class represents data to be stored within the

    database. serial the class represents data to be stored (in its serialized

    state) within another persistent object.

    stream the class represents streaming data.

    view the class is used to define an SQL view (see the ViewQuery

    keyword). An empty string, which indicates that this class has no specific type.

    Simple registered objects as well as abstract classes typically do notspecify a class type.

    http://localhost:57772/csp/docbook/DocBook.UI.Page.cls?KEY=ROBJ_class_viewqueryhttp://localhost:57772/csp/docbook/DocBook.UI.Page.cls?KEY=ROBJ_class_viewquery
  • 8/13/2019 05fd4Basic Concepts

    47/69

    Specifies how this class is to be used. The class

    compiler uses the ClassType keyword to

    determine how to compile a class. For

    example, if ClassType is persistent, the classcompiler additionally invokes the storage

    compiler to generate persistence code for a

    class. Unless explicitly defined, the value ofClassType is either the default value (NULL) or

    it is inherited from the primary superclass.

  • 8/13/2019 05fd4Basic Concepts

    48/69

    Types of Classes

    Classes are divided into data type classes and

    object classes.

    Data type classes represent literal values such

    as strings, integers, and dates

    Data type classes are used to create literal

    properties of other objects. They do not have

    properties and cannot be instantiated

  • 8/13/2019 05fd4Basic Concepts

    49/69

    Object classes

    Object classes may have properties and can be

    instantiated.

    Object classes are further divided, according

    to their database behavior, into transientobjects, persistent objects, and serial objects.

    A transient object (derived directly from the

    %RegisteredObjectclass) has no storagebehavior; it exists only in memory.

    http://localhost:57772/csp/documatic/%CSP.Documatic.cls?APP=1&LIBRARY=%SYS&CLASSNAME=%Library.RegisteredObjecthttp://localhost:57772/csp/documatic/%CSP.Documatic.cls?APP=1&LIBRARY=%SYS&CLASSNAME=%Library.RegisteredObjecthttp://localhost:57772/csp/documatic/%CSP.Documatic.cls?APP=1&LIBRARY=%SYS&CLASSNAME=%Library.RegisteredObject
  • 8/13/2019 05fd4Basic Concepts

    50/69

    Instantiations of classes derived from

    %RegisteredObjectare known as registered or

    transient objects.

    These objects have a full set of built-inmethods for controlling their in-memory

    behavior.

    P i t t Obj t Cl

    http://localhost:57772/csp/documatic/%CSP.Documatic.cls?APP=1&LIBRARY=%SYS&CLASSNAME=%Library.RegisteredObjecthttp://localhost:57772/csp/documatic/%CSP.Documatic.cls?APP=1&LIBRARY=%SYS&CLASSNAME=%Library.RegisteredObjecthttp://localhost:57772/csp/documatic/%CSP.Documatic.cls?APP=1&LIBRARY=%SYS&CLASSNAME=%Library.RegisteredObject
  • 8/13/2019 05fd4Basic Concepts

    51/69

    Persistent Object Classes

    Instantiations of classes derived from %Persistentareknown as persistent objects

    these objects are registered objects that inherit fromthe %Persistentclass.

    Persistent objects have the ability to store themselvesinto the database.

    lazy loading : Loading a persistent object into memoryfrom the database does not load any other objects that

    it refers to. As soon as a referenced object is referredto, however, it is automatically brought into memory;this is known as swizzlingor lazy loading .

    http://localhost:57772/csp/documatic/%CSP.Documatic.cls?APP=1&LIBRARY=%SYS&CLASSNAME=%Library.Persistenthttp://localhost:57772/csp/documatic/%CSP.Documatic.cls?APP=1&LIBRARY=%SYS&CLASSNAME=%Library.Persistenthttp://localhost:57772/csp/documatic/%CSP.Documatic.cls?APP=1&LIBRARY=%SYS&CLASSNAME=%Library.Persistenthttp://localhost:57772/csp/documatic/%CSP.Documatic.cls?APP=1&LIBRARY=%SYS&CLASSNAME=%Library.Persistent
  • 8/13/2019 05fd4Basic Concepts

    52/69

    Serial Object Classes

    Instantiations of classes derived from%SerialObjectare known as serial orembeddableobjects

    these objects are registered objects thatinherit from the %SerialObjectclass.

    These objects can exist independently inmemory, but, when stored to the database,can only exist as embedded within a persistentobject.

    http://localhost:57772/csp/documatic/%CSP.Documatic.cls?APP=1&LIBRARY=%SYS&CLASSNAME=%Library.SerialObjecthttp://localhost:57772/csp/documatic/%CSP.Documatic.cls?APP=1&LIBRARY=%SYS&CLASSNAME=%Library.SerialObjecthttp://localhost:57772/csp/documatic/%CSP.Documatic.cls?APP=1&LIBRARY=%SYS&CLASSNAME=%Library.SerialObjecthttp://localhost:57772/csp/documatic/%CSP.Documatic.cls?APP=1&LIBRARY=%SYS&CLASSNAME=%Library.SerialObjecthttp://localhost:57772/csp/documatic/%CSP.Documatic.cls?APP=1&LIBRARY=%SYS&CLASSNAME=%Library.SerialObjecthttp://localhost:57772/csp/documatic/%CSP.Documatic.cls?APP=1&LIBRARY=%SYS&CLASSNAME=%Library.SerialObject
  • 8/13/2019 05fd4Basic Concepts

    53/69

    Embedded objects

    Embedded objects have different in-memory and on-disk representations.

    In memory, an embedded object is represented as aseparate object. The in-memory value of an embedded

    object attribute is an OREF that refers to the objectsin-memory representation.

    On disk, an embedded object property is stored as partof its containing object. A serial object has no separateidentity (OID) and cannot be referred to by other

    objects. The values of the embedded objectsproperties are serialized and stored along with all ofthe other object attributes.

  • 8/13/2019 05fd4Basic Concepts

    54/69

  • 8/13/2019 05fd4Basic Concepts

    55/69

    Address class

    Class MyApp.Address Extends %SerialObject

    {

    Property Street As %String(MAXLEN=80); Property

    City As %String(MINLEN=3);Property State As %String(MINLEN=2);

    }

    Once defined, the Address class can be used as anembedded object attribute for a persistent objectclass such as Patient:

  • 8/13/2019 05fd4Basic Concepts

    56/69

    Class MyApp.Patient Extends %Persistent

    {

    Property Name As %String;

    Property Home As Address;

    }

    D t T Cl

  • 8/13/2019 05fd4Basic Concepts

    57/69

    Data Type Classes

    Data type classes define and control literal values. Unlike object classes, data types do not have any

    independent identity and can never be explicitly

    instantiated.

    Instead, they exist only as properties of the

    objects that contain them.

    Data type classes cannot contain properties.

    A data type is a class with its ClassType keyword

    set to datatype.

    Class Type Page

  • 8/13/2019 05fd4Basic Concepts

    58/69

    Class Type Page

    The New Class wizard asks you what type of class you

    would like to create. You can either extend (inheritfrom) a previously defined class or create a new classby selecting one of the following options:

    Persistent- Create a definition for a persistent class.Persistent objects can be stored in the database.

    Serial-Create a definition for a serial class. Serialobjects can be embedded in persistent objects tocreate complex data types such as addresses.

    Registered-Create a definition for a registered class.

    Registered objects are not stored in the database. Abstract-Create a definition for an abstract class with

    no superclass.

  • 8/13/2019 05fd4Basic Concepts

    59/69

    Datatype-Create a definition for a data type class.A data type class is used to create user-defined

    data types. CSP(used to process HTTP events)-Create a

    definition for a %CSP.Pageclass. A CSP class isused to create a CSP event handling class. This is

    a programmatic way to create CSP Pages or torespond to HTTP events (for example, to createan XML server).

    Extends-Extend an existing class: check Extendsand enter (or choose from a list) the name of anexisting superclass.

    If you are creating a new persistent or serial class the New

    http://localhost:57772/csp/documatic/%CSP.Documatic.cls?APP=1&LIBRARY=%SYS&CLASSNAME=%CSP.Pagehttp://localhost:57772/csp/documatic/%CSP.Documatic.cls?APP=1&LIBRARY=%SYS&CLASSNAME=%CSP.Pagehttp://localhost:57772/csp/documatic/%CSP.Documatic.cls?APP=1&LIBRARY=%SYS&CLASSNAME=%CSP.Page
  • 8/13/2019 05fd4Basic Concepts

    60/69

    If you are creating a new persistent or serial class, the NewClass wizard prompts for certain items particular topersistent or serial classes. These include:

    Owner- (optional) For a persistent class, enter the SQL user

    name to be the owner of the new class. This user namecontrols privileges when this class is used via SQL. If thisfield is left blank, then the default owner, _system, is used.

    SQL Table Name-(optional) For a persistent class, enter aname to be used for the SQL table that corresponds to this

    class. If this field is left blank, then the SQL table name isidentical to the class name. If the class name is not a validSQL identifier, you must enter an SQL table name here.

    XML Enabled-(optional) If selected, the class is XML-enabled; that is, it has the ability to project itself as an XML

    document. It can also be used in Web Service methods.This is equivalent to adding the %XML.Adaptorclass to theclass' superclass list.

    http://localhost:57772/csp/documatic/%CSP.Documatic.cls?APP=1&LIBRARY=%SYS&CLASSNAME=%XML.Adaptorhttp://localhost:57772/csp/documatic/%CSP.Documatic.cls?APP=1&LIBRARY=%SYS&CLASSNAME=%XML.Adaptorhttp://localhost:57772/csp/documatic/%CSP.Documatic.cls?APP=1&LIBRARY=%SYS&CLASSNAME=%XML.Adaptorhttp://localhost:57772/csp/documatic/%CSP.Documatic.cls?APP=1&LIBRARY=%SYS&CLASSNAME=%XML.Adaptor
  • 8/13/2019 05fd4Basic Concepts

    61/69

    Zen DataModel-(optional) If checked, the classincludes extends %ZEN.DataModel.Adaptor.

    Data Population-(optional) If you select this option,your new class supports automatic data population.This is equivalent to adding the %Library.Populateclass

    to the class' superclass list. Automatic data population allows you to easily create

    random data with which you can test the operation ofyour class. To populate a class, compile it and then

    execute the class' Populate method (inherited from the%Library.Populateclass). For example, using the Cachterminal:Do ##class(MyApp.Person).Populate(100)

    http://localhost:57772/csp/documatic/%CSP.Documatic.cls?APP=1&LIBRARY=%SYS&CLASSNAME=%Library.Populatehttp://localhost:57772/csp/documatic/%CSP.Documatic.cls?APP=1&LIBRARY=%SYS&CLASSNAME=%Library.Populatehttp://localhost:57772/csp/documatic/%CSP.Documatic.cls?APP=1&LIBRARY=%SYS&CLASSNAME=%Library.Populatehttp://localhost:57772/csp/documatic/%CSP.Documatic.cls?APP=1&LIBRARY=%SYS&CLASSNAME=%Library.Populatehttp://localhost:57772/csp/documatic/%CSP.Documatic.cls?APP=1&LIBRARY=%SYS&CLASSNAME=%Library.Populatehttp://localhost:57772/csp/documatic/%CSP.Documatic.cls?APP=1&LIBRARY=%SYS&CLASSNAME=%Library.Populate
  • 8/13/2019 05fd4Basic Concepts

    62/69

    If you are creating a new CSP class, the New

    Class wizard prompts for the following value:

    Content Type-Specifies what the content type

    served by this CSP class is. The availableoptions are HTML or XML. This option is used

    to set the value of the CONTENTTYPE

    parameter of the new class to text/html ortext/xml respectively.

    Adding Properties to a Class

  • 8/13/2019 05fd4Basic Concepts

    63/69

    Adding Properties to a Class

    You can add a new property to a class in two

    ways:

    Adding the property to the class definition in

    the Class Editor.

    Using the New Property wizard

  • 8/13/2019 05fd4Basic Concepts

    64/69

    Using Class Editor

    position the cursor on a blank line in the Class

    Editor and enter a property declaration:

    Class MyApp.Person Extends %Persistent

    [ClassType = persistent]

    {

    Property Name As %String;

    Property Title As %String;

    }

    Using New Property Wizard

  • 8/13/2019 05fd4Basic Concepts

    65/69

    Using New Property Wizard

    To open the New Property wizard, select Class> Add > New Property . Alternatively, right-click the Class Inspector and select Add > NewProperty or, if only properties are displayed

    (Property heads the left column), right-clickand select New Property or select the NewProperty icon, from the toolbar.

    Students task: Explore Adding properties to aclass

  • 8/13/2019 05fd4Basic Concepts

    66/69

    Class Compilation

    Cach class definitions are compiled into applicationroutines by the Cach class compiler.

    Classes cannot be used in an application before theyare compiled.

    The Cach class compiler differs from the compilersavailable with other programming languages, such asC++ or Java, in two significant ways:

    first, the results of compilation are placed into a shared

    repository (database), not a file system. Second, it automatically provides support for

    persistent classes.

  • 8/13/2019 05fd4Basic Concepts

    67/69

    class compiler does the following: It generates a list of dependencies Depending on the compile options

    used, any dependencies that have been modified since last beingcompiled will also be compiled.

    It resolves inheritance it determines which methods, properties, andother class members are inherited from superclasses. It stores thisinheritance information into the class dictionary for later reference.

    For persistent and serial classes, it determines the storage structureneeded to store objects in the database and creates the necessaryruntime information needed for the SQL representation of the class.

    It executes any method generatorsdefined (or inherited) by the class.

    It creates one or more routines that contain the runtime code for theclass. The class compiler groups methods according to language (CachObjectScript and Basic) and generates separate routines, each containingmethods of one language or the other.

    It compiles all of the generated routines into executable code.

    It creates a class descriptor. This is a special data structure (stored as aroutine) that contains all the runtime dispatch information needed tosupport a class (names of properties, locations of methods, and so on).

    http://localhost:57772/csp/docbook/DocBook.UI.Page.cls?KEY=GOBJ_methodgenhttp://localhost:57772/csp/docbook/DocBook.UI.Page.cls?KEY=GOBJ_methodgen
  • 8/13/2019 05fd4Basic Concepts

    68/69

    Class Compilation

    several ways to invoke the class compiler:

    From within Cach Studio using the option in

    the Build menu.

    From the Cach command line (in the Cach

    Terminal) using the Compile method of the

    %SYSTEM.OBJobject:

    Do $System.OBJ.Compile("MyApp.MyClass")

    Unified Data Architecture

    http://localhost:57772/csp/documatic/%CSP.Documatic.cls?APP=1&LIBRARY=%SYS&CLASSNAME=%SYSTEM.OBJhttp://localhost:57772/csp/documatic/%CSP.Documatic.cls?APP=1&LIBRARY=%SYS&CLASSNAME=%SYSTEM.OBJ
  • 8/13/2019 05fd4Basic Concepts

    69/69

    This table summarizes the mapping between the basic

    object-oriented features of Cach Objects and therelational features of SQL Tables.

    Unified Data Architecture

    Cach Objects SQL Tables

    Package Schema Class Table

    Object Instance Table Row

    Property Table Column

    Method Stored Procedure Relationship Foreign Key

    Embedded Object Column Subset


Recommended