Exemple #1
0
// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
string allocateEventID(DatabaseArchive *ar, const Origin *origin,
                       const string &prefix, const string &pattern,
                       const Client::Config::StringSet *blackList) {
	if ( !origin )
		return "";

	int year, yday, hour, min, sec, usec;

	if ( !origin->time().value().get2(&year, &yday, &hour, &min, &sec, &usec) )
		return "";

	uint64_t width;
	// Maximum precission is 1 millisecond
	uint64_t x = uint64_t((((yday*24)+hour)*60+min)*60+sec)*1000 + usec/1000;

	string text;
	string eventID = generateEventID(year, x, prefix, pattern, text, &width);
	ObjectPtr o = ar?ar->getObject(Event::TypeInfo(), eventID):Event::Find(eventID);
	bool blocked = (blackList != NULL) && (blackList->find(text) != blackList->end());

	if ( !o && !blocked )
		return eventID;

	if ( blocked ) SEISCOMP_WARNING("Blocked ID: %s (rejected %s)", eventID.c_str(), text.c_str());

	for ( int i = 1; i < 5; ++i ) {
		eventID = generateEventID(year, x+i*width, prefix, pattern, text);
		blocked = (blackList != NULL) && (blackList->find(text) != blackList->end());
		o = ar?ar->getObject(Event::TypeInfo(), eventID):Event::Find(eventID);
		if ( !o && !blocked )
			return eventID;
		if ( blocked ) SEISCOMP_WARNING("Blocked ID: %s (rejected %s)", eventID.c_str(), text.c_str());
	}

	for ( int i = 1; i < 5; ++i ) {
		eventID = generateEventID(year, x-i*width, prefix, pattern, text);
		blocked = (blackList != NULL) && (blackList->find(text) != blackList->end());
		o = ar?ar->getObject(Event::TypeInfo(), eventID):Event::Find(eventID);
		if ( !o && !blocked )
			return eventID;
		if ( blocked ) SEISCOMP_WARNING("Blocked ID: %s (rejected %s)", eventID.c_str(), text.c_str());
	}

	return "";
}
ApplicationActivity::ApplicationActivity(ApplicationEvent applicationEvent, Outcome outcome,
                                         ActiveParticipant appInfo)
    : event(outcome, EventActionCode::Execute, generateEventID(EventIDCode::ApplicationActivity)),
      applicationInfo(applicationInfoWithRoleIdCode(std::move(appInfo)))
{
    event.eventTypeCode = generateEventTypeCode(applicationEvent == ApplicationEvent::Started
                                                    ? EventTypeCode::ApplicationStart
                                                    : EventTypeCode::ApplicationStop);
}
InstancesAccessed::InstancesAccessed(Outcome outcome, Action action, std::string patientId)
    : event(outcome, toActionCode(action), generateEventID(EventIDCode::InstancesAccessed)),
      patient(EntityParticipantObject::Type::Person, EntityParticipantObject::Role::Patient,
              generateParticipantObjectIDTypeCode(ParticipantObjectIDTypeCode::PatientId),
              std::move(patientId)),
      manipulatingPerson(nullptr),
      manipulatingProcess(nullptr)
{
}
Exemple #4
0
Query::Query(Outcome outcome, ActiveParticipant queryingProcess, ActiveParticipant queriedProcess,
             std::string queriedSOPClassUID, std::string base64Dataset)
    : event(outcome, EventActionCode::Execute, generateEventID(EventIDCode::Query)),
      queryingProcess(std::move(queryingProcess)),
      queriedProcess(std::move(queriedProcess)),
      queriedSop(EntityParticipantObject::Type::SystemObject, EntityParticipantObject::Role::Report,
                 generateParticipantObjectIDTypeCode(ParticipantObjectIDTypeCode::SOPClassUID),
                 std::move(queriedSOPClassUID))
{
    this->queryingProcess.participant.roleIdCode = generateRoleIDCode(RoleIDCode::Source);
    this->queriedProcess.participant.roleIdCode = generateRoleIDCode(RoleIDCode::Destination);
    queriedSop.objectNameOrQuery = std::move(base64Dataset);
}