View Javadoc
1   /*
2    * Licensed to The Apereo Foundation under one or more contributor license
3    * agreements. See the NOTICE file distributed with this work for additional
4    * information regarding copyright ownership.
5    *
6    *
7    * The Apereo Foundation licenses this file to you under the Educational
8    * Community License, Version 2.0 (the "License"); you may not use this file
9    * except in compliance with the License. You may obtain a copy of the License
10   * at:
11   *
12   *   http://opensource.org/licenses/ecl2.txt
13   *
14   * Unless required by applicable law or agreed to in writing, software
15   * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
16   * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
17   * License for the specific language governing permissions and limitations under
18   * the License.
19   *
20   */
21  
22  package org.opencastproject.workflow.api;
23  
24  import javax.persistence.Column;
25  import javax.persistence.Entity;
26  import javax.persistence.EntityResult;
27  import javax.persistence.FieldResult;
28  import javax.persistence.Id;
29  import javax.persistence.NamedNativeQueries;
30  import javax.persistence.NamedNativeQuery;
31  import javax.persistence.SqlResultSetMapping;
32  import javax.persistence.Table;
33  
34  /**
35   * Summary of the workflow stats necessary for index rebuild,
36   * for use in repopulate and update (immutable)
37   */
38  @Table(name = "oc_workflow")
39  @Entity
40  @NamedNativeQueries({
41          @NamedNativeQuery(
42                  name = "WorkflowIndexData.getAll",
43                  query = "SELECT id, state, mediapackage_id, organization_id FROM oc_workflow ORDER BY mediapackage_id, id DESC",
44                  resultSetMapping = "DataResult"
45          ),
46  })
47  @SqlResultSetMapping(
48          name = "DataResult",
49          entities = {
50                  @EntityResult(
51                          entityClass = WorkflowIndexData.class,
52                          fields = {
53                                    @FieldResult(name = "id",column = "id"),
54                                    @FieldResult(name = "state", column = "state"),
55                                    @FieldResult(name = "mediaPackageId", column = "mediapackage_id"),
56                                    @FieldResult(name = "organizationId", column = "organization_id")
57                          }
58                  )
59  })
60  
61  
62  public class WorkflowIndexData {
63    @Id
64    private Long id;
65    private int state;
66  
67    @Column(name = "mediapackage_id", length = 128) //NB: This column definition needs to match WorkflowInstance!
68    private String mediaPackageId;
69  
70    @Column(name = "organization_id") //NB: This column definition needs to match WorkflowInstance!
71    private String organizationId;
72  
73  
74    /**
75     * Default constructor without any import.
76     */
77    public WorkflowIndexData() {
78  
79    }
80  
81    public WorkflowIndexData(Long id, int state, String mediaPackageId, String organizationId) {
82      this.id = id;
83      this.state = state;
84      this.mediaPackageId = mediaPackageId;
85      this.organizationId = organizationId;
86    }
87  
88    public Long getId() {
89      return id;
90    }
91  
92    public int getState() {
93      return state;
94    }
95  
96    public String getMediaPackageId() {
97      return mediaPackageId;
98    }
99  
100   public String getOrganizationId() {
101     return organizationId;
102   }
103 
104 }