package com.l7tech.gateway.common.service;

import com.l7tech.objectmodel.Goid;
import com.l7tech.objectmodel.GoidAdapter;
import com.l7tech.objectmodel.imp.PersistentEntityImp;
import com.l7tech.objectmodel.migration.Migration;
import com.l7tech.objectmodel.migration.MigrationMappingSelection;
import com.l7tech.objectmodel.migration.PropertyResolver.Type;
import com.l7tech.util.DeserializeSafe;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.Table;
import jakarta.persistence.Version;
import jakarta.xml.bind.annotation.XmlRootElement;
import jakarta.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import org.hibernate.annotations.Proxy;

@XmlRootElement
@Entity
@Proxy(lazy = false)
@Table(name = "service_documents")
@DeserializeSafe
public class ServiceDocument extends PersistentEntityImp {
   private Goid serviceId;
   private String uri;
   private String type;
   private String contentType;
   private String contents;
   static final long serialVersionUID = -1663151882055805516L;

   public ServiceDocument() {
   }

   public ServiceDocument(ServiceDocument var1, boolean var2) {
      if (var2) {
         this.setGoid(var1.getGoid());
         this.setVersion(var1.getVersion());
      }

      this.setServiceId(var1.getServiceId());
      this.setUri(var1.getUri());
      this.setType(var1.getType());
      this.setContentType(var1.getContentType());
      this.setContents(var1.getContents());
   }

   @Migration(mapName = MigrationMappingSelection.NONE, mapValue = MigrationMappingSelection.NONE, resolver = Type.SERVICE)
   @XmlJavaTypeAdapter(GoidAdapter.class)
   @Column(name = "service_goid")
   @org.hibernate.annotations.Type(type = "com.l7tech.server.util.GoidType")
   public Goid getServiceId() {
      return this.serviceId;
   }

   public void setServiceId(Goid var1) {
      this.serviceId = var1;
   }

   @NotNull
   @Size(min = 1, max = 32)
   @Column(name = "type")
   public String getType() {
      return this.type;
   }

   public void setType(String var1) {
      this.type = var1;
   }

   @NotNull
   @Size(min = 1, max = 4096)
   @Column(name = "uri")
   public String getUri() {
      return this.uri;
   }

   public void setUri(String var1) {
      this.uri = var1;
   }

   @NotNull
   @Size(min = 1, max = 32)
   @Column(name = "content_type")
   public String getContentType() {
      return this.contentType;
   }

   public void setContentType(String var1) {
      this.contentType = var1;
   }

   @NotNull
   @Size(min = 1, max = 5242880)
   @Column(name = "content")
   public String getContents() {
      return this.contents;
   }

   public void setContents(String var1) {
      this.contents = var1;
   }

   @Version
   @Column(name = "version")
   public int getVersion() {
      return super.getVersion();
   }
}
