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

org.usergrid.persistence.entities.Event Maven / Gradle / Ivy

There is a newer version: 0.0.27.1
Show newest version
/*******************************************************************************
 * Copyright 2012 Apigee Corporation
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *   http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 ******************************************************************************/
package org.usergrid.persistence.entities;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import java.util.UUID;

import javax.xml.bind.annotation.XmlRootElement;

import org.codehaus.jackson.map.annotate.JsonSerialize;
import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
import org.usergrid.persistence.TypedEntity;
import org.usergrid.persistence.annotations.EntityDictionary;
import org.usergrid.persistence.annotations.EntityProperty;

/**
 * An event type posted by the application.
 */
@XmlRootElement
public class Event extends TypedEntity {

	public static final String ENTITY_TYPE = "event";

	@EntityProperty(required = true, indexed = true, mutable = false)
	long timestamp = System.currentTimeMillis();

	@EntityProperty(required = false, indexed = true, mutable = false)
	UUID user;

	@EntityProperty(required = false, indexed = true, mutable = false)
	UUID group;

	@EntityProperty(fulltextIndexed = false, required = false, mutable = false, indexed = true)
	String category;

	@EntityProperty(indexed = false, required = false, mutable = false)
	Map counters;

	@EntityProperty(indexed = true, required = false, mutable = false)
	String message;

	@EntityDictionary(keyType = java.lang.String.class)
	protected Set connections;

	public Event() {
		// id = UUIDUtils.newTimeUUID();
	}

	public Event(UUID id) {
		uuid = id;
	}

	public long getTimestamp() {
		return timestamp;
	}

	public void setTimestamp(long timestamp) {
		if (timestamp == 0) {
			timestamp = System.currentTimeMillis();
		}
		this.timestamp = timestamp;
	}

	@JsonSerialize(include = Inclusion.NON_NULL)
	public UUID getUser() {
		return user;
	}

	public void setUser(UUID user) {
		this.user = user;
	}

	@JsonSerialize(include = Inclusion.NON_NULL)
	public UUID getGroup() {
		return group;
	}

	public void setGroup(UUID group) {
		this.group = group;
	}

	@JsonSerialize(include = Inclusion.NON_NULL)
	public String getCategory() {
		return category;
	}

	public void setCategory(String category) {
		this.category = category;
	}

	@JsonSerialize(include = Inclusion.NON_NULL)
	public Map getCounters() {
		return counters;
	}

	public void setCounters(Map counters) {
		this.counters = counters;
	}

	public void addCounter(String name, int value) {
		if (counters == null) {
			counters = new HashMap();
		}
		counters.put(name, value);
	}

	public String getMessage() {
		return message;
	}

	public void setMessage(String message) {
		this.message = message;
	}

	@JsonSerialize(include = Inclusion.NON_NULL)
	public Set getConnections() {
		return connections;
	}

	public void setConnections(Set connections) {
		this.connections = connections;
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy