MCMS DevDoc

Entwicklerhandbuch :: Eclipse :: WPML :: Beispiele

WPML: Beispiele

« Service

Bibliotheksmodel

Beispiel einer Bibliothek-Modeldatei

BASEDIR "/src/";

LIBARY mcms.Demo {
	@version "1.0.0";
	GENTABLEXML;
	
	// Definition eines Modelles
	MODEL Entry {
		id ObjectID;
		name String;
		date Date;

		PKEY id;
		INDEX names name;
	}

  // Definition eines weiteren Modells, welches auf das erste referenziert
	MODEL EntryComment {
		id ObjectID;
		entry_id ObjectIDRef Entry:id;
		created_by_name String;
		created_at DateTime;
		info Text;
		
		PKEY id;
		INDEX entry_id entry_id;
	}
	
  // Definition eines Services, in diesem Fall zum Datenzugriff
	SERVICE Repos {
		METHOD storeEntry(Entry e) STORES e:id IN "m_demo#demo_entry";
		METHOD removeEntry(Entry e);
	}
}

Modulmodel

Beispiel einer Modul-Modeldatei

BASEDIR "/src/";

MODULE mcms.Demo extends Base {
	@note "Demomodul";
	@version "1.0.0";
	GENTABLEXML;
	
	// Installationsscript
	GENSCRIPT REPLACE "install" INSTALL {
		CREATE TABLE entrys;
		CREATE TABLE entrycomments;
	}
	
	// Deinstallationsscript
	GENSCRIPT REPLACE "remove" REMOVE{
		DROP TABLE entrycomments;
		DROP TABLE entrys;
	}
	
	// Definition eines Modelles
	MODEL Entry {
		@note "Demomodel";
		id ObjectID;
		name String;
		date Date;

		PKEY id;
		INDEX names name;
	}
	
	// Definition eines weiteren Modells, welches auf das erste referenziert
	MODEL EntryComment {
		id ObjectID;
		entry_id NULLABLE ObjectIDRef Entry:id;
		created_by_name String;
		created_at DateTime;
		info Text;
		
		PKEY id;
		INDEX entry_id entry_id;
	}
	
	// Definition eines Services, in diesem Fall zum Datenzugriff
	SERVICE Repos {
		METHOD storeEntry(Entry e) STORES e:id IN "m_demo#demo_entry";
		METHOD removeEntry(Entry e);
	}
	
 	// Eine View mit einer Liste von Elementen
	view index {
		LIST Entry entries:e;
	}
	
	// Eine View mit einem Formular
	view editEntry {
		CHECKPERM entryUpdate;
		SHOW FORM Entry entry;
	}
	
	// Eine Aktion
	action updateEntry {
		CHECKPERM entryUpdate;
	}
}