mirror of
https://github.com/scm-manager/scm-manager.git
synced 2026-08-02 01:20:45 +02:00
implement orientdb user dao
This commit is contained in:
@@ -33,6 +33,7 @@ package sonia.scm.orientdb;
|
||||
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.inject.Provider;
|
||||
|
||||
import com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx;
|
||||
@@ -40,6 +41,11 @@ import com.orientechnologies.orient.core.record.impl.ODocument;
|
||||
|
||||
import sonia.scm.GenericDAO;
|
||||
import sonia.scm.ModelObject;
|
||||
import sonia.scm.util.Util;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -73,6 +79,17 @@ public abstract class AbstractOrientDBModelDAO<T extends ModelObject>
|
||||
|
||||
//~--- get methods ----------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param connection
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
protected abstract List<ODocument> getAllDocuments(
|
||||
ODatabaseDocumentTx connection);
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
@@ -227,6 +244,39 @@ public abstract class AbstractOrientDBModelDAO<T extends ModelObject>
|
||||
return item;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<T> getAll()
|
||||
{
|
||||
List<T> items = null;
|
||||
ODatabaseDocumentTx connection = connectionProvider.get();
|
||||
|
||||
try
|
||||
{
|
||||
List<ODocument> result = getAllDocuments(connection);
|
||||
|
||||
if (Util.isNotEmpty(result))
|
||||
{
|
||||
items = OrientDBUtil.transformToItems(converter, result);
|
||||
}
|
||||
else
|
||||
{
|
||||
items = Lists.newArrayList();
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
OrientDBUtil.close(connection);
|
||||
}
|
||||
|
||||
return items;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
|
||||
@@ -33,7 +33,6 @@ package sonia.scm.repository.orientdb;
|
||||
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
|
||||
@@ -48,7 +47,6 @@ import sonia.scm.orientdb.AbstractOrientDBModelDAO;
|
||||
import sonia.scm.orientdb.OrientDBUtil;
|
||||
import sonia.scm.repository.Repository;
|
||||
import sonia.scm.repository.RepositoryDAO;
|
||||
import sonia.scm.util.Util;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
@@ -143,34 +141,14 @@ public class OrientDBRepositoryDAO extends AbstractOrientDBModelDAO<Repository>
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param connection
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<Repository> getAll()
|
||||
protected List<ODocument> getAllDocuments(ODatabaseDocumentTx connection)
|
||||
{
|
||||
List<Repository> repositories = null;
|
||||
ODatabaseDocumentTx connection = connectionProvider.get();
|
||||
|
||||
try
|
||||
{
|
||||
List<ODocument> result = OrientDBUtil.executeListResultQuery(connection,
|
||||
QUERY_ALL);
|
||||
|
||||
if (Util.isNotEmpty(result))
|
||||
{
|
||||
repositories = OrientDBUtil.transformToItems(converter, result);
|
||||
}
|
||||
else
|
||||
{
|
||||
repositories = Lists.newArrayList();
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
OrientDBUtil.close(connection);
|
||||
}
|
||||
|
||||
return repositories;
|
||||
return OrientDBUtil.executeListResultQuery(connection, QUERY_ALL);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -33,82 +33,46 @@ package sonia.scm.user.orientdb;
|
||||
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import com.google.inject.Provider;
|
||||
|
||||
import com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx;
|
||||
import com.orientechnologies.orient.core.record.impl.ODocument;
|
||||
|
||||
import sonia.scm.orientdb.AbstractOrientDBModelDAO;
|
||||
import sonia.scm.orientdb.OrientDBUtil;
|
||||
import sonia.scm.user.User;
|
||||
import sonia.scm.user.UserDAO;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
public class OrientDBUserDAO implements UserDAO
|
||||
public class OrientDBUserDAO extends AbstractOrientDBModelDAO<User>
|
||||
implements UserDAO
|
||||
{
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param item
|
||||
*/
|
||||
@Override
|
||||
public void add(User item)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
/** Field description */
|
||||
public static final String QUERY_ALL = "select from User";
|
||||
|
||||
/** Field description */
|
||||
public static final String QUERY_SINGLE_BYID =
|
||||
"select from User where id = ?";
|
||||
|
||||
//~--- constructors ---------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Method description
|
||||
* Constructs ...
|
||||
*
|
||||
*
|
||||
* @param item
|
||||
*
|
||||
* @return
|
||||
* @param connectionProvider
|
||||
*/
|
||||
@Override
|
||||
public boolean contains(User item)
|
||||
public OrientDBUserDAO(Provider<ODatabaseDocumentTx> connectionProvider)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param id
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public boolean contains(String id)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param item
|
||||
*/
|
||||
@Override
|
||||
public void delete(User item)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param item
|
||||
*/
|
||||
@Override
|
||||
public void modify(User item)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
super(connectionProvider, UserConverter.INSTANCE);
|
||||
}
|
||||
|
||||
//~--- get methods ----------------------------------------------------------
|
||||
@@ -117,61 +81,29 @@ public class OrientDBUserDAO implements UserDAO
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param connection
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
protected List<ODocument> getAllDocuments(ODatabaseDocumentTx connection)
|
||||
{
|
||||
return OrientDBUtil.executeListResultQuery(connection, QUERY_ALL);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param connection
|
||||
* @param id
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public User get(String id)
|
||||
protected ODocument getDocument(ODatabaseDocumentTx connection, String id)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Collection<User> getAll()
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Long getCreationTime()
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Long getLastModified()
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
return OrientDBUtil.executeSingleResultQuery(connection, QUERY_SINGLE_BYID,
|
||||
id);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,6 +65,9 @@ public class UserConverter extends AbstractConverter implements Converter<User>
|
||||
/** Field description */
|
||||
public static final String FIELD_PASSWORD = "password";
|
||||
|
||||
/** Field description */
|
||||
public static final UserConverter INSTANCE = new UserConverter();
|
||||
|
||||
//~--- methods --------------------------------------------------------------
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user