Example usage for org.hibernate.id UUIDHexGenerator generate

List of usage examples for org.hibernate.id UUIDHexGenerator generate

Introduction

In this page you can find the example usage for org.hibernate.id UUIDHexGenerator generate.

Prototype

@Override
    public Serializable generate(SharedSessionContractImplementor session, Object obj) 

Source Link

Usage

From source file:de.innovationgate.webgate.api.jdbc.WGDatabaseImpl.java

License:Open Source License

/**
 * @throws WGAPIException /*from w w  w. j  a v  a 2 s  .  c  o m*/
 * @see de.innovationgate.webgate.api.WGDatabaseCore#createStructEntry(WGDocument,
 *      WGContentType)
 */
public WGDocumentCore createStructEntry(Object key, WGDocument reference, WGContentType contentType)
        throws WGAPIException {

    StructEntry newStructEntry = new StructEntry();

    if (contentType != null) {
        ContentType contentTypeEntity = (ContentType) ((WGDocumentImpl) contentType.getCore()).getEntity();
        newStructEntry.setContenttype(contentTypeEntity);
    }

    if (key != null) {
        newStructEntry.setKey(String.valueOf(key));
    } else {
        UUIDHexGenerator idGenerator = new UUIDHexGenerator();
        newStructEntry.setKey(String.valueOf(idGenerator
                .generate((org.hibernate.engine.spi.SessionImplementor) getSession(), newStructEntry)));
    }

    if (reference instanceof WGArea) {
        Area area = (Area) ((WGDocumentImpl) reference.getCore()).getEntity();
        newStructEntry.setArea(area);
        if (_ddlVersion < WGDatabase.CSVERSION_WGA5) {
            area.getRootentries().put(newStructEntry.getKey(), newStructEntry);
        }

    } else {
        StructEntry parentEntry = (StructEntry) getEntity(reference);
        newStructEntry.setParententry(parentEntry);
        if (_ddlVersion < WGDatabase.CSVERSION_WGA5) {
            parentEntry.getChildentries().put(newStructEntry.getKey(), newStructEntry);
        }
    }

    newStructEntry.setReaders(new ArrayList());
    newStructEntry.setChildeditors(new ArrayList());
    newStructEntry.setPageeditors(new ArrayList());
    newStructEntry.setPublished(new HashMap());
    newStructEntry.setContent(new HashSet());
    newStructEntry.setChildentries(new HashMap());

    return createDocumentImpl(newStructEntry);

}

From source file:de.innovationgate.webgate.api.jdbc.WGDatabaseImpl.java

License:Open Source License

/**
 * @see de.innovationgate.webgate.api.WGDatabaseCore#createUserProfile(String,
 *      int)/*www. j a va 2  s  .  c o  m*/
 */
public WGDocumentCore createUserProfile(String name, int type)
        throws WGAPIException, WGAuthorisationException, WGCreationException {

    UserProfile newProfile = new UserProfile();

    if (name != null) {
        newProfile.setName(name);
    } else {
        UUIDHexGenerator idGenerator = new UUIDHexGenerator();
        newProfile.setName(String.valueOf(idGenerator.generate((SessionImplementor) getSession(), newProfile)));
    }
    newProfile.setType(new Integer(type));
    newProfile.setHits(new Integer(0));
    newProfile.setSessions(new Integer(0));
    newProfile.setLanguages(new ArrayList<String>());
    newProfile.setPortletkeys(new ArrayList<String>());
    newProfile.setItems(new HashMap<String, UserProfileItem>());
    newProfile.setPortlets(new HashMap<String, UserProfilePortlet>());

    return createDocumentImpl(newProfile);
}