package it.mice.voila.runtime.entity;

import java.io.Serializable;

import org.apache.commons.lang.StringUtils;

public class OperationLogMessage implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = -780557000199729696L;

	private String applicationId;
	private Integer operationId;
	private String operationName;
    private String ipAddress;
    private String logDescription;
    private String createUser;
    
    
	public OperationLogMessage() {
		super();
	}
    
	public OperationLogMessage(String message) {
        String[] array = StringUtils.splitByWholeSeparatorPreserveAllTokens(message, "|");
        int ctr = 0;
        setCreateUser(array[ctr++]);
        setIpAddress(array[ctr++]);
        setApplicationId(array[ctr++]);
        setOperationId(Integer.parseInt(array[ctr++]));
        setOperationName(array[ctr++]);
        setLogDescription(array[ctr++]);
	}

	public String getApplicationId() {
		return applicationId;
	}
	public void setApplicationId(String applicationId) {
		this.applicationId = applicationId;
	}
	public Integer getOperationId() {
		return operationId;
	}
	public void setOperationId(Integer operationId) {
		this.operationId = operationId;
	}
	public String getOperationName() {
		return operationName;
	}
	public void setOperationName(String operationName) {
		this.operationName = operationName;
	}
	public String getIpAddress() {
		return ipAddress;
	}
	public void setIpAddress(String ipAddress) {
		this.ipAddress = ipAddress;
	}
	public String getLogDescription() {
		return logDescription;
	}
	public void setLogDescription(String logDescription) {
		this.logDescription = logDescription;
	}
	public String getCreateUser() {
		return createUser;
	}
	public void setCreateUser(String createUser) {
		this.createUser = createUser;
	}
	@Override
	public String toString() {
		StringBuffer result = new StringBuffer();
		result.append(createUser).append("|").append(ipAddress).append("|").append(applicationId).append("|").append(operationId).append("|").append(operationName).append("|").append(logDescription);
		return result.toString();
	}
}
