about
  demos
  download
  documentation

documentation

Getting started with omixed

Server and Schematographer Installation

  1. Download, build and deploy the omixed server (see installation instructions).
  2. Download and install the schematographer. (requires the Adobe AIR runtime).

Create a schema

  1. Open the schematographer
  2. Drag and drop an item type palette item from the palette onto empty model. A new item type panel should appear on the model.
  3. Double click on the newly created panel.
  4. A property panel should appear, use it to edit the name of the item type; let's call it "Person".
  5. From the palette, drag a new String palette item onto the the newly created Person item type, double click on it to open its property panel and call this new String "Email".
  6. Drag and drop another item type onto the model; let's call this one "Message".
  7. From the palette, drag a new Text palette item onto the the newly created Message item type, call this new Text "Contents".
  8. Double click on the Message item type again to open its property panel and check the checkbox "check if root"; this will be the root item type.
  9. From the palette, drag a new Link palette onto the Message item type, double click on it to activate its property box, use the combo box to point this to the Person, call this Link "To".
  10. Save this file as Messages.xml.
  11. You can open this file using a text editor: it should look like this (the x and y attributes will of course be different):
    <OmixedDatabaseSchema> <ItemTypeList> <ItemType name="Person" x="491" y="131"> <Attribute name="Email" type="String"/> </ItemType> <ItemType name="Message" x="334" y="391"> <Attribute name="Contents" type="Text"/> <Link name="To" arity="one" to="Person"/> </ItemType> </ItemTypeList> <RootItemTypeList> <ItemType name="Message"/> </RootItemTypeList> </OmixedDatabaseSchema>

Create a resource with the schema

Please note that you must have SSL properly configured on your tomcat installation for this to work. The server installation faq has more details.

  1. Open a terminal and cd into the omixed server folder that you used to build and deploy from.
  2. Type:
    java -jar AdminConsole.jar
  3. Enter your connection details to connect.
  4. In the AdminConsole, type :
    resource-create messages resource-set-schema messages file:///home/buggy/schema/Messages.xml user-create bobber user builder policy-add-on-resource allow connect bobber messages
    (obviously changing the path to wherever you saved the Messages.xml file!)

Interact with the resource using client libraries

Please note these clients do not even have to be on the same machine as the server. For convenience, these instructions assume that they are. Please change "localhost" to match your server's domain name if you are trying this from another machine.

Java Example

  1. Make a folder called omixed-test.
  2. Using bazaar download the latest version of the java_library inside the omixed-test folder.
  3. Build the library by typing "ant" inside the java_library folder
  4. in the omixed-test folder create a new file called NewMessage.java :
    import org.w3c.dom.*; import javax.xml.parsers.*; import org.omixed.omixedclient.*; class NewMessage { public static void main(String [ ] args) throws OmixedClientException, ParserConfigurationException { OmixedClient client = new OmixedClient("localhost", "8080"); // create a client object client.connect("messages", "bobber", "builder"); // connect to the resource OmixedItem person = new OmixedItem(client, "Person", "Jack", "public"); // make an empty local person object person.setAttribute("Email", "Jack@omixed.org"); // set its email value client.create(person); // create the person object on the resource OmixedItem message = new OmixedItem(client, "Message", "email1", "public"); // make an empty local message object message.setAttribute("Contents", "Hello Omixed World"); // set its contents value message.setLink("To", person.getItemID()); // link it to the person client.create(message); // create the message object on the resource NodeList itemElements = client.getItems( message.getItemID() ).getChildNodes(); // for through all the message items for (int i=0; i < itemElements.getLength() ; i++){ Node itemNode = itemElements.item(i); Element itemElement = (Element) itemNode; String itemID = itemElement.getAttribute("itemID"); OmixedItem messageOnServer = new OmixedItem( client, itemID, itemElement ); System.out.println(messageOnServer.getAttribute("Contents")); // print the Contents of the message } client.delete(message.getItemID()); // delete the message item client.delete(person.getItemID()); // delete the person item client.disconnect(); // disconnect } }
  5. build with
    javac -cp java_library/OmixedJavaClient_jdk6.jar NewMessage.java
  6. run with (if you're using windows, please replace the ":" with ";")
    java -classpath .:java_library/OmixedJavaClient_jdk6.jar:java_library/lib/* NewMessage
  7. should result in : Hello Omixed World

Ruby Example

  1. Make a folder called omixed-test-ruby.
  2. Make a new file called NewMessage.rb :
    require ('ruby_library/omixed.rb') include Omixed client = OmixedClient.new("localhost") client.connect("messages", "bobber", "builder"); person = OmixedItem.new() person.setupNewItem(client, "Person", "Jack", "public"); person.setAttribute("Email", "Jack@omixed.org"); client.createItem(person); message = OmixedItem.new() message.setupNewItem(client, "Message", "email1", "public"); message.setAttribute("Contents", "Hello Omixed World"); message.setLink("To", person.itemID); client.createItem(message); itemElements = client.getItemsWithoutLinks( message.itemID ); itemElements.each_element do |el| messageFromServer = OmixedItem.new() messageFromServer.setupXML(client, el.attributes["itemID"], el) puts messageFromServer.getAttribute("Contents") end client.delete(message.itemID); client.delete(person.itemID); client.disconnect();
  3. pull the ruby library by doing:
    bzr get http://www.omixed.org/downloads/files/bazaar/ruby_library
  4. and run by doing:
    ruby NewMessage.rb
  5. should result in : Hello Omixed World