• Home
  • News
  • Software
  • Articles / Guides
  • Forums
  • Links
  • ...back
    Category:

    Technical Information 15 Apr 2008

    InfoStore Architecture:

    InfoStore was designed to be easy to use and configure while retaining unparalleled flexibility in terms of what data / processes it can support. The data infrastructure is a highly versatile, XML based environment, no databases needed. For speed, Infostore uses a multilayered caching mechanism, and the search mechansim is implemented usign Apache Lucene.

    System Requirements:

    To run Infostore, you will need nothing but a machine with a JDK installed (version J2SE5 or higher). everything else is packaged right into the system. The main process needs about 40MB of RAM, but might grow a bit over time due to caching. The reference platforms it runs on are Linux (Ubuntu is the test platform) and Windows XP. However, I see no reason why it would not work on other platforms.

    The InfoStore Item concept

    InfoStore tries to be very effective in storing user-entered data. For example, if you enter a new "Person" into the system, you will be presented different fields, for example a name, age, postal adress etc. InfoStore stores the data the user entered in a Data Item iwth a unique ID after it has been created.

    But how does the system even know about what a "Person" is? This is where a Template comes into place.

    Any Data Item in the system is configured by a Template, which stores additional information about the Data item. In our example, the "Person" template stores information that is common to all "Person"-Data Items. Now - what is this information ?

    In its simplest, the Template defines the list of fields that can be entered for the information type "Person". For each individual field that you elect to add to your information type "Person", you can configure the following:

    • Data Type: You can choose what kind of data are allowed to go into the field. Example:  only allow a numeric value into the age field
    • Form Type: You can select how the data should be editable by the user. Example: the Age field should be a simple text entry form field, the postal adress should be a text area.
    • Display Type: Select how you want the data to be displayed. Example: Make the email adress of the Person clickable to write email to him directly, by using the "email" display type.

    There is much more to templates than this still, here are some more things the system can do for you:

    • Prepopulate fields at Item creation time using the InfoStore Formula System
    • Populate calculated fields at Runtime (everytime someone accesses the Data Item) using the InfoStore Formula system
    • Restrict Access to Data Items using this template using the InfoStore Access Groups
    • Run custom Script code whenever an item is created or changed
    • Organize how to display your Data using InfoStore Views (the horizontal tabs displayed at the top of Data Items.) 

    InfoStore provides the following Data Types:

    Data Type Identifier Data Type Description
    text The simplest of all data types. Allows arbitrary input, no filtering or restriction is placed on the user. Use this data type for all the fields that should be freely enterable by the user
    title

    This is a special data type that needs to be set for the prefilled "title" field that exists for any InfoStore Data Item. The title field is neccessary for infoStore, as it is used to refer to an Item in Searches, and for display and linking. Other fields do not need to use this data type

    id Stores only valid InfoStore IDs. A valid InfoStore ID is any existing Data Item's ID, as can be seen at the top of every Data Item. You can use this field to store lists of Data Items that are of interest to your Data Item, for example a list of related Articles.
    number
    A valid numeric value only. Can be a floating opint, positive, or negative number.
    email
    A valid email adress only.
    login
    A valid Infostore login name only
    date
    A date value in the form of DD.MM.YYYY only
    formula
    Flag this field as a formula. This means that no value can actually be written into the field, as its value is dynamically calculated by a formula. See the formula system reference for details.
    file
    You can use this Data Type to allow the user to upload binaryx files into this field. Note that you will also have to set the Form Type to "file" , so the user can upload things in the form.

    Form Types are used by InfoStore to determine how and if a field is made available to the user for editing. The following form types are available:

    Form Type Identifier  Form Type Description
    textfield  A simple single line text field for textual input
    textarea
     A Multiline textfield (standard mode is text only, but if Display Type HTML is set, this textfield is converted into a WYSIWYG editor)
    bigtextarea
     A bigger Multline textfield (standard mode is text only, but if Display Type HTML is set, this textfield is converted into a WYSIWYG editor)
    dropdown
    Allows you to create a dropdown for this value, in order to let the user only pick certain values from a selection you provide. To fill the dropdown with values, please use the little edit icon next to the form type box that appears once you select "dropdown"
    datepicker
    Only really useful for fields with datatype "date". Provides a convienient Date picker to enter correctly formatted dates.
    radio
    not currently supported. Please do not use.
    checkbox
    not currently supported. Please do not use.
    file
    Provides a file upload / update / deletion mechanism in the form.  Only useful for datatype "file"
    password
    provides a text entry field, but hides the typed in value (only stars are displayed)
    fixed
    does show the entered value in the form, but does not allow for editing the value.
    hidden
    hides the value entirely from the form (useful for formulas)

    InfoStore Scripting / Formula System

    InfoStore uses the Formula system for three different purposes:

    •  Prefill data in newly created Data Items (for example, you can instruct the system, to automatically put the item creator name into the "createdby" field)
    • Dynamically calculate fields everytime the Data Item is displayed (for example, if you have a Project that contains tasks, you can get the number of total tasks)
    • Use a Formula for filtering items out of views. (Example: only show items that are not resolved)

    Here are some basic examples of the formula system, with an explanation for each of them:

    (1+2)*3

    Calculates the result and outputs the value 9

    "Task is $resolved % resolved"

    Gets whatever value is currently stored in this Data Item in the "resolved" field, and puts it into the return string. For example, if the resolved field is set to "90", it outputs this string:  Task is 90 % resolved

    if($age>40,"You are getting old...","You are still too young to be a Jedi master...")

    Pulls the value contained in the "age" field in the current Data Item, and compares it to the number 40. If its more, it will return You are getting old... , otherwise You are still too young to be a Jedi master...

    "Your average Team age is " + str(avg($child:age)) + " years"

    A bit more complex.  Lets split it into explanation chunks: First it takes the first String, and adds (+ sign ) the formula behind to it, and then it adds again the last string. Now lets cover this section:

    $child:age

    This function pulls the value fo the field "child" from the current item. In our example, this field contains a list of InfoStore Item IDs. the ":" operator now instructs the formula system to pull the value of the "age" field from ALL the Item IDs in the "child" field, and return a list of those "age" values as a comma separated list. So, if for example, the Data Item has three IDs in "child", and each of those Data items has an age set, the result would be

    30,40,50

    so now the formula would look like this:

    str(avg(30,40,50))

    the avg function takes all the numbers and gets the average value of them all, resulting in

    str(40)

    Finally, the str function converts the number into a string value that can be appended to other strings. So the final result of this formula would be:

    Your average Team age is 40 years

    Allowed Syntax rules:

    • If a formula cannot be evaluated due to Syntax error, it will be returned as the field content. For example:

     

    ((((((1+2)*3

     

    is missing several closing brackets, therefore is invalid.

    The system will return this as the formula value: ((((((1+2)*3

    • Any valid arithmetic formula (see allowed arithmetic tokens below) is allowed, no matter how complex. Examples:

     

    (1+2)*3

     

     

    (100*(100+12)/(45-2)*5+4)

     

    • A formula may be spread across multiple lines to ease readbility. Example:

    if($age>40,

    "You are a young jedi",

    "You are a Jedi master"

    )

     

    is the same as

    if($age>40,"You are a young jedi","You are a Jedi master")

    • You can initialize and use variables using statements. A statement is identified by having a ";" at the end. The result of your formula must always be calculated as the last line and must NOT include a statement identifier (";"). Example:

     

    myage=$age;

     

    isold = if(myage>40,"old","young");

     

    myname=$name;

     

     

    "Welcome, " + myname + " -- you are " + isold + "..."

    would return (if $name=Emanuel and $age=30):

    Welcome, Emanuel -- you are young...


    • InfoStore data (designated by leading "$" character) can be directly embedded into Strings.

     

    "Your age is $age years"

     

    will translate to e.g. Your age is 35 years


    • Other functions cannot be embedded into strings. For Example
    "My Team's average age is avg($child:age)"

     

    will fail to evaluate. it will return (assume $child:age returns "20,30,40" ) this:

    My Team's average age is avg(20,30,40)

    to make this formula work, you need to isolate the function like so:

    "My Team's average age is " + str(avg($child:age))

     

    InfoStore Data Discovery Functions:

    Code Description
    Example formula Example output
    $fieldname
    returns the value of the internal fieldname (as entered into the template) for the current Data Item (the one the formula operates on)
    $email emanuel@host.de
    $$fieldname
    returns the rendered representation of the of the internal fieldname's value (as entered into the template) for the current Data Item (the one the formula operates on) $$email emanuel@host.de
    $number:fieldname
    returns the value of the internal fieldname (as entered into the template) for the Data item in number $3589:title
    Projects
    $$number:fieldname
    returns the rendered representation of the value of the internal fieldname (as entered into the template) for the Data item in number $$3589:title
    Projects EditRemove (ID:3589)
    $[number:]fieldname1:fieldname2
    gets the value of fieldname1 in the current Data Item context,and IF the fieldname represents a list of InfoStore IDs, it fetches the values in fieldname2 for each of the IDs. Otherwise, an error is thrown.
    $2:child:title

    Projects,
    InfoStore Configuration,
    Emanuels testlab

    $child~50000:title gets all children of the current item, IF they are of Template ID 50000 . This is usually used when you have multiple child types under the current item, and you are only interested in one of the types. $child~5000:title foo,bar

    Mathematical Operators:

    Logical Operators

    || (logical OR)
    && (logical AND)
    ! (not)

    Arithmetic Operators

    + (addition)
    - (subtraction)
    * (multipilcation)
    / (division)
    % (modulus)
    . (dot product)
    ^ (power)
    ^^ (cross product)

    Equality Operators

    == (equals)
    != (not equals)
    < (less than)
    <= (less or equals)
    > (less than)
    >= (more or equals)

    Precedence Operators

    ( ) (Precedence brackets)
    = (Assignment)


    Date Functions:

    date()
    Returns the current date in dd.mm.yyyy format

    datediff("date1","date2")
    Compares two Date Strings in dd.mm.yyyy format, and returns the number of days by which these dates differ

    datediff("24.12.2005","27.12.2005")

    returns 3

    workdays("date1","date2") Compares two Date Strings in dd.mm.yyyy format, and returns the number of days by which these dates differ. Does not count Saturdays and Sundays.

    dateadd("date",Number)
    Adds the number of days given to the date. Returns a String containing a Date formateed as dd.mm.yyyy

    dateadd("24.12.2005",3)

    returns "27.12.2005"

    Summary Functions:

    sum(n1,n2...,nx)
    Returns the sum of all numerical parameters
    sum(1,2,3,4,5) = 15
    avg(n1,n2...nx) Returns the average of all numicerical parameters
    avg(3,4,5) = 4
    cnt(n1,n2...nx)
    Counts the number of elements given, and returns that count

    distinct("String1",...,"Stringn") Returns a comma separated list of values, but discards similar Strings

    distinct("foo","foo","bar")

    returns "foo","bar"

    Decision Functions:

    if(cond,a,b)
    If cond evaluates to 1 (or "true"), return a, else return b
    if(1>2,"thats right","thats ridiculous")
    returns: "thats ridiculous"
    matches("String","Regex") Returns 1 if the String is matched by the Regular Expression given, 0 otherwise. Can be nicely embedded into if() statements.

    matches("Emanuela",".*anue.*")

    returns 1

    Conversion Functions:

    str(Number)
    returns the String representation of the number given

    int(Number) Converts the given number into an Integer value (rounds to the nearest whole number)

    int(3,14159)

    returns 3

    Math Functions:

    sin(Number)
    returns the Sine of the given numerical value

    cos(Number)
    returns the Cosine of the given numerical value
    tan(Number)
    doh

    asin(Number)


    acos(Number)


    atan(Number)


    log(Number)
    Returns the Logarithm for the Number given

    ln(Number)
    Returns tha natural Logarithm for the Number given

    sqrt(Number)
    Square Root

    mod(Number)
    Modulus (alternative)

    sum(n1,n2...,nx)
    Returns the sum of all numerical parameters
    sum(1,2,3,4,5) = 15
    avg(n1,n2...nx) Returns the average of all numicerical parameters
    avg(3,4,5) = 4
    rand()
    Returns a double between 0..1

    workdays("date1","date2") Compares two Date Strings in dd.mm.yyyy format, and returns the number of days by which these dates differ. Does not count Saturdays and Sundays.

     

     Not flexible enough? Try using Jython!

    Not only does Infostore support the custom formula system denoted above, it also allows you to evaluate any Python code you want. The cool thing about using Python (or Jython, to be exact) is that you have the FULL InfoStore API at  your  fingertips. For example, you could have a piece of formula like:

    if(current.getDataFirst("emailadress").matches(".*@foo.com.*$")):

      InfoStoreContext.getInstance().email.sendEmail(...);

    You can evaluate as complex a formula as you would like.

     

    (Tags: )
    User Comments on this article

    No Comments on this article so far. Be the first to comment!
    Write a new comment

    (no markup is supported whatsoever)
    Your Name:
    Post Title:
    Comment:
    Are you real?
    Advertisement

    © 2002-2008 Emanuel Schleussinger. Built with InfoStore and Wicket