You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
76 lines
2.8 KiB
76 lines
2.8 KiB
package com.fr.plugin.db.procedure.entity; |
|
|
|
import com.fr.stable.db.dao.BaseDAO; |
|
import com.fr.stable.db.dao.DAOProvider; |
|
import com.fr.stable.db.session.DAOSession; |
|
import com.fr.stable.query.QueryFactory; |
|
import com.fr.stable.query.condition.QueryCondition; |
|
import com.fr.stable.query.restriction.RestrictionFactory; |
|
|
|
import java.util.HashMap; |
|
import java.util.List; |
|
import java.util.UUID; |
|
|
|
public class TemplateProcedureDAO extends BaseDAO<TemplateProcedureEntity> { |
|
public TemplateProcedureDAO(DAOSession daoSession) { |
|
super(daoSession); |
|
} |
|
|
|
public void removeById(String id) throws Exception { |
|
getSession().remove(QueryFactory.create() |
|
.addRestriction(RestrictionFactory.eq("id", id)), |
|
this.getEntityClass()); |
|
} |
|
public void addEntity(TemplateProcedureEntity entity) throws Exception { |
|
entity.setId(UUID.randomUUID().toString()); |
|
getSession().persist(entity); |
|
} |
|
|
|
public void updateEntity(TemplateProcedureEntity entity) throws Exception{ |
|
HashMap<String, Object> params = new HashMap<>(); |
|
params.put("procedureName",entity.getProcedureName() ); |
|
params.put("reportPath",entity.getReportPath()); |
|
params.put("connectionName",entity.getConnectionName()); |
|
params.put("connectionId",entity.getConnectionId()); |
|
getSession().update(params, QueryFactory.create().addRestriction(RestrictionFactory.eq("id", entity.getId())), getEntityClass()); |
|
} |
|
|
|
public List<TemplateProcedureEntity> getAll() throws Exception { |
|
QueryCondition condition = QueryFactory.create(); |
|
return getSession().find(condition,getEntityClass()); |
|
} |
|
|
|
public TemplateProcedureEntity getEntityByprocedureId(String procedureId) throws Exception { |
|
QueryCondition condition = QueryFactory.create(); |
|
condition.addRestriction(RestrictionFactory.eq("procedureId",procedureId)); |
|
return getSession().findOne(condition,getEntityClass()); |
|
} |
|
|
|
public void removeAll() throws Exception{ |
|
List<TemplateProcedureEntity> list = getSession().find(QueryFactory.create(),getEntityClass()); |
|
for(TemplateProcedureEntity entity:list){ |
|
getSession().remove(QueryFactory.create() |
|
.addRestriction(RestrictionFactory.eq("id", entity.getId())), |
|
this.getEntityClass()); |
|
} |
|
|
|
|
|
} |
|
|
|
@Override |
|
protected Class<TemplateProcedureEntity> getEntityClass() { |
|
return TemplateProcedureEntity.class; |
|
} |
|
|
|
public final static DAOProvider DAO = new DAOProvider() { |
|
@Override |
|
public Class getEntityClass() { |
|
return TemplateProcedureEntity.class; |
|
} |
|
|
|
@Override |
|
public Class<? extends BaseDAO> getDAOClass() { |
|
return TemplateProcedureDAO.class; |
|
} |
|
}; |
|
}
|
|
|