Skip to content

Commit

Permalink
Merge branch 'master' of github.com:edanuff/stack
Browse files Browse the repository at this point in the history
  • Loading branch information
edanuff committed Jan 11, 2012
2 parents 59310bc + 329d87a commit 9303611
Show file tree
Hide file tree
Showing 19 changed files with 788 additions and 153 deletions.
224 changes: 171 additions & 53 deletions config/src/main/resources/cassandra.yaml

Large diffs are not rendered by default.

224 changes: 171 additions & 53 deletions config/src/test/resources/cassandra.yaml

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions core/src/main/java/org/usergrid/persistence/Schema.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,14 @@

import org.apache.commons.beanutils.PropertyUtils;
import org.apache.commons.lang.reflect.FieldUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.codehaus.jackson.JsonNode;
import org.codehaus.jackson.map.ObjectMapper;
import org.codehaus.jackson.map.SerializationConfig;
import org.codehaus.jackson.node.ObjectNode;
import org.codehaus.jackson.smile.SmileFactory;
import org.codehaus.jackson.type.TypeReference;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider;
import org.springframework.core.type.filter.AssignableTypeFilter;
Expand Down Expand Up @@ -1808,7 +1808,7 @@ public static Map<String, Object> deserializeEntityProperties(

String entityType = string(columns.get(PROPERTY_TYPE));
if (entityType == null) {
logger.error("No type for entity found!", new Throwable());
logger.warn("deserializeEntityProperties(): No type for entity found, entity probably doesn't exist");
return null;
}
if (checkId && !columns.containsKey(PROPERTY_UUID)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -976,11 +976,27 @@ public <A extends Entity> A batchCreate(Mutator<ByteBuffer> m,
}

if (!is_application) {
batchIncrementAggregateCounters(m, applicationId, null, null, null,
null, "application.collection." + collection_name, 1L,
timestamp);
batchIncrementAggregateCounters(m, applicationId, null, null, null,
null, "application.entities", 1L, timestamp);
/*
* batchIncrementAggregateCounters(m, applicationId, null, null,
* null, null, "application.collection." + collection_name, 1L,
* timestamp); batchIncrementAggregateCounters(m, applicationId,
* null, null, null, null, "application.entities", 1L, timestamp);
*/
try {
incrementAggregateCounters(null, null, null,
"application.collection." + collection_name, 1L);
} catch (Exception e) {
logger.error(
"Unable to increment counter application.collection."
+ collection_name, e);
}
try {
incrementAggregateCounters(null, null, null,
"application.entities", 1L);
} catch (Exception e) {
logger.error(
"Unable to increment counter application.entities", e);
}
}

return entity;
Expand Down Expand Up @@ -1107,8 +1123,8 @@ public <A extends Entity> A getEntity(UUID entityId, String entityType,
// }

if (results == null) {
logger.error("No properties found for entity " + entityId,
new Throwable());
logger.warn("getEntity(): No properties found for entity "
+ entityId + ", probably doesn't exist...");
return null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,9 @@ public class Application extends TypedEntity {
"modified", "username", "email" }, dictionariesIndexed = { "aliases" }, indexingDynamicProperties = true)
protected List<UUID> users;

@EntityCollection(type = "device", propertiesIndexed = {}, indexingDynamicProperties = false)
protected List<UUID> devices;

public Application() {
// id = UUIDUtils.newTimeUUID();
}
Expand Down Expand Up @@ -316,6 +319,15 @@ public void setEvents(List<UUID> events) {
this.events = events;
}

@JsonSerialize(include = Inclusion.NON_NULL)
public List<UUID> getDevices() {
return devices;
}

public void setDevices(List<UUID> devices) {
this.devices = devices;
}

@JsonSerialize(include = Inclusion.NON_NULL)
public Map<String, OAuthProvider> getOauthproviders() {
return oauthproviders;
Expand Down
14 changes: 14 additions & 0 deletions core/src/main/java/org/usergrid/persistence/entities/Device.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
package org.usergrid.persistence.entities;

import java.util.List;
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.EntityCollection;
import org.usergrid.persistence.annotations.EntityProperty;

/**
Expand All @@ -20,6 +22,9 @@ public class Device extends TypedEntity {
@EntityProperty(indexed = true, fulltextIndexed = false, required = false, indexedInConnections = true, aliasProperty = true, unique = true, basic = true)
protected String name;

@EntityCollection(type = "user", propertiesIndexed = {}, linkedCollection = "devices", indexingDynamicProperties = false)
protected List<UUID> users;

public Device() {
// id = UUIDUtils.newTimeUUID();
}
Expand All @@ -38,4 +43,13 @@ public void setName(String name) {
this.name = name;
}

@JsonSerialize(include = Inclusion.NON_NULL)
public List<UUID> getUsers() {
return users;
}

public void setUsers(List<UUID> users) {
this.users = users;
}

}
12 changes: 12 additions & 0 deletions core/src/main/java/org/usergrid/persistence/entities/User.java
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ public class User extends TypedEntity {
@EntityCollection(type = "group", linkedCollection = "users", propertiesIndexed = { "path" }, indexingDynamicProperties = true)
protected List<UUID> groups;

@EntityCollection(type = "device", linkedCollection = "users", propertiesIndexed = {}, indexingDynamicProperties = false)
protected List<UUID> devices;

@EntityCollection(type = "activity", propertiesIndexed = { "created",
"published", "content" }, subkeys = { "verb" }, reversed = true, sort = "published desc")
protected List<UUID> activities;
Expand Down Expand Up @@ -214,6 +217,15 @@ public void setGroups(List<UUID> groups) {
this.groups = groups;
}

@JsonSerialize(include = Inclusion.NON_NULL)
public List<UUID> getDevices() {
return devices;
}

public void setDevices(List<UUID> devices) {
this.devices = devices;
}

@JsonSerialize(include = Inclusion.NON_NULL)
public Set<String> getConnections() {
return connections;
Expand Down
3 changes: 1 addition & 2 deletions core/src/main/java/org/usergrid/utils/Inflector.java
Original file line number Diff line number Diff line change
Expand Up @@ -740,10 +740,9 @@ protected void initialize() {
inflect.addIrregular("sex", "sexes");
inflect.addIrregular("move", "moves");
inflect.addIrregular("stadium", "stadiums");
inflect.addIrregular("data", "data");

inflect.addUncountable("equipment", "information", "rice", "money",
"species", "series", "fish", "sheep");
"species", "series", "fish", "sheep", "data", "analytics");
}

}
10 changes: 5 additions & 5 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<bundle.symbolicName>org.usergrid</bundle.symbolicName>
<bundle.namespace>org.usergrid</bundle.namespace>
<cassandra-javautils-version>0.7.0</cassandra-javautils-version>
<cassandra-version>0.8.7</cassandra-version>
<hector-om-version>1.1-02</hector-om-version>
<hector-version>0.8.0-2</hector-version>
<hector-test-version>0.8.0-3</hector-test-version>
<cassandra-javautils-version>0.7.1</cassandra-javautils-version>
<cassandra-version>1.0.6</cassandra-version>
<hector-om-version>2.0-01</hector-om-version>
<hector-version>1.0-2-SNAPSHOT</hector-version>
<hector-test-version>1.0-2-SNAPSHOT</hector-test-version>
<jackson-version>1.8.5</jackson-version>
<jersey-version>1.9.1</jersey-version>
<junit-version>4.8.2</junit-version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ public static List<ServiceParameter> addQueryParams(
}

@Path("{entityId: [A-Fa-f0-9]{8}-[A-Fa-f0-9]{4}-[A-Fa-f0-9]{4}-[A-Fa-f0-9]{4}-[A-Fa-f0-9]{12}}")
public ServiceResource addIdParameter(@Context UriInfo ui,
public AbstractContextResource addIdParameter(@Context UriInfo ui,
@PathParam("entityId") PathSegment entityId) throws Exception {

logger.info("ServiceResource.addIdParameter");
Expand All @@ -181,7 +181,7 @@ public ServiceResource addIdParameter(@Context UriInfo ui,
}

@Path("{itemName}")
public ServiceResource addNameParameter(@Context UriInfo ui,
public AbstractContextResource addNameParameter(@Context UriInfo ui,
@PathParam("itemName") PathSegment itemName) throws Exception {

logger.info("ServiceResource.addNameParameter");
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package org.usergrid.rest.applications.users;

import org.usergrid.rest.AbstractContextResource;

public abstract class AbstractUserExtensionResource extends
AbstractContextResource {

UserResource userResource;

public AbstractUserExtensionResource(UserResource userResource)
throws Exception {
super(userResource);
this.userResource = userResource;
}

public UserResource getUserResource() {
return userResource;
}

}
Loading

0 comments on commit 9303611

Please sign in to comment.