wisemapping-open-source/wise-webapp/src/main/java/com/wisemapping/dao/LabelManagerImpl.java

49 lines
1.4 KiB
Java
Raw Normal View History

package com.wisemapping.dao;
import com.wisemapping.model.Label;
2014-01-26 22:21:01 +01:00
import com.wisemapping.model.User;
import org.jetbrains.annotations.NotNull;
2014-01-28 06:28:16 +01:00
import org.jetbrains.annotations.Nullable;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
2014-01-26 22:21:01 +01:00
import java.util.List;
public class LabelManagerImpl extends HibernateDaoSupport
implements LabelManager {
@Override
2014-01-26 22:18:49 +01:00
public void addLabel(@NotNull final Label label) {
saveLabel(label);
}
@Override
2014-01-26 22:18:49 +01:00
public void saveLabel(@NotNull final Label label) {
getSession().save(label);
}
2014-01-26 22:21:01 +01:00
@NotNull
@Override
public List<Label> getAllLabels(@NotNull final User user) {
return getHibernateTemplate().find("from com.wisemapping.model.Label wisemapping where creator_id=?", user.getId());
}
2014-01-28 06:28:16 +01:00
@Nullable
@Override
public Label getLabelById(int id) {
return getHibernateTemplate().get(Label.class, id);
}
2014-01-28 06:21:14 +01:00
@Nullable
@Override
public Label getLabelByTitle(@NotNull String title, @NotNull final User user) {
Label result = null;
final List<Label> labels = getHibernateTemplate().find("from com.wisemapping.model.Label wisemapping where title=? and creator=?", new Object[]{title, user});
if (labels != null && !labels.isEmpty()) {
result = labels.get(0);
}
return result;
}
2014-01-28 06:28:16 +01:00
}