661 lines
12 KiB
C++
Executable File
661 lines
12 KiB
C++
Executable File
/*
|
|
* SimpleDBModel.h
|
|
*
|
|
* Created on: 09.05.2014
|
|
* Author: matthias
|
|
*/
|
|
|
|
#ifndef SIMPLEDBMODEL_H_
|
|
#define SIMPLEDBMODEL_H_
|
|
|
|
#include <wfr/common/types/WfsTypes.h>
|
|
#include <odb/core.hxx>
|
|
#include <vector>
|
|
#include <memory>
|
|
#include <string>
|
|
|
|
namespace wfr {
|
|
namespace eventsystem {
|
|
#pragma db namespace session
|
|
namespace odbmodel {
|
|
|
|
class Workflow;
|
|
class Activity;
|
|
class ActivityInstance;
|
|
class WorkflowStatusEvent;
|
|
class ActivityStatusEvent;
|
|
class ActivityInstanceStatusEvent;
|
|
|
|
|
|
#pragma db value(wfr_id_t) type("BigInt")
|
|
#pragma db value(wfr_size_t) type("BigInt")
|
|
|
|
|
|
#pragma db object pointer(std::shared_ptr)
|
|
class Workflow {
|
|
|
|
friend class odb::access;
|
|
|
|
private:
|
|
#pragma db id auto
|
|
uint32_t oid;
|
|
|
|
wfr_id_t wfid;
|
|
|
|
std::string uuid;
|
|
|
|
std::string name;
|
|
|
|
#pragma db inverse(parentWorkflow)
|
|
std::vector<std::weak_ptr<Activity>> activities;
|
|
|
|
std::weak_ptr<Activity> toplevelActivity;
|
|
|
|
#pragma db inverse(parentWorkflow)
|
|
std::vector<std::weak_ptr<WorkflowStatusEvent>> statusEvents;
|
|
|
|
|
|
public:
|
|
Workflow() : oid(0), wfid(0) {}
|
|
|
|
Workflow(wfr_id_t wfid, std::string uuid) : oid(0), wfid(wfid), uuid(uuid) {}
|
|
|
|
std::vector<std::weak_ptr<Activity> >& getActivities() {
|
|
return activities;
|
|
}
|
|
|
|
const std::string& getName() const {
|
|
return name;
|
|
}
|
|
|
|
void setName(const std::string& name) {
|
|
this->name = name;
|
|
}
|
|
|
|
const std::weak_ptr<Activity>& getToplevelActivity() const {
|
|
return toplevelActivity;
|
|
}
|
|
|
|
void setToplevelActivity(const std::weak_ptr<Activity>& toplevelActivity) {
|
|
this->toplevelActivity = toplevelActivity;
|
|
}
|
|
|
|
wfr_id_t getOid() const {
|
|
return oid;
|
|
}
|
|
|
|
const std::string& getUuid() const {
|
|
return uuid;
|
|
}
|
|
|
|
wfr_id_t getWfid() const {
|
|
return wfid;
|
|
}
|
|
|
|
void setWfid(wfr_id_t wfid) {
|
|
this->wfid = wfid;
|
|
}
|
|
};
|
|
|
|
#pragma db object pointer(std::shared_ptr)
|
|
class WorkflowStatusEvent {
|
|
|
|
friend class odb::access;
|
|
|
|
private:
|
|
#pragma db id auto
|
|
uint32_t oid;
|
|
|
|
#pragma db not_null
|
|
std::shared_ptr<Workflow> parentWorkflow;
|
|
|
|
std::string newStatus;
|
|
|
|
std::string oldStatus;
|
|
|
|
uint64_t timestamp;
|
|
|
|
public:
|
|
WorkflowStatusEvent() : oid(0), timestamp(0) {}
|
|
|
|
const std::string& getNewStatus() {
|
|
return newStatus;
|
|
}
|
|
|
|
void setNewStatus(const std::string& newStatus) {
|
|
this->newStatus = newStatus;
|
|
}
|
|
|
|
wfr_id_t getOid() {
|
|
return oid;
|
|
}
|
|
|
|
const std::string& getOldStatus() {
|
|
return oldStatus;
|
|
}
|
|
|
|
void setOldStatus(const std::string& oldStatus) {
|
|
this->oldStatus = oldStatus;
|
|
}
|
|
|
|
const std::shared_ptr<Workflow>& getParentWorkflow() {
|
|
return parentWorkflow;
|
|
}
|
|
|
|
void setParentWorkflow(const std::shared_ptr<Workflow>& parentWorkflow) {
|
|
this->parentWorkflow = parentWorkflow;
|
|
}
|
|
|
|
uint64_t getTimestamp() {
|
|
return timestamp;
|
|
}
|
|
|
|
void setTimestamp(uint64_t timestamp) {
|
|
this->timestamp = timestamp;
|
|
}
|
|
};
|
|
|
|
|
|
|
|
#pragma db object pointer(std::shared_ptr)
|
|
class Activity {
|
|
|
|
friend class odb::access;
|
|
|
|
private:
|
|
#pragma db id auto
|
|
uint32_t oid;
|
|
|
|
wfr_id_t actid;
|
|
|
|
std::string name;
|
|
|
|
#pragma db not_null
|
|
std::shared_ptr<Workflow> parentWorkflow;
|
|
|
|
std::shared_ptr<Activity> parent;
|
|
|
|
#pragma db inverse(parentActivity)
|
|
std::vector<std::weak_ptr<ActivityStatusEvent>> statusEvents;
|
|
|
|
std::string type;
|
|
|
|
wfr_id_t branchID;
|
|
|
|
#pragma db inverse(baseActivity)
|
|
std::vector<std::weak_ptr<ActivityInstance>> instances;
|
|
|
|
std::vector<std::weak_ptr<Activity>> successors;
|
|
|
|
std::vector<std::weak_ptr<Activity>> predecessors;
|
|
|
|
public:
|
|
Activity() : oid(0), actid(0), branchID(0) {}
|
|
|
|
Activity(wfr_id_t actid, wfr_id_t branchid) : oid(0), actid(actid), branchID(branchid) {}
|
|
|
|
wfr_id_t getBranchId() const {
|
|
return branchID;
|
|
}
|
|
|
|
std::vector<std::weak_ptr<ActivityInstance> >& getInstances() {
|
|
return instances;
|
|
}
|
|
|
|
const std::string& getName() const {
|
|
return name;
|
|
}
|
|
|
|
void setName(const std::string& name) {
|
|
this->name = name;
|
|
}
|
|
|
|
const std::shared_ptr<Workflow>& getParentWorkflow() const {
|
|
return parentWorkflow;
|
|
}
|
|
|
|
void setParentWorkflow(const std::shared_ptr<Workflow>& parentWorkflow) {
|
|
this->parentWorkflow = parentWorkflow;
|
|
}
|
|
|
|
const std::shared_ptr<Activity>& getParent() const {
|
|
return parent;
|
|
}
|
|
|
|
void setParent(const std::shared_ptr<Activity>& parent) {
|
|
this->parent = parent;
|
|
}
|
|
|
|
std::vector<std::weak_ptr<Activity> >& getPredecessors() {
|
|
return predecessors;
|
|
}
|
|
|
|
std::vector<std::weak_ptr<Activity> >& getSuccessors() {
|
|
return successors;
|
|
}
|
|
|
|
const std::string& getType() const {
|
|
return type;
|
|
}
|
|
|
|
void setType(const std::string& type) {
|
|
this->type = type;
|
|
}
|
|
|
|
wfr_id_t getOid() const {
|
|
return oid;
|
|
}
|
|
|
|
wfr_id_t getActid() const {
|
|
return actid;
|
|
}
|
|
|
|
void setActid(wfr_id_t actid) {
|
|
this->actid = actid;
|
|
}
|
|
};
|
|
|
|
|
|
#pragma db object pointer(std::shared_ptr)
|
|
class ActivityStatusEvent {
|
|
|
|
friend class odb::access;
|
|
|
|
private:
|
|
#pragma db id auto
|
|
uint32_t oid;
|
|
|
|
#pragma db not_null
|
|
std::shared_ptr<Activity> parentActivity;
|
|
|
|
std::string newStatus;
|
|
|
|
std::string oldStatus;
|
|
|
|
uint64_t timestamp;
|
|
|
|
public:
|
|
ActivityStatusEvent() : oid(0), timestamp(0) {}
|
|
|
|
const std::string& getNewStatus() {
|
|
return newStatus;
|
|
}
|
|
|
|
void setNewStatus(const std::string& newStatus) {
|
|
this->newStatus = newStatus;
|
|
}
|
|
|
|
wfr_id_t getOid() {
|
|
return oid;
|
|
}
|
|
|
|
const std::string& getOldStatus() {
|
|
return oldStatus;
|
|
}
|
|
|
|
void setOldStatus(const std::string& oldStatus) {
|
|
this->oldStatus = oldStatus;
|
|
}
|
|
|
|
const std::shared_ptr<Activity>& getParentActivity() {
|
|
return parentActivity;
|
|
}
|
|
|
|
void setParentActivity(const std::shared_ptr<Activity>& parentActivity) {
|
|
this->parentActivity = parentActivity;
|
|
}
|
|
|
|
uint64_t getTimestamp() {
|
|
return timestamp;
|
|
}
|
|
|
|
void setTimestamp(uint64_t timestamp) {
|
|
this->timestamp = timestamp;
|
|
}
|
|
};
|
|
|
|
|
|
#pragma db object pointer(std::shared_ptr)
|
|
class ActivityInstance {
|
|
|
|
friend class odb::access;
|
|
|
|
private:
|
|
#pragma db id auto
|
|
uint32_t oid;
|
|
|
|
wfr_id_t instid;
|
|
|
|
wfr_id_t iterationID;
|
|
|
|
std::vector<std::weak_ptr<ActivityInstance>> successors;
|
|
|
|
std::vector<std::weak_ptr<ActivityInstance>> predecessors;
|
|
|
|
#pragma db not_null
|
|
std::shared_ptr<Activity> baseActivity;
|
|
|
|
#pragma db not_null
|
|
std::shared_ptr<Workflow> parentWorkflow;
|
|
|
|
std::shared_ptr<ActivityInstance> parentInstance;
|
|
|
|
#pragma db inverse(parentInstance)
|
|
std::vector<std::weak_ptr<ActivityInstanceStatusEvent>> statusEvents;
|
|
|
|
public:
|
|
ActivityInstance() : oid(0), instid(0), iterationID(0) {}
|
|
|
|
ActivityInstance(wfr_id_t instid, wfr_id_t iterationID) : oid(0), instid(instid), iterationID(iterationID) {}
|
|
|
|
wfr_id_t getInstid() {
|
|
return instid;
|
|
}
|
|
|
|
void setInstid(wfr_id_t instid) {
|
|
this->instid = instid;
|
|
}
|
|
|
|
wfr_id_t getIterationId() {
|
|
return iterationID;
|
|
}
|
|
|
|
void setIterationId(wfr_id_t iterationId) {
|
|
iterationID = iterationId;
|
|
}
|
|
|
|
wfr_id_t getOid() {
|
|
return oid;
|
|
}
|
|
|
|
std::shared_ptr<Activity>& getBaseActivity() {
|
|
return baseActivity;
|
|
}
|
|
|
|
void setBaseActivity(std::shared_ptr<Activity>& parentActivity) {
|
|
this->baseActivity = parentActivity;
|
|
}
|
|
|
|
std::vector<std::weak_ptr<ActivityInstance> >& getPredecessors() {
|
|
return predecessors;
|
|
}
|
|
|
|
std::vector<std::weak_ptr<ActivityInstance> >& getSuccessors() {
|
|
return successors;
|
|
}
|
|
|
|
const std::shared_ptr<ActivityInstance>& getParentInstance() const {
|
|
return parentInstance;
|
|
}
|
|
|
|
void setParentInstance(
|
|
const std::shared_ptr<ActivityInstance>& parentInstance) {
|
|
this->parentInstance = parentInstance;
|
|
}
|
|
|
|
std::shared_ptr<Workflow>& getParentWorkflow() {
|
|
return parentWorkflow;
|
|
}
|
|
|
|
void setParentWorkflow(std::shared_ptr<Workflow>& parentWorkflow) {
|
|
this->parentWorkflow = parentWorkflow;
|
|
}
|
|
};
|
|
|
|
|
|
#pragma db object pointer(std::shared_ptr)
|
|
class ActivityInstanceStatusEvent {
|
|
|
|
friend class odb::access;
|
|
|
|
private:
|
|
#pragma db id auto
|
|
uint32_t oid;
|
|
|
|
#pragma db not_null
|
|
std::shared_ptr<ActivityInstance> parentInstance;
|
|
|
|
std::string newStatus;
|
|
|
|
std::string oldStatus;
|
|
|
|
uint64_t timestamp;
|
|
|
|
public:
|
|
ActivityInstanceStatusEvent() : oid(0), timestamp(0) {}
|
|
|
|
const std::string& getNewStatus() {
|
|
return newStatus;
|
|
}
|
|
|
|
void setNewStatus(const std::string& newStatus) {
|
|
this->newStatus = newStatus;
|
|
}
|
|
|
|
wfr_id_t getOid() {
|
|
return oid;
|
|
}
|
|
|
|
const std::string& getOldStatus() {
|
|
return oldStatus;
|
|
}
|
|
|
|
void setOldStatus(const std::string& oldStatus) {
|
|
this->oldStatus = oldStatus;
|
|
}
|
|
|
|
const std::shared_ptr<ActivityInstance>& getParentInstance() {
|
|
return parentInstance;
|
|
}
|
|
|
|
void setParentInstance(const std::shared_ptr<ActivityInstance>& parentActivity) {
|
|
this->parentInstance = parentActivity;
|
|
}
|
|
|
|
uint64_t getTimestamp() {
|
|
return timestamp;
|
|
}
|
|
|
|
void setTimestamp(uint64_t timestamp) {
|
|
this->timestamp = timestamp;
|
|
}
|
|
};
|
|
|
|
|
|
#pragma db object pointer(std::shared_ptr)
|
|
class DeviceInstanceStatusEvent {
|
|
|
|
friend class odb::access;
|
|
|
|
private:
|
|
#pragma db id auto
|
|
uint32_t oid;
|
|
|
|
std::shared_ptr<Workflow> parentWorkflow;
|
|
|
|
std::string deviceType;
|
|
|
|
wfr_id_t deviceID;
|
|
|
|
wfr_id_t deviceSubID;
|
|
|
|
std::string newStatus;
|
|
|
|
std::string oldStatus;
|
|
|
|
uint64_t timestamp;
|
|
|
|
std::shared_ptr<ActivityInstance> executedInstance;
|
|
|
|
wfr_id_t executedImplID;
|
|
|
|
wfr_size_t deviceSlotCount;
|
|
|
|
public:
|
|
DeviceInstanceStatusEvent() : oid(0), deviceID(0), deviceSubID(0), timestamp(0), executedImplID(0), deviceSlotCount(0) {}
|
|
|
|
const std::string& getNewStatus() {
|
|
return newStatus;
|
|
}
|
|
|
|
void setNewStatus(const std::string& newStatus) {
|
|
this->newStatus = newStatus;
|
|
}
|
|
|
|
wfr_id_t getOid() {
|
|
return oid;
|
|
}
|
|
|
|
const std::string& getOldStatus() {
|
|
return oldStatus;
|
|
}
|
|
|
|
void setOldStatus(const std::string& oldStatus) {
|
|
this->oldStatus = oldStatus;
|
|
}
|
|
|
|
const std::shared_ptr<Workflow>& getParentWorkflow() {
|
|
return parentWorkflow;
|
|
}
|
|
|
|
void setParentWorkflow(const std::shared_ptr<Workflow>& parentWorkflow) {
|
|
this->parentWorkflow = parentWorkflow;
|
|
}
|
|
|
|
uint64_t getTimestamp() {
|
|
return timestamp;
|
|
}
|
|
|
|
void setTimestamp(uint64_t timestamp) {
|
|
this->timestamp = timestamp;
|
|
}
|
|
|
|
wfr_id_t getDeviceId() {
|
|
return deviceID;
|
|
}
|
|
|
|
wfr_id_t getDeviceSubId() {
|
|
return deviceSubID;
|
|
}
|
|
|
|
void setDeviceId(wfr_id_t deviceId) {
|
|
deviceID = deviceId;
|
|
}
|
|
|
|
void setDeviceSubId(wfr_id_t deviceSubId) {
|
|
deviceSubID = deviceSubId;
|
|
}
|
|
|
|
wfr_size_t getDeviceSlotCount() {
|
|
return deviceSlotCount;
|
|
}
|
|
|
|
void setDeviceSlotCount(wfr_size_t deviceSlotCount) {
|
|
this->deviceSlotCount = deviceSlotCount;
|
|
}
|
|
|
|
const std::string& getDeviceType() {
|
|
return deviceType;
|
|
}
|
|
|
|
void setDeviceType(const std::string& deviceType) {
|
|
this->deviceType = deviceType;
|
|
}
|
|
|
|
wfr_id_t getExecutedImplId() {
|
|
return executedImplID;
|
|
}
|
|
|
|
void setExecutedImplId(wfr_id_t executedImplId) {
|
|
executedImplID = executedImplId;
|
|
}
|
|
|
|
const std::shared_ptr<ActivityInstance>& getExecutedInstance() {
|
|
return executedInstance;
|
|
}
|
|
|
|
void setExecutedInstance(const std::shared_ptr<ActivityInstance>& executedInstance) {
|
|
this->executedInstance = executedInstance;
|
|
}
|
|
};
|
|
|
|
|
|
#pragma db object pointer(std::shared_ptr)
|
|
class ComponentStatusEvent {
|
|
|
|
friend class odb::access;
|
|
|
|
private:
|
|
#pragma db id auto
|
|
uint32_t oid;
|
|
|
|
std::shared_ptr<Workflow> workflow;
|
|
|
|
std::string componentType;
|
|
|
|
std::string newStatus;
|
|
|
|
std::string oldStatus;
|
|
|
|
uint64_t timestamp;
|
|
|
|
public:
|
|
ComponentStatusEvent() : oid(0), timestamp(0) {}
|
|
|
|
std::string& getComponentType() {
|
|
return componentType;
|
|
}
|
|
|
|
void setComponentType(const std::string& componentType) {
|
|
this->componentType = componentType;
|
|
}
|
|
|
|
std::string& getNewStatus() {
|
|
return newStatus;
|
|
}
|
|
|
|
void setNewStatus(const std::string& newStatus) {
|
|
this->newStatus = newStatus;
|
|
}
|
|
|
|
wfr_id_t getOid() {
|
|
return oid;
|
|
}
|
|
|
|
std::string& getOldStatus() {
|
|
return oldStatus;
|
|
}
|
|
|
|
void setOldStatus(const std::string& oldStatus) {
|
|
this->oldStatus = oldStatus;
|
|
}
|
|
|
|
uint64_t getTimestamp() {
|
|
return timestamp;
|
|
}
|
|
|
|
void setTimestamp(uint64_t timestamp) {
|
|
this->timestamp = timestamp;
|
|
}
|
|
|
|
std::shared_ptr<Workflow>& getWorkflow() {
|
|
return workflow;
|
|
}
|
|
|
|
void setWorkflow(const std::shared_ptr<Workflow>& workflow) {
|
|
this->workflow = workflow;
|
|
}
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
} /* namespace odbmodel */
|
|
} /* namespace eventsystem */
|
|
} /* namespace wfr */
|
|
|
|
|
|
|
|
#endif /* SIMPLEDBMODEL_H_ */
|