public class Department {
public static void employee(String name, String department) {
User.create(name,department);
}
}
@Entity
public class Kind {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
public int id = -1;
public String name;
public Kind(String name) {
this.name = name;
}
public static Kind create(String name) {
Kind kind = new Kind(name);
Context.em.persist(kind);
return kind;
}
public void addBatchTaskToUsers(String task) {
List<User> users = users();
for (User user : users) {
Task taskEntity = new Task(task, this);
Context.em.persist(taskEntity);
user.applyTask(taskEntity);
}
}
public List<User> users() {
Query query = Context.em
.createQuery("select distinct u from User as u inner join u.kinds as kind where kind = ?1");
query.setParameter(1, this);
return query.getResultList();
}
}
@Entity
public class Task {
public Task(String task,Kind kind) {
this.kind = kind;
this.task = task;
}
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
public int id = -1;
public Date startTime;
public Date endTime;
public String task;
@ManyToOne
public User owner;
@ManyToOne
public Kind kind;
public static Task create(String name, Kind kind) {
Task task = new Task(name,kind);
Context.em.persist(task);
return task;
}
private static Date getCurrentMonthBegin()
{
Calendar calendar = Calendar.getInstance();
calendar.set(Calendar.DAY_OF_MONTH,0);
Date begin = calendar.getTime();
return begin;
}
public static Date getCurrentMonthEnd()
{
Calendar calendar = Calendar.getInstance();
calendar.set(Calendar.DAY_OF_MONTH, calendar.getMaximum(Calendar.DAY_OF_MONTH));
Date end = calendar.getTime();
return end;
}
public static List<Task> allTask_CurrentMonth() {
Date begin = getCurrentMonthBegin();
Date end = getCurrentMonthEnd();
Query query = Context.em.createQuery("from Task as t where t.startTime >= ?1 and t.startTime <= ?2");
query.setParameter(1,begin);
query.setParameter(2,end);
return query.getResultList();
}
public static List<Task> processingTasks_CurrentMonth() {
Date begin = getCurrentMonthBegin();
Date end = getCurrentMonthEnd();
Query query = Context.em.createQuery("from Task as t where t.startTime >= ?1 and t.startTime <= ?2 and t.endTime is null");
query.setParameter(1,begin);
query.setParameter(2,end);
return query.getResultList();
}
public static List<Task> processedTasks_CurrentMonth() {
Date begin = getCurrentMonthBegin();
Date end = getCurrentMonthEnd();
Query query = Context.em.createQuery("from Task as t where t.endTime >= ?1 and t.endTime <= ?2 ");
query.setParameter(1,begin);
query.setParameter(2,end);
return query.getResultList();
}
}
@Entity
public class User {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
public int id = -1;
public String name;
public String department;
@OneToMany
public List<Kind> kinds = new ArrayList<Kind>();
public User(String name, String department) {
this.name = name;
this.department = department;
}
public Tasks tasks = new Tasks(this);
class Tasks {
private User user;
public Tasks(User user) {
this.user = user;
}
public Task find_by_name(String task) {
Query query = Context.em
.createQuery("from Task t where t.owner = ?1 and t.task = ?2");
query.setParameter(1, user);
query.setParameter(2, task);
return (Task) query.getSingleResult();
}
public List<Task> processing_tasks() {
Query query = Context.em
.createQuery("from Task t where t.startTime <= ?1 and t.owner = ?2 and t.endTime is null");
query.setParameter(1, new Date());
query.setParameter(2, user);
return query.getResultList();
}
public boolean detectProcessingTask(String task) {
for(Task taskEntity:processing_tasks())
{
if(task.equals(taskEntity.task))
{
return true;
}
}
return false;
}
}
public static User find_By_Name_And_Department(String name,
String department) {
Query query = Context.em
.createQuery("from User u where u.name = ?1 and u.department = ?2");
query.setParameter(1, name);
query.setParameter(2, department);
return (User) query.getSingleResult();
}
public static User create(String name, String department) {
User user = new User(name, department);
Context.em.persist(user);
return user;
}
public void applyTask(Task task) {
task.owner = this;
task.startTime = new Date();
Context.em.persist(task);
}
public static List<Task> all_processing_tasks() {
Query query = Context.em
.createQuery("from Task t where t.startTime <= ?1 and t.endTime is null");
query.setParameter(1, new Date());
return query.getResultList();
}
public void endTask(Task task) {
task.endTime = new Date();
}
}
分享到:
相关推荐
8. **领域模型(Domain Model)**:整个DDD的核心,它反映了业务领域的知识和规则。Java代码中的领域模型类应尽可能地表达业务语言。 9. **策略(Strategy)**:将算法封装为可替换的策略对象,使得算法可以在不...
首先,领域驱动设计的核心在于“领域模型”(Domain Model),它是对业务领域的抽象和模拟。在船运系统中,领域模型可能包括船、货物、航线、港口等实体(Entity)和值对象(Value Object)。实体是具有唯一标识的...
5. **查询和过滤**:使用Elasticsearch提供的查询DSL(Domain Specific Language)来执行地理位置查询。例如,查找距离特定点一定范围内的地点: ```ruby Location.search(query: { geo_distance: { distance: '...
The research presented in this thesis contributes to the advancement of handwritten digit recognition within the broader domain of artificial intelligence. By comparing the performance of two ...
3. 领域模型(Domain Model):包含业务逻辑和规则,是系统的核心部分。在CQRS中,领域模型可能会包含事件发布(Event Publishing)机制,当命令处理器完成对状态的修改后,会触发相应事件。 4. 事件处理器(Event ...
- **crossdomain.xml:** 为了允许跨域数据访问,需要正确配置`crossdomain.xml`文件。 - **网络资源代理:** 对于敏感数据的访问,可以通过网络资源代理来增加一层保护。 #### 七、附录A: Configuration XML 配置...
2. 粗排ESDM(Entire Space Domain Adaptation Model)模型:该模型可以解决召回模块的样本选择偏差问题。 3. 集合选择技术:该技术可以放弃对值的精准预估,以集合选择为目标,从而释放一部分算力。 4. 以学习后...
2. **PixelDragons.MVCSample.Domain** - 这个文件夹可能包含了示例项目的领域模型,即业务逻辑和实体类,这是MVC模式中的"Model"部分。 3. **PixelDragons.MVC** - 这可能包含了pixeldragonsmvc框架的核心组件,如...
1. **MVC架构**:Grails遵循Model-View-Controller(MVC)设计模式,使得代码组织结构清晰,便于维护和扩展。模型负责业务逻辑,视图负责数据展示,控制器则协调两者之间的交互。 2. **GORM(Grails Object ...
Unfortunately, such signals are only sparse in the discrete Fourier transform (DFT) domain when the sinusoid frequencies live precisely at the center of the DFT bins. When this is not the case, CS ...
Rosie divides your application in three layers, view, domain and repository. View: It contains all your presentation logic, implemented through the [Model-View-Presenter pattern][mvp
The examples use a common model from an overarching sample application, giving you a context from which to start and helping you to understand the examples within an already familiar domain....
This article summarize today state and application domain of machine-learning and Support Vector Machine,expound basic concept and basic model of machine-learning and Support Vector Machine and ...
Broadband (1.6–18 THz) terahertz time-domain spectroscopy (THz-TDS) and time-resolved terahertz spectroscopy (TRTS) were performed on a 54 μm thick chalcogenide glass (As30Se30Te40) sample with a ...
在"PixelDragons.MVCSample.Domain"目录中,我们可以预见到包含实体类(Entity Class)和可能的数据访问层(Data Access Layer)。这些实体类通常对应数据库中的表,它们封装了数据和操作数据的方法。NHibernate,...
蛋堆通过朱拉克·安蒂娜(Julac Ontina) 该框架基于Java Spring Boot中的Controller-Domain-Repository-Service(CDRS)框架或结构。 它旨在替换Softboiled-MVC,因为发现可以将Model-Controller-View(MVC)进一步...
Accurate and Diverse Sampling of Sequences based on a “Best of Many” Sample Objective .pdf Actor and Action Video Segmentation from a Sentence .pdf An Analysis of Scale Invariance in Object ...
The Frequency Domain and the Fourier Transform Ideal Sampling and Reconstruction Aliasing Antialiasing Techniques Application to Image Synthesis Sources of Aliasing in Rendering Understanding ...
import com.sample.domain.Message; import com.sample.domain.Address; //声明一个Country类型Fact declare Country countryName: String countryCode: String createDate: Date end global List myGlobalList...