Isis Script - First (alpha) version available

July 6, 2015
isis dsl eclipse xtext

As mentioned in my previous post I’ve been working on a DSL for Apache Isis. Now a first (alpha) version is finished. This version provides a very early stage of an Eclipse editor for the Isis Script DSL.

Isis Script DSL Editor

Only a few features are available yet:

This feature set allows us to implement the entity and repository of the domain object SimpleObject from the Apache Isis Maven archetype SimpleApp. The corresponding Isis Script (based on the current version of the DSL) is as follows:

package domainapp.dom.modules.simple

import javax.jdo.annotations.Column
import javax.jdo.annotations.DatastoreIdentity
import javax.jdo.annotations.IdGeneratorStrategy
import javax.jdo.annotations.IdentityType
import javax.jdo.annotations.PersistenceCapable
import javax.jdo.annotations.Queries
import javax.jdo.annotations.Query
import javax.jdo.annotations.Unique
import javax.jdo.annotations.Version
import javax.jdo.annotations.VersionStrategy
import org.apache.isis.applib.annotation.Action
import org.apache.isis.applib.annotation.ActionLayout
import org.apache.isis.applib.annotation.BookmarkPolicy
import org.apache.isis.applib.annotation.DomainObject
import org.apache.isis.applib.annotation.DomainObjectLayout
import org.apache.isis.applib.annotation.DomainServiceLayout
import org.apache.isis.applib.annotation.Editing
import org.apache.isis.applib.annotation.MemberOrder
import org.apache.isis.applib.annotation.Parameter
import org.apache.isis.applib.annotation.ParameterLayout
import org.apache.isis.applib.annotation.Property
import org.apache.isis.applib.annotation.SemanticsOf
import org.apache.isis.applib.annotation.Title
import org.apache.isis.applib.query.QueryDefault
import org.apache.isis.applib.services.i18n.TranslatableString

@PersistenceCapable(identityType=IdentityType.DATASTORE)
@DatastoreIdentity(strategy=IdGeneratorStrategy.IDENTITY, column="id")
@Version(strategy=VersionStrategy.VERSION_NUMBER, column="version")
@Queries(#[
	@Query(name = "find", language = "JDOQL",
		value = "SELECT FROM domainapp.dom.modules.simple.SimpleObject"),
	@Query(name = "findByName", language = "JDOQL",
		value = "SELECT FROM domainapp.dom.modules.simple.SimpleObject WHERE name.indexOf(:name) >= 0")
])
@Unique(name="SimpleObject_name_UNQ", members = #["name"])
@DomainObject(objectType = "SIMPLE")
@DomainObjectLayout(bookmarking = BookmarkPolicy.AS_ROOT)
entity SimpleObject {

	@Column(allowsNull="false", length = 40)
	@Title(sequence="1")
	@Property(editing = Editing.DISABLED)
	property String name

	event UpdateNameDomainEvent

	@Action(domainEvent = UpdateNameDomainEvent)
	action updateName(@Parameter(maxLength = 40)
            @ParameterLayout(named = "New name") String newName) {
		setName(newName)
		this
	}

	action default0UpdateName() {
		getName()
	}

	action validateUpdateName(String name) {
		if (name.contains("!"))
			TranslatableString.tr("Exclamation mark is not allowed")
		else null
	}

	@DomainServiceLayout(menuOrder = "10")
	repository {

		@Action(semantics = SemanticsOf.SAFE)
		@ActionLayout(bookmarking = BookmarkPolicy.AS_ROOT)
		@MemberOrder(sequence = "1")
		action listAll() {
			container.allInstances(SimpleObject)
		}

		@Action(semantics = SemanticsOf.SAFE)
		@ActionLayout(bookmarking = BookmarkPolicy.AS_ROOT)
		@MemberOrder(sequence = "2")
		action findByName(@ParameterLayout(named="Name") String name) {
			container.allMatches(new QueryDefault(SimpleObject,
				"findByName", "name", name))
		}

		@MemberOrder(sequence = "3")
		action create(@ParameterLayout(named="Name") String name) {
			val obj = container.newTransientInstance(SimpleObject)
			obj.name = name
			container.persistIfNotAlready(obj)
			obj
		}
	}

	title {
		TranslatableString.tr("Object: {name}", "name", name)
	}
}

Technical details of the implementation can be found here.

If you’re interested in giving the Eclipse editor for Isis Script a try then you can find the corresponding information here.

Veloedit - Now available on GitHub

January 5, 2016
eclipse velocity

Enabling TemplateVariableResolver for Xbase imports in Xtext editor

October 4, 2015
eclipse xtext xbase

Isis Script - Updated (alpha) version available

September 5, 2015
isis dsl eclipse xtext
comments powered by Disqus