
org.molgenis.service.StringValueService Maven / Gradle / Ivy
package org.molgenis.service;
import java.util.List;
import java.util.ArrayList;
import org.apache.log4j.Logger;
import org.molgenis.framework.db.Database;
import org.molgenis.framework.db.DatabaseException;
import org.molgenis.framework.db.QueryRule;
import org.molgenis.framework.db.QueryRule.Operator;
import org.molgenis.omx.observ.value.StringValue;
import org.molgenis.model.elements.Entity;
import org.molgenis.util.EntityPager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
@Lazy
@Service
public class StringValueService
{
private static final Logger logger = Logger.getLogger(StringValueService.class);
@Autowired
@Qualifier("database")
private Database db;
public StringValue create(StringValue stringValue) throws DatabaseException
{
logger.debug("creating StringValue");
db.add(stringValue);
return stringValue;
}
public StringValue read(Integer id) throws DatabaseException
{
logger.debug("retrieving StringValue");
return db.findById(StringValue.class, id);
}
public void update(StringValue stringValue) throws DatabaseException
{
logger.debug("updating StringValue");
db.update(stringValue);
}
public boolean deleteById(Integer id) throws DatabaseException
{
logger.debug("deleting StringValue");
StringValue stringValue = db.findById(StringValue.class, id);
return db.remove(stringValue) == 1;
}
public Iterable readAll() throws DatabaseException
{
logger.debug("retrieving all StringValue instances");
return db.find(StringValue.class);
}
public EntityPager readAll(int start, int num, List queryRules) throws DatabaseException
{
logger.debug("retrieving all StringValue instances");
if (queryRules == null) queryRules = new ArrayList();
queryRules.add(new QueryRule(Operator.OFFSET, start));
queryRules.add(new QueryRule(Operator.LIMIT, num));
int count = db.count(StringValue.class, queryRules.toArray(new QueryRule[0]));
List stringValueCollection = db.find(StringValue.class, queryRules.toArray(new QueryRule[0]));
return new EntityPager(start, num, count, stringValueCollection);
}
public Entity getEntity() throws DatabaseException
{
return db.getMetaData().getEntity("StringValue");
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy