Remove trunk directory
This commit is contained in:
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache 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.apache.org/licenses/LICENSE-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.
|
||||
*
|
||||
* $Id: file 64488 2006-03-10 17:32:09Z paulo $
|
||||
*/
|
||||
|
||||
package com.wisemapping.dao;
|
||||
|
||||
import com.wisemapping.model.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface MindmapManager {
|
||||
|
||||
Colaborator getColaboratorBy(String email);
|
||||
|
||||
Colaborator getColaboratorBy(long id);
|
||||
|
||||
List<MindmapUser> getMindmapUserByColaborator(final long colaboratorId);
|
||||
|
||||
List<MindmapUser> getMindmapUserByRole(final UserRole userRole);
|
||||
|
||||
MindmapUser getMindmapUserBy(final int mindmapId, final User user);
|
||||
|
||||
List<MindMap> getAllMindmaps();
|
||||
|
||||
MindMap getMindmapById(int mindmapId);
|
||||
|
||||
MindMap getMindmapByTitle(final String name, final User user);
|
||||
|
||||
void addColaborator (Colaborator colaborator);
|
||||
|
||||
void addMindmap(User user, MindMap mindMap);
|
||||
|
||||
public void addView(int mapId);
|
||||
|
||||
void saveMindmap(MindMap mindMap);
|
||||
|
||||
void updateMindmap(MindMap mindMap, boolean saveHistory);
|
||||
|
||||
void removeColaborator(Colaborator colaborator);
|
||||
|
||||
void removeMindmap(MindMap mindap);
|
||||
|
||||
void removeMindmapUser(MindmapUser mindmapUser);
|
||||
|
||||
public List<MindMap> search(MindMapCriteria criteria);
|
||||
|
||||
public List<MindMap> search(MindMapCriteria criteria, int maxResult);
|
||||
|
||||
public List<MindMapHistory> getHistoryFrom(int mindmapId);
|
||||
|
||||
public MindMapHistory getHistory(int historyId);
|
||||
}
|
@@ -0,0 +1,203 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache 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.apache.org/licenses/LICENSE-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.
|
||||
*
|
||||
* $Id: file 64488 2006-03-10 17:32:09Z paulo $
|
||||
*/
|
||||
|
||||
package com.wisemapping.dao;
|
||||
|
||||
import com.wisemapping.model.*;
|
||||
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
|
||||
import org.hibernate.criterion.Restrictions;
|
||||
import org.hibernate.criterion.SimpleExpression;
|
||||
import org.hibernate.criterion.Junction;
|
||||
import org.hibernate.criterion.Order;
|
||||
import org.hibernate.Criteria;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Calendar;
|
||||
|
||||
public class MindmapManagerImpl
|
||||
extends HibernateDaoSupport
|
||||
implements MindmapManager {
|
||||
|
||||
public Colaborator getColaboratorBy(final String email) {
|
||||
final Colaborator colaborator;
|
||||
final List colaborators = getHibernateTemplate().find("from com.wisemapping.model.Colaborator colaborator where email=?", email);
|
||||
if (colaborators != null && !colaborators.isEmpty()) {
|
||||
assert colaborators.size() == 1 : "More than one user with the same username!";
|
||||
colaborator = (Colaborator) colaborators.get(0);
|
||||
} else {
|
||||
colaborator = null;
|
||||
}
|
||||
return colaborator;
|
||||
}
|
||||
|
||||
public List<MindMap> search(MindMapCriteria criteria) {
|
||||
return search(criteria,-1);
|
||||
}
|
||||
|
||||
public List<MindMapHistory> getHistoryFrom(int mindmapId)
|
||||
{
|
||||
final Criteria hibernateCriteria = getSession().createCriteria(MindMapHistory.class);
|
||||
hibernateCriteria.add(Restrictions.eq("mindmapId",mindmapId));
|
||||
hibernateCriteria.addOrder( Order.desc("creationTime"));
|
||||
// Mientras no haya paginacion solo los 10 primeros
|
||||
hibernateCriteria.setMaxResults(10);
|
||||
return hibernateCriteria.list();
|
||||
}
|
||||
|
||||
public MindMapHistory getHistory(int historyId)
|
||||
{
|
||||
return (MindMapHistory) getHibernateTemplate().get(MindMapHistory.class, historyId);
|
||||
}
|
||||
|
||||
public List<MindMap> search(MindMapCriteria criteria, int maxResult) {
|
||||
final Criteria hibernateCriteria = getSession().createCriteria(MindMap.class);
|
||||
//always search public maps
|
||||
hibernateCriteria.add(Restrictions.like("public", Boolean.TRUE));
|
||||
|
||||
if (criteria != null) {
|
||||
final Junction junction;
|
||||
if (criteria.isOrCriteria()) {
|
||||
junction = Restrictions.disjunction();
|
||||
} else {
|
||||
junction = Restrictions.conjunction();
|
||||
}
|
||||
|
||||
if (criteria.getTitle() != null && criteria.getTitle().length() > 0) {
|
||||
final SimpleExpression titleRestriction = Restrictions.like("title", "%" + criteria.getTitle() + "%");
|
||||
junction.add(titleRestriction);
|
||||
}
|
||||
|
||||
if (criteria.getDescription() != null && criteria.getDescription().length() > 0) {
|
||||
final SimpleExpression descriptionRestriction = Restrictions.like("description", "%" + criteria.getDescription() + "%");
|
||||
junction.add(descriptionRestriction);
|
||||
}
|
||||
if (criteria.getTags().size() > 0) {
|
||||
for (String tag : criteria.getTags()) {
|
||||
final SimpleExpression tagRestriction = Restrictions.like("tags", "%" + tag + "%");
|
||||
junction.add(tagRestriction);
|
||||
}
|
||||
}
|
||||
|
||||
hibernateCriteria.add(junction);
|
||||
}
|
||||
// if (maxResult>0)
|
||||
// {
|
||||
// hibernateCriteria.setMaxResults(maxResult);
|
||||
// }
|
||||
return hibernateCriteria.list();
|
||||
}
|
||||
|
||||
public Colaborator getColaboratorBy(long id) {
|
||||
return (Colaborator) getHibernateTemplate().get(Colaborator.class, id);
|
||||
}
|
||||
|
||||
public List<MindmapUser> getMindmapUserByColaborator(final long colaboratorId) {
|
||||
return getHibernateTemplate().find("from com.wisemapping.model.MindmapUser mindmapUser where colaborator_id=?", colaboratorId);
|
||||
}
|
||||
|
||||
public List<MindmapUser> getMindmapUserByRole(final UserRole userRole) {
|
||||
return getHibernateTemplate().find("from com.wisemapping.model.MindmapUser mindmapUser where roleId=?", userRole.ordinal());
|
||||
}
|
||||
|
||||
public MindmapUser getMindmapUserBy(final int mindmapId, final User user) {
|
||||
final MindmapUser result;
|
||||
|
||||
final List<MindmapUser> mindMaps = getHibernateTemplate().find("from com.wisemapping.model.MindmapUser mindmapUser where mindMap.id=? and colaborator_id=?", new Object[]{mindmapId, user.getId()});
|
||||
if (mindMaps != null && !mindMaps.isEmpty()) {
|
||||
result = mindMaps.get(0);
|
||||
} else {
|
||||
result = null;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public void addColaborator(Colaborator colaborator) {
|
||||
assert colaborator != null : "ADD MINDMAP COLABORATOR: Colaborator is required!";
|
||||
getHibernateTemplate().save(colaborator);
|
||||
}
|
||||
|
||||
public void removeMindmapUser(MindmapUser mindmapUser) {
|
||||
getHibernateTemplate().delete(mindmapUser);
|
||||
}
|
||||
|
||||
public void removeColaborator(Colaborator colaborator) {
|
||||
getHibernateTemplate().delete(colaborator);
|
||||
}
|
||||
|
||||
public List<MindMap> getAllMindmaps() {
|
||||
return getHibernateTemplate().find("from com.wisemapping.model.MindMap wisemapping");
|
||||
}
|
||||
|
||||
public MindMap getMindmapById(int mindmapId) {
|
||||
return (MindMap) getHibernateTemplate().get(MindMap.class, mindmapId);
|
||||
}
|
||||
|
||||
public MindMap getMindmapByTitle(final String title, final User user) {
|
||||
final MindMap result;
|
||||
List<MindMap> mindMaps = getHibernateTemplate().find("from com.wisemapping.model.MindMap wisemapping where title=? and creator=?", new Object[]{title, user.getUsername()});
|
||||
if (mindMaps != null && !mindMaps.isEmpty()) {
|
||||
result = mindMaps.get(0);
|
||||
} else {
|
||||
result = null;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public void addView(int mapId)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void addMindmap(User user, MindMap mindMap) {
|
||||
saveMindmap(mindMap);
|
||||
}
|
||||
|
||||
public void saveMindmap(MindMap mindMap) {
|
||||
assert mindMap != null : "Save Mindmap: Mindmap is required!";
|
||||
getSession().saveOrUpdate(mindMap.getNativeBrowser());
|
||||
getSession().save(mindMap);
|
||||
}
|
||||
|
||||
public void updateMindmap(MindMap mindMap, boolean saveHistory) {
|
||||
assert mindMap != null : "Save Mindmap: Mindmap is required!";
|
||||
getHibernateTemplate().saveOrUpdate(mindMap.getNativeBrowser());
|
||||
getHibernateTemplate().saveOrUpdate(mindMap);
|
||||
if (saveHistory)
|
||||
{
|
||||
saveHistory(mindMap);
|
||||
}
|
||||
}
|
||||
|
||||
public void removeMindmap(MindMap mindMap) {
|
||||
getHibernateTemplate().delete(mindMap);
|
||||
}
|
||||
|
||||
public void saveHistory(MindMap mindMap)
|
||||
{
|
||||
final MindMapHistory history = new MindMapHistory();
|
||||
|
||||
history.setXml(mindMap.getXml());
|
||||
history.setCreationTime(Calendar.getInstance());
|
||||
history.setCreator(mindMap.getLastModifierUser());
|
||||
history.setMindmapId(mindMap.getId());
|
||||
getHibernateTemplate().saveOrUpdate(history);
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache 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.apache.org/licenses/LICENSE-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.
|
||||
*
|
||||
* $Id: file 64488 2006-03-10 17:32:09Z paulo $
|
||||
*/
|
||||
|
||||
package com.wisemapping.dao;
|
||||
|
||||
import com.wisemapping.model.User;
|
||||
import com.wisemapping.model.UserLogin;
|
||||
import com.wisemapping.model.Colaborator;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface UserManager {
|
||||
|
||||
List<User> getAllUsers();
|
||||
|
||||
User getUserBy(String email);
|
||||
|
||||
public User getUserBy(long id);
|
||||
|
||||
User getUserByUsername(String username);
|
||||
|
||||
boolean authenticate(String email, String password);
|
||||
|
||||
void createUser(User user);
|
||||
|
||||
void auditLogin(UserLogin userLogin);
|
||||
|
||||
void updateUser(User user);
|
||||
|
||||
User getUserByActivationCode(long code);
|
||||
|
||||
public Colaborator getColaboratorBy(String email);
|
||||
|
||||
public User createUser(User user, Colaborator col);
|
||||
}
|
@@ -0,0 +1,143 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache 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.apache.org/licenses/LICENSE-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.
|
||||
*
|
||||
* $Id: file 64488 2006-03-10 17:32:09Z paulo $
|
||||
*/
|
||||
|
||||
package com.wisemapping.dao;
|
||||
|
||||
import com.wisemapping.model.Colaborator;
|
||||
import com.wisemapping.model.MindmapUser;
|
||||
import com.wisemapping.model.User;
|
||||
import com.wisemapping.model.UserLogin;
|
||||
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
|
||||
import org.acegisecurity.providers.encoding.PasswordEncoder;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public class UserManagerImpl
|
||||
extends HibernateDaoSupport
|
||||
implements UserManager {
|
||||
|
||||
private PasswordEncoder passwordEncoder;
|
||||
|
||||
public void setPasswordEncoder(PasswordEncoder passwordEncoder)
|
||||
{
|
||||
this.passwordEncoder = passwordEncoder;
|
||||
}
|
||||
|
||||
public List<User> getAllUsers() {
|
||||
return getHibernateTemplate().find("from com.wisemapping.model.User user");
|
||||
}
|
||||
|
||||
public User getUserBy(final String email) {
|
||||
final User user;
|
||||
final List users = getHibernateTemplate().find("from com.wisemapping.model.User colaborator where email=?", email);
|
||||
if (users != null && !users.isEmpty()) {
|
||||
assert users.size() == 1 : "More than one user with the same email!";
|
||||
user = (User) users.get(0);
|
||||
} else {
|
||||
user = null;
|
||||
}
|
||||
return user;
|
||||
}
|
||||
|
||||
public Colaborator getColaboratorBy(final String email) {
|
||||
final Colaborator cola;
|
||||
final List cols = getHibernateTemplate().find("from com.wisemapping.model.Colaborator colaborator where email=?", email);
|
||||
if (cols != null && !cols.isEmpty()) {
|
||||
assert cols.size() == 1 : "More than one colaborator with the same email!";
|
||||
cola = (Colaborator) cols.get(0);
|
||||
} else {
|
||||
cola = null;
|
||||
}
|
||||
return cola;
|
||||
}
|
||||
|
||||
public User getUserBy(long id)
|
||||
{
|
||||
return (User)getHibernateTemplate().get(User.class,id);
|
||||
}
|
||||
|
||||
public User getUserByUsername(String username) {
|
||||
final User user;
|
||||
final List users = getHibernateTemplate().find("from com.wisemapping.model.User colaborator where username=?", username);
|
||||
if (users != null && !users.isEmpty()) {
|
||||
assert users.size() == 1 : "More than one user with the same username!";
|
||||
user = (User) users.get(0);
|
||||
} else {
|
||||
user = null;
|
||||
}
|
||||
return user;
|
||||
}
|
||||
|
||||
public boolean authenticate(final String email, final String password) {
|
||||
final boolean result;
|
||||
final User user = getUserBy(email);
|
||||
result = user != null && user.getPassword().equals(password);
|
||||
return result;
|
||||
}
|
||||
|
||||
public void createUser(User user) {
|
||||
assert user != null : "Trying to store a null user";
|
||||
user.setPassword(passwordEncoder.encodePassword(user.getPassword(),null));
|
||||
getHibernateTemplate().saveOrUpdate(user);
|
||||
}
|
||||
|
||||
public User createUser(User user, Colaborator col)
|
||||
{
|
||||
user.setPassword(passwordEncoder.encodePassword(user.getPassword(),null));
|
||||
assert user != null : "Trying to store a null user";
|
||||
|
||||
final Set<MindmapUser> set = col.getMindmapUsers();
|
||||
for (MindmapUser mindmapUser : set) {
|
||||
MindmapUser newMapUser = new MindmapUser();
|
||||
newMapUser.setRoleId(mindmapUser.getRole().ordinal());
|
||||
newMapUser.setMindMap(mindmapUser.getMindMap());
|
||||
newMapUser.setColaborator(user);
|
||||
user.addMindmapUser(newMapUser);
|
||||
}
|
||||
|
||||
getHibernateTemplate().delete(col);
|
||||
getHibernateTemplate().flush();
|
||||
getHibernateTemplate().saveOrUpdate(user);
|
||||
return user;
|
||||
}
|
||||
|
||||
public void auditLogin(UserLogin userLogin) {
|
||||
assert userLogin != null : "userLogin is null";
|
||||
getHibernateTemplate().save(userLogin);
|
||||
}
|
||||
|
||||
public void updateUser(User user) {
|
||||
assert user != null : "user is null";
|
||||
user.setPassword(passwordEncoder.encodePassword(user.getPassword(),null));
|
||||
getHibernateTemplate().update(user);
|
||||
}
|
||||
|
||||
public User getUserByActivationCode(long code) {
|
||||
final User user;
|
||||
final List users = getHibernateTemplate().find("from com.wisemapping.model.User user where activationCode=?", code);
|
||||
if (users != null && !users.isEmpty()) {
|
||||
assert users.size() == 1 : "More than one user with the same username!";
|
||||
user = (User) users.get(0);
|
||||
} else {
|
||||
user = null;
|
||||
}
|
||||
return user;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user