All Downloads are FREE. Search and download functionalities are using the official Maven repository.

xq.gwt.mvc.model.PersistableEntityModel Maven / Gradle / Ivy

Go to download

A framework for implementing the MVP variant of the Model View Controller design pattern in the context of GWT

The newest version!
package xq.gwt.mvc.model;

public abstract class PersistableEntityModel extends AbstractEntityModel {
	
	private static final long serialVersionUID = -8609306484477758113L;
	
	public abstract PropertyModel[] getKeyProperties();
	
	public abstract PersistableEntityModel newInstance();
	
	@Override
	public PersistableEntityModel copy()throws Exception{
		PersistableEntityModel newEntity = newInstance();
		copyPropertyValues(this, newEntity);		
		return newEntity;
	}
			
	@Override
	public String getIdentifier(){
		String identifier = null;
		PropertyModel[] keys = getKeyProperties(); 
		if (keys != null){
			for (int i = 0; i < keys.length; i++) {
				if(i == 0){
					identifier = keys[i].getText();
				}else
					identifier += keys[i].getText();
			}
		}
			
		return identifier;
	}
	
	public boolean isNew(){
		PropertyModel[] keys = getKeyProperties();
		if(keys == null)
			return true;
		for (int i = 0; i < keys.length; i++) {
			if(keys[i].getObjectValue() != null)
				return false;
		}
		
		
		return true;
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy