Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/**
* $Id$
* $URL$
* EntityDataUtils.java - entity-broker - Aug 11, 2008 2:58:03 PM - azeckoski
**************************************************************************
* Copyright (c) 2008, 2009 The Sakai Foundation
*
* Licensed under the Educational Community 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.opensource.org/licenses/ECL-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.sakaiproject.entitybroker.util;
import java.io.Serializable;
import java.util.*;
import java.util.Map.Entry;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.azeckoski.reflectutils.ReflectUtils;
import org.azeckoski.reflectutils.exceptions.FieldnameNotFoundException;
import org.sakaiproject.content.api.ContentEntity;
import org.sakaiproject.entity.api.EntityPropertyNotDefinedException;
import org.sakaiproject.entity.api.EntityPropertyTypeException;
import org.sakaiproject.entity.api.ResourceProperties;
import org.sakaiproject.entitybroker.EntityReference;
import org.sakaiproject.entitybroker.entityprovider.annotations.EntityId;
import org.sakaiproject.entitybroker.entityprovider.capabilities.CollectionResolvable;
import org.sakaiproject.entitybroker.entityprovider.extension.ActionReturn;
import org.sakaiproject.entitybroker.entityprovider.extension.EntityData;
import org.sakaiproject.entitybroker.entityprovider.search.Restriction;
import org.sakaiproject.entitybroker.entityprovider.search.Search;
import org.sakaiproject.entitybroker.util.model.EntityContent;
/**
* Utilities which are useful when working with {@link EntityData} objects and their properties
*
* @author Aaron Zeckoski (azeckoski @ gmail.com)
*/
public class EntityDataUtils {
private final static Log log = LogFactory.getLog(EntityDataUtils.class);
// Property names
private final static Set directPropertyNames = Collections.unmodifiableSet(new HashSet(){
private static final long serialVersionUID = 1L;
{
add(ResourceProperties.PROP_DISPLAY_NAME);
add(ResourceProperties.PROP_DESCRIPTION);
add(ResourceProperties.PROP_CREATOR);
add(ResourceProperties.PROP_MODIFIED_BY);
add(ResourceProperties.PROP_CREATION_DATE);
add(ResourceProperties.PROP_MODIFIED_DATE);
add(ResourceProperties.PROP_RESOURCE_TYPE);
add(ResourceProperties.PROP_CONTENT_TYPE);
add(ResourceProperties.PROP_CONTENT_PRIORITY);
add(ResourceProperties.PROP_CONTENT_LENGTH);
add(ResourceProperties.PROP_IS_COLLECTION);
}
});
/**
* Convert a list of objects to entity data objects (DOES NOT populate them),
* will preserve null (i.e. null in => null out)
*/
public static List convertToEntityData(List> entities, EntityReference ref) {
List l = null;
if (entities != null) {
l = new ArrayList();
for (Object entity : entities) {
l.add( makeEntityData(ref, entity) );
}
}
return l;
}
/**
* Convert a single object to an entity data object (DOES NOT populate it),
* will preserve null (i.e. null in => null out)
*/
public static EntityData convertToEntityData(Object entity, EntityReference ref) {
EntityData ed = null;
if (entity != null) {
ed = makeEntityData(ref, entity);
}
return ed;
}
/**
* Convert a list of entities / entity data to just entities,
* will preserve null (i.e. null in => null out)
*/
public static List> convertToEntities(List> entities) {
List