public void Destroy(int id ) { try { SessionInitializeTransaction(); EntityEN entityEN = (EntityEN)session.Load(typeof(EntityEN), id); session.Delete(entityEN); SessionCommit(); } catch (Exception ex) { SessionRollBack(); if (ex is MoSIoTGenNHibernate.Exceptions.ModelException) { throw ex; } throw new MoSIoTGenNHibernate.Exceptions.DataLayerException("Error in EntityCAD.", ex); } finally { SessionClose(); } }
public EntityEN ReadOIDDefault(int id ) { EntityEN entityEN = null; try { SessionInitializeTransaction(); entityEN = (EntityEN)session.Get(typeof(EntityEN), id); SessionCommit(); } catch (Exception ex) { SessionRollBack(); if (ex is MoSIoTGenNHibernate.Exceptions.ModelException) { throw ex; } throw new MoSIoTGenNHibernate.Exceptions.DataLayerException("Error in EntityCAD.", ex); } finally { SessionClose(); } return(entityEN); }
public int New_(string p_name, int p_scenario, string p_description) { EntityEN entityEN = null; int oid; //Initialized EntityEN entityEN = new EntityEN(); entityEN.Name = p_name; if (p_scenario != -1) { // El argumento p_scenario -> Property scenario es oid = false // Lista de oids id entityEN.Scenario = new MoSIoTGenNHibernate.EN.MosIoT.IoTScenarioEN(); entityEN.Scenario.Id = p_scenario; } entityEN.Description = p_description; //Call to EntityCAD oid = _IEntityCAD.New_(entityEN); return(oid); }
// Modify default (Update all attributes of the class) public void ModifyDefault(EntityEN entity) { try { SessionInitializeTransaction(); EntityEN entityEN = (EntityEN)session.Load(typeof(EntityEN), entity.Id); entityEN.Name = entity.Name; entityEN.Description = entity.Description; session.Update(entityEN); SessionCommit(); } catch (Exception ex) { SessionRollBack(); if (ex is MoSIoTGenNHibernate.Exceptions.ModelException) { throw ex; } throw new MoSIoTGenNHibernate.Exceptions.DataLayerException("Error in EntityCAD.", ex); } finally { SessionClose(); } }
public int New_(EntityEN entity) { try { SessionInitializeTransaction(); if (entity.Scenario != null) { // Argumento OID y no colección. entity.Scenario = (MoSIoTGenNHibernate.EN.MosIoT.IoTScenarioEN)session.Load(typeof(MoSIoTGenNHibernate.EN.MosIoT.IoTScenarioEN), entity.Scenario.Id); entity.Scenario.Entity .Add(entity); } session.Save(entity); SessionCommit(); } catch (Exception ex) { SessionRollBack(); if (ex is MoSIoTGenNHibernate.Exceptions.ModelException) { throw ex; } throw new MoSIoTGenNHibernate.Exceptions.DataLayerException("Error in EntityCAD.", ex); } finally { SessionClose(); } return(entity.Id); }
public EntityEN ReadOID(int id ) { EntityEN entityEN = null; entityEN = _IEntityCAD.ReadOID(id); return(entityEN); }
public void Modify(int p_Entity_OID, string p_name, string p_description) { EntityEN entityEN = null; //Initialized EntityEN entityEN = new EntityEN(); entityEN.Id = p_Entity_OID; entityEN.Name = p_name; entityEN.Description = p_description; //Call to EntityCAD _IEntityCAD.Modify(entityEN); }
public static IMAppointmentDTOA Convert(EntityEN en, NHibernate.ISession session = null) { IMAppointmentDTOA dto = null; IMAppointmentRESTCAD iMAppointmentRESTCAD = null; IMAppointmentCEN iMAppointmentCEN = null; IMAppointmentCP iMAppointmentCP = null; if (en != null) { dto = new IMAppointmentDTOA(); iMAppointmentRESTCAD = new IMAppointmentRESTCAD(session); iMAppointmentCEN = new IMAppointmentCEN(iMAppointmentRESTCAD); iMAppointmentCP = new IMAppointmentCP(session); IMAppointmentEN enHijo = iMAppointmentRESTCAD.ReadOIDDefault(en.Id); // // Attributes dto.Id = en.Id; dto.Name = en.Name; if (enHijo != null) { dto.Date = enHijo.Date; } dto.Description = en.Description; // // TravesalLink /* Rol: IMAppointment o--> Appointment */ dto.ValueAppointment = AppointmentAssembler.Convert((AppointmentEN)enHijo.Appointment, session); // // Service } return(dto); }
public static PatientDTOA Convert(EntityEN en, NHibernate.ISession session = null) { PatientDTOA dto = null; PatientRESTCAD patientRESTCAD = null; PatientCEN patientCEN = null; PatientCP patientCP = null; if (en != null) { dto = new PatientDTOA(); patientRESTCAD = new PatientRESTCAD(session); patientCEN = new PatientCEN(patientRESTCAD); patientCP = new PatientCP(session); PatientEN enHijo = patientRESTCAD.ReadOIDDefault(en.Id); // // Attributes dto.Id = en.Id; dto.Name = en.Name; dto.Description = en.Description; // // TravesalLink /* Rol: Patient o--> PatientProfile */ dto.PatientProfile = PatientProfileAssembler.Convert((PatientProfileEN)enHijo.PatientProfile, session); /* Rol: Patient o--> User */ dto.UserData = UserAssembler.Convert((UserEN)enHijo.UserPatient, session); // // Service } return(dto); }
public static CarePlanDTOA Convert(EntityEN en, NHibernate.ISession session = null) { CarePlanDTOA dto = null; CarePlanRESTCAD carePlanRESTCAD = null; CarePlanCEN carePlanCEN = null; CarePlanCP carePlanCP = null; if (en != null) { dto = new CarePlanDTOA(); carePlanRESTCAD = new CarePlanRESTCAD(session); carePlanCEN = new CarePlanCEN(carePlanRESTCAD); carePlanCP = new CarePlanCP(session); CarePlanEN enHijo = carePlanRESTCAD.ReadOIDDefault(en.Id); // // Attributes dto.Id = en.Id; dto.Name = en.Name; dto.Description = en.Description; // // TravesalLink /* Rol: CarePlan o--> CarePlanTemplate */ dto.CarePlanTemplate = CarePlanTemplateAssembler.Convert((CarePlanTemplateEN)enHijo.Template, session); // // Service } return(dto); }
public static PractitionerDTOA Convert(EntityEN en, NHibernate.ISession session = null) { PractitionerDTOA dto = null; PractitionerRESTCAD practitionerRESTCAD = null; PractitionerCEN practitionerCEN = null; PractitionerCP practitionerCP = null; if (en != null) { dto = new PractitionerDTOA(); practitionerRESTCAD = new PractitionerRESTCAD(session); practitionerCEN = new PractitionerCEN(practitionerRESTCAD); practitionerCP = new PractitionerCP(session); PractitionerEN enHijo = practitionerRESTCAD.ReadOIDDefault(en.Id); // // Attributes dto.Id = en.Id; dto.Name = en.Name; dto.Description = en.Description; // // TravesalLink /* Rol: Practitioner o--> User */ dto.PractitionerData = UserAssembler.Convert((UserEN)enHijo.UserPractitioner, session); // // Service } return(dto); }
public static VitalSignDTOA Convert(EntityEN en, NHibernate.ISession session = null) { VitalSignDTOA dto = null; VitalSignRESTCAD vitalSignRESTCAD = null; VitalSignCEN vitalSignCEN = null; VitalSignCP vitalSignCP = null; if (en != null) { dto = new VitalSignDTOA(); vitalSignRESTCAD = new VitalSignRESTCAD(session); vitalSignCEN = new VitalSignCEN(vitalSignRESTCAD); vitalSignCP = new VitalSignCP(session); VitalSignEN enHijo = vitalSignRESTCAD.ReadOIDDefault(en.Id); // // Attributes dto.Id = en.Id; dto.Name = en.Name; dto.Description = en.Description; // // TravesalLink /* Rol: VitalSign o--> Measure */ dto.MeasureVitalSign = MeasureAssembler.Convert((MeasureEN)enHijo.Measure, session); // // Service } return(dto); }
public static IMCommunicationDTOA Convert(EntityEN en, NHibernate.ISession session = null) { IMCommunicationDTOA dto = null; IMCommunicationRESTCAD iMCommunicationRESTCAD = null; IMCommunicationCEN iMCommunicationCEN = null; IMCommunicationCP iMCommunicationCP = null; if (en != null) { dto = new IMCommunicationDTOA(); iMCommunicationRESTCAD = new IMCommunicationRESTCAD(session); iMCommunicationCEN = new IMCommunicationCEN(iMCommunicationRESTCAD); iMCommunicationCP = new IMCommunicationCP(session); IMCommunicationEN enHijo = iMCommunicationRESTCAD.ReadOIDDefault(en.Id); // // Attributes dto.Id = en.Id; dto.Name = en.Name; dto.Description = en.Description; // // TravesalLink /* Rol: IMCommunication o--> Comunication */ dto.ValueCommunication = ComunicationAssembler.Convert((ComunicationEN)enHijo.Comunication, session); // // Service } return(dto); }
public static IMTelemetryDTOA Convert(EntityEN en, NHibernate.ISession session = null) { IMTelemetryDTOA dto = null; IMTelemetryRESTCAD iMTelemetryRESTCAD = null; IMTelemetryCEN iMTelemetryCEN = null; IMTelemetryCP iMTelemetryCP = null; if (en != null) { dto = new IMTelemetryDTOA(); iMTelemetryRESTCAD = new IMTelemetryRESTCAD(session); iMTelemetryCEN = new IMTelemetryCEN(iMTelemetryRESTCAD); iMTelemetryCP = new IMTelemetryCP(session); IMTelemetryEN enHijo = iMTelemetryRESTCAD.ReadOIDDefault(en.Id); // // Attributes dto.Id = en.Id; dto.Name = en.Name; dto.Description = en.Description; // // TravesalLink /* Rol: IMTelemetry o--> Telemetry */ dto.Telemetry = TelemetryAssembler.Convert((TelemetryEN)enHijo.Telemetry, session); // // Service } return(dto); }
public static PatientAccessDTOA Convert (EntityEN en, NHibernate.ISession session = null) { PatientAccessDTOA dto = null; PatientAccessRESTCAD patientAccessRESTCAD = null; PatientAccessCEN patientAccessCEN = null; PatientAccessCP patientAccessCP = null; if (en != null) { dto = new PatientAccessDTOA (); patientAccessRESTCAD = new PatientAccessRESTCAD (session); patientAccessCEN = new PatientAccessCEN (patientAccessRESTCAD); patientAccessCP = new PatientAccessCP (session); PatientAccessEN enHijo = patientAccessRESTCAD.ReadOIDDefault (en.Id); // // Attributes dto.Id = en.Id; dto.Name = en.Name; dto.Description = en.Description; // // TravesalLink /* Rol: PatientAccess o--> AccessMode */ dto.AccessMode = AccessModeAssembler.Convert ((AccessModeEN)enHijo.AccessMode, session); // // Service } return dto; }
public static RelatedPersonDTOA Convert(EntityEN en, NHibernate.ISession session = null) { RelatedPersonDTOA dto = null; RelatedPersonRESTCAD relatedPersonRESTCAD = null; RelatedPersonCEN relatedPersonCEN = null; RelatedPersonCP relatedPersonCP = null; if (en != null) { dto = new RelatedPersonDTOA(); relatedPersonRESTCAD = new RelatedPersonRESTCAD(session); relatedPersonCEN = new RelatedPersonCEN(relatedPersonRESTCAD); relatedPersonCP = new RelatedPersonCP(session); RelatedPersonEN enHijo = relatedPersonRESTCAD.ReadOIDDefault(en.Id); // // Attributes dto.Id = en.Id; dto.Name = en.Name; dto.Description = en.Description; // // TravesalLink /* Rol: RelatedPerson o--> User */ dto.RpData = UserAssembler.Convert((UserEN)enHijo.UserRelatedPerson, session); // // Service } return(dto); }
public HttpResponseMessage ReadOID(int idEntity) { // CAD, CEN, EN, returnValue EntityRESTCAD entityRESTCAD = null; EntityCEN entityCEN = null; EntityEN entityEN = null; EntityDTOA returnValue = null; try { SessionInitializeWithoutTransaction(); entityRESTCAD = new EntityRESTCAD(session); entityCEN = new EntityCEN(entityRESTCAD); // Data entityEN = entityCEN.ReadOID(idEntity); // Convert return if (entityEN != null) { returnValue = EntityAssembler.Convert(entityEN, session); } } catch (Exception e) { if (e.GetType() == typeof(HttpResponseException)) { throw e; } else if (e.GetType() == typeof(MoSIoTGenNHibernate.Exceptions.ModelException) && e.Message.Equals("El token es incorrecto")) { throw new HttpResponseException(HttpStatusCode.Forbidden); } else if (e.GetType() == typeof(MoSIoTGenNHibernate.Exceptions.ModelException) || e.GetType() == typeof(MoSIoTGenNHibernate.Exceptions.DataLayerException)) { throw new HttpResponseException(HttpStatusCode.BadRequest); } else { throw new HttpResponseException(HttpStatusCode.InternalServerError); } } finally { SessionClose(); } // Return 404 - Not found if (returnValue == null) { return(this.Request.CreateResponse(HttpStatusCode.NotFound)); } // Return 200 - OK else { return(this.Request.CreateResponse(HttpStatusCode.OK, returnValue)); } }
public static EntityDTOA Convert(EntityEN en, NHibernate.ISession session = null) { EntityDTOA dto = null; EntityRESTCAD entityRESTCAD = null; EntityCEN entityCEN = null; EntityCP entityCP = null; if (en != null) { dto = new EntityDTOA(); entityRESTCAD = new EntityRESTCAD(session); entityCEN = new EntityCEN(entityRESTCAD); entityCP = new EntityCP(session); // // Attributes dto.Id = en.Id; // // TravesalLink /* Rol: Entity o--> Association */ dto.OriginAssociations = null; List <AssociationEN> OriginAssociations = entityRESTCAD.OriginAssociations(en.Id).ToList(); if (OriginAssociations != null) { dto.OriginAssociations = new List <AssociationDTOA>(); foreach (AssociationEN entry in OriginAssociations) { dto.OriginAssociations.Add(AssociationAssembler.Convert(entry, session)); } } /* Rol: Entity o--> Association */ dto.TargetAssociations = null; List <AssociationEN> TargetAssociations = entityRESTCAD.TargetAssociations(en.Id).ToList(); if (TargetAssociations != null) { dto.TargetAssociations = new List <AssociationDTOA>(); foreach (AssociationEN entry in TargetAssociations) { dto.TargetAssociations.Add(AssociationAssembler.Convert(entry, session)); } } /* Rol: Entity o--> EntityAttributes */ dto.Attributes = null; List <EntityAttributesEN> Attributes = entityRESTCAD.Attributes(en.Id).ToList(); if (Attributes != null) { dto.Attributes = new List <EntityAttributesDTOA>(); foreach (EntityAttributesEN entry in Attributes) { dto.Attributes.Add(EntityAttributesAssembler.Convert(entry, session)); } } /* Rol: Entity o--> EntityOperation */ dto.Operations = null; List <EntityOperationEN> Operations = entityRESTCAD.Operations(en.Id).ToList(); if (Operations != null) { dto.Operations = new List <EntityOperationDTOA>(); foreach (EntityOperationEN entry in Operations) { dto.Operations.Add(EntityOperationAssembler.Convert(entry, session)); } } // // Service } return(dto); }
public static DeviceDTOA Convert(EntityEN en, NHibernate.ISession session = null) { DeviceDTOA dto = null; DeviceRESTCAD deviceRESTCAD = null; DeviceCEN deviceCEN = null; DeviceCP deviceCP = null; if (en != null) { dto = new DeviceDTOA(); deviceRESTCAD = new DeviceRESTCAD(session); deviceCEN = new DeviceCEN(deviceRESTCAD); deviceCP = new DeviceCP(session); DeviceEN enHijo = deviceRESTCAD.ReadOIDDefault(en.Id); // // Attributes dto.Id = en.Id; if (enHijo != null) { dto.DeviceSwitch = enHijo.DeviceSwitch; } if (enHijo != null) { dto.Tag = enHijo.Tag; } if (enHijo != null) { dto.IsSimulated = enHijo.IsSimulated; } if (enHijo != null) { dto.SerialNumber = enHijo.SerialNumber; } if (enHijo != null) { dto.FirmVersion = enHijo.FirmVersion; } if (enHijo != null) { dto.Trademark = enHijo.Trademark; } dto.Name = en.Name; dto.Description = en.Description; // // TravesalLink /* Rol: Device o--> DeviceTemplate */ dto.DeviceTemplate = DeviceTemplateAssembler.Convert((DeviceTemplateEN)enHijo.DeviceTemplate, session); // // Service } return(dto); }
public static EntityEN Convert(EntityDTO dto) { EntityEN newinstance = null; try { if (dto != null) { newinstance = new EntityEN(); newinstance.Id = dto.Id; newinstance.Name = dto.Name; if (dto.OriginAssociation_oid != null) { MoSIoTGenNHibernate.CAD.MosIoT.IAssociationCAD associationCAD = new MoSIoTGenNHibernate.CAD.MosIoT.AssociationCAD(); newinstance.OriginAssociation = new System.Collections.Generic.List <MoSIoTGenNHibernate.EN.MosIoT.AssociationEN>(); foreach (int entry in dto.OriginAssociation_oid) { newinstance.OriginAssociation.Add(associationCAD.ReadOIDDefault(entry)); } } if (dto.TargetAssociation_oid != null) { MoSIoTGenNHibernate.CAD.MosIoT.IAssociationCAD associationCAD = new MoSIoTGenNHibernate.CAD.MosIoT.AssociationCAD(); newinstance.TargetAssociation = new System.Collections.Generic.List <MoSIoTGenNHibernate.EN.MosIoT.AssociationEN>(); foreach (int entry in dto.TargetAssociation_oid) { newinstance.TargetAssociation.Add(associationCAD.ReadOIDDefault(entry)); } } if (dto.Scenario_oid != -1) { MoSIoTGenNHibernate.CAD.MosIoT.IIoTScenarioCAD ioTScenarioCAD = new MoSIoTGenNHibernate.CAD.MosIoT.IoTScenarioCAD(); newinstance.Scenario = ioTScenarioCAD.ReadOIDDefault(dto.Scenario_oid); } newinstance.Description = dto.Description; if (dto.Operations != null) { MoSIoTGenNHibernate.CAD.MosIoT.IEntityOperationCAD entityOperationCAD = new MoSIoTGenNHibernate.CAD.MosIoT.EntityOperationCAD(); newinstance.Operations = new System.Collections.Generic.List <MoSIoTGenNHibernate.EN.MosIoT.EntityOperationEN>(); foreach (EntityOperationDTO entry in dto.Operations) { newinstance.Operations.Add(EntityOperationAssemblerDTO.Convert(entry)); } } if (dto.Attributes != null) { MoSIoTGenNHibernate.CAD.MosIoT.IEntityAttributesCAD entityAttributesCAD = new MoSIoTGenNHibernate.CAD.MosIoT.EntityAttributesCAD(); newinstance.Attributes = new System.Collections.Generic.List <MoSIoTGenNHibernate.EN.MosIoT.EntityAttributesEN>(); foreach (EntityAttributesDTO entry in dto.Attributes) { newinstance.Attributes.Add(EntityAttributesAssemblerDTO.Convert(entry)); } } if (dto.States != null) { MoSIoTGenNHibernate.CAD.MosIoT.IEntityStateCAD entityStateCAD = new MoSIoTGenNHibernate.CAD.MosIoT.EntityStateCAD(); newinstance.States = new System.Collections.Generic.List <MoSIoTGenNHibernate.EN.MosIoT.EntityStateEN>(); foreach (EntityStateDTO entry in dto.States) { newinstance.States.Add(EntityStateAssemblerDTO.Convert(entry)); } } } } catch (Exception ex) { throw ex; } return(newinstance); }