package org.i3xx.cloud.data.coor.domain;

import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Index;
import javax.persistence.Table;

@Entity 
@Table(name="objecttoob4", indexes={
@Index(name="uuid_idx", columnList="uuid"),
@Index(name="history_idx", columnList="history"),
@Index(name="uuidindex_idx", columnList="uuid, history"),
@Index(name="idindex_idx", columnList="ID, TRANSID, FIRMA")})
public class ObjectToOb4 {
	
	/**  */
	private static final int ID_IS_DIRTY = 0x1;
	
	/**  */
	private static final int UUID_IS_DIRTY = 0x2;
	
	// OfficeBase_M5
	private String uuid;
	private String history;
	// OfficeBase_M4
	private String FIRMA;
	private long ID;
	private int TRANSID;
	//Index
	private int dirty;
	
	public ObjectToOb4() {
		uuid = "";
		history = "";
		FIRMA = "";
		ID = 0L;
		TRANSID = 0;
	}
	
	@Id
	public String getPrimary() {
		return uuid+"_"+history;
	}
	
	public String getUuid(){
		return uuid;
	}

	/**
	 * 
	 * @param newVal
	 */
	public void setUuid(String newVal){
		uuid = newVal;
		dirty |= UUID_IS_DIRTY;
	}

	public String getHistory(){
		return history;
	}

	/**
	 * 
	 * @param newVal
	 */
	public void setHistory(String newVal){
		history = newVal;
		dirty |= UUID_IS_DIRTY;
	}

	public long getId(){
		return ID;
	}

	/**
	 * 
	 * @param newVal
	 */
	public void setId(long newVal){
		ID = newVal;
		dirty |= ID_IS_DIRTY;
	}

	public int getTransid(){
		return TRANSID;
	}

	/**
	 * 
	 * @param newVal
	 */
	public void setTransid(int newVal){
		TRANSID = newVal;
		dirty |= ID_IS_DIRTY;
	}

	public String getFirma(){
		return FIRMA;
	}

	/**
	 * 
	 * @param newVal
	 */
	public void setFirma(String newVal){
		FIRMA = newVal;
		dirty = ( UUID_IS_DIRTY | ID_IS_DIRTY );
	}
	
	// ------------------------------------------------------------------------
	// intern operations
	// ------------------------------------------------------------------------
	
	/**
	 * Finishes the operation and build the index
	 */
	public void finish() {
		//if( (dirty&UUID_IS_DIRTY)==UUID_IS_DIRTY )
			//
		//if( (dirty&ID_IS_DIRTY)==ID_IS_DIRTY )
			//
		
		dirty = 0;
	}
	
	/**
	 * @return True if anything has changed
	 */
	public boolean isDirty() {
		return dirty!=0;
	}

}

@@ -169,16 +169,49 @@
 ble;%0D%0A%0D%0A
+/**%0D%0A * @author Stefan%0D%0A *%0D%0A */%0D%0A
 @Entity 
@@ -955,31 +955,779 @@
 %0D%0A%09%09
-return uuid+%22_%22+history
+//%0D%0A%09%09// The uuid is the object id to identify every object used by the software (except this mapping))%0D%0A%09%09// The history is the object id to identify each object's history.%0D%0A%09%09//%0D%0A%09%09// UUID ::= 128-bit UUID @see https://en.wikipedia.org/wiki/Universally_unique_identifier%0D%0A%09%09// uuid ::= UUID%0D%0A%09%09// history ::= UUID%0D%0A%09%09// primary ::= uuid '_' history%0D%0A%09%09//%0D%0A%09%09return uuid+%22_%22+history;%0D%0A%09%7D%0D%0A%09%0D%0A%09/**%0D%0A%09 * @param newValue%0D%0A%09 */%0D%0A%09public void setPrimary(String newValue) %7B%0D%0A%09%09//%0D%0A%09%09// UUID ::= 128-bit UUID @see https://en.wikipedia.org/wiki/Universally_unique_identifier%0D%0A%09%09// primary ::= UUID '_' UUID%0D%0A%09%09//%0D%0A%09%09String%5B%5D s = newValue.split(%22%5C%5C_%22, 2);%0D%0A%09%09if(s!=null && s.length%3E=1 && s%5B0%5D!=null)%0D%0A%09%09%09uuid = s%5B0%5D;%0D%0A%09%09if(s!=null && s.length%3E=2 && s%5B1%5D!=null)%0D%0A%09%09%09history = s%5B1%5D
 ;%0D%0A%09

Add setter for primary index function