Package org.openbravo.model.ad.utility

Examples of org.openbravo.model.ad.utility.Image


        log4j.debug("InitialClientSetup - createClient - m_info: " + m_info.toString());
      // Add images
      Client newClient = OBDal.getInstance().get(Client.class, AD_Client_ID);
      SystemInformation sys = OBDal.getInstance().get(SystemInformation.class, "0");
      if (sys.getYourCompanyBigImage() != null) {
        Image yourCompanyBigImage = OBProvider.getInstance().get(Image.class);
        yourCompanyBigImage.setClient(newClient);
        yourCompanyBigImage.setBindaryData(sys.getYourCompanyBigImage().getBindaryData());
        yourCompanyBigImage.setName(sys.getYourCompanyBigImage().getName());
        newClient.getClientInformationList().get(0).setYourCompanyBigImage(yourCompanyBigImage);
        OBDal.getInstance().save(yourCompanyBigImage);
      }

      if (sys.getYourCompanyDocumentImage() != null) {
        Image yourCompanyDocumentImage = OBProvider.getInstance().get(Image.class);
        yourCompanyDocumentImage.setClient(newClient);
        yourCompanyDocumentImage.setBindaryData(sys.getYourCompanyDocumentImage().getBindaryData());
        yourCompanyDocumentImage.setName(sys.getYourCompanyBigImage().getName());
        newClient.getClientInformationList().get(0).setYourCompanyDocumentImage(
            yourCompanyDocumentImage);
        OBDal.getInstance().save(yourCompanyDocumentImage);
      }

      if (sys.getYourCompanyMenuImage() != null) {
        Image yourCompanyMenuImage = OBProvider.getInstance().get(Image.class);
        yourCompanyMenuImage.setClient(newClient);
        yourCompanyMenuImage.setBindaryData(sys.getYourCompanyMenuImage().getBindaryData());
        yourCompanyMenuImage.setName(sys.getYourCompanyMenuImage().getName());
        newClient.getClientInformationList().get(0).setYourCompanyMenuImage(yourCompanyMenuImage);
        OBDal.getInstance().save(yourCompanyMenuImage);
      }

      OBDal.getInstance().save(newClient);
View Full Code Here


  public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException,
      ServletException {

    VariablesSecureApp vars = new VariablesSecureApp(request);
    String id = vars.getStringParameter("id");
    Image img = null;
    try {
      img = OBDal.getInstance().get(Image.class, id);
    } catch (Exception e) {
      log4j.error("Could not load image from database", e);
    }

    if (img != null) {
      byte[] imageBytes = img.getBindaryData();
      if (imageBytes != null) {
        OutputStream out = response.getOutputStream();
        response.setContentLength(imageBytes.length);
        out.write(imageBytes);
        out.close();
View Full Code Here

    if (logo == null || logo.equals(""))
      return;

    OBContext.enableAsAdminContext();
    try {
      Image img = null;
      if (logo.equals("yourcompanylogin")) {
        img = OBDal.getInstance().get(SystemInformation.class, "0").getYourCompanyLoginImage();
      } else if (logo.equals("youritservicelogin")) {
        img = OBDal.getInstance().get(SystemInformation.class, "0").getYourItServiceLoginImage();
      } else if (logo.equals("yourcompanymenu")) {
        img = OBDal.getInstance().get(ClientInformation.class,
            OBContext.getOBContext().getCurrentClient().getId()).getYourCompanyMenuImage();
        if (img == null)
          img = OBDal.getInstance().get(SystemInformation.class, "0").getYourCompanyMenuImage();
      } else if (logo.equals("yourcompanybig")) {
        img = OBDal.getInstance().get(ClientInformation.class,
            OBContext.getOBContext().getCurrentClient().getId()).getYourCompanyBigImage();
        if (img == null)
          img = OBDal.getInstance().get(SystemInformation.class, "0").getYourCompanyBigImage();
      } else if (logo.equals("yourcompanydoc")) {
        String orgId = vars.getStringParameter("orgId");
        if (orgId != null && !orgId.equals("")) {
          Organization org = OBDal.getInstance().get(Organization.class, orgId);
          img = org.getOrganizationInformationList().get(0).getYourCompanyDocumentImage();
        }
        if (img == null)
          img = OBDal.getInstance().get(SystemInformation.class, "0").getYourCompanyDocumentImage();
      } else
        return;
      byte[] imageBytes = null;
      if (img != null) {
        imageBytes = img.getBindaryData();
        OutputStream out = response.getOutputStream();
        response.setContentLength(imageBytes.length);
        out.write(imageBytes);
        out.close();
      } else {
View Full Code Here

    } else if (vars.commandIn("SAVE")) {
      final FileItem fi = vars.getMultiFile("inpFile");
      byte[] bytea = fi.get();

      // Using DAL to write the image data to the database
      Image image;
      if (imageID == null || imageID.equals("")) {
        image = OBProvider.getInstance().get(Image.class);
        image.setBindaryData(bytea);
        image.setActive(true);
        image.setName("Image");
        OBDal.getInstance().save(image);
        OBDal.getInstance().flush();

      } else {
        image = OBDal.getInstance().get(Image.class, imageID);
        image.setActive(true);
        image.setBindaryData(bytea);
        OBDal.getInstance().flush();
      }
      response.setContentType("text/html; charset=UTF-8");
      PrintWriter writer = response.getWriter();
      writeRedirect(writer, image.getId(), columnName);
    } else if (vars.commandIn("DELETE")) {
      if (imageID != null && !imageID.equals("")) {
        boolean adminMode = OBContext.getOBContext().setInAdministratorMode(true);
        try {
          Image image = OBDal.getInstance().get(Image.class, imageID);
          Table table = OBDal.getInstance().get(Table.class, tableId);
          String propertyName = ModelProvider.getInstance().getEntityByTableName(
              table.getDBTableName()).getPropertyByColumnName(columnName).getName();
          DataPackage dpackage = table.getDataPackage();
          try {
View Full Code Here

      log4j.debug("InitialOrgSetup - createOrg - m_info last: " + m_info.toString());
    // Add images
    Organization newOrganization = OBDal.getInstance().get(Organization.class, AD_Org_ID);
    Client organizationClient = OBDal.getInstance().get(Client.class, AD_Client_ID);
    if (organizationClient.getClientInformationList().get(0).getYourCompanyDocumentImage() != null) {
      Image yourCompanyDocumentImage = OBProvider.getInstance().get(Image.class);
      yourCompanyDocumentImage.setClient(organizationClient);
      yourCompanyDocumentImage.setOrganization(newOrganization);
      yourCompanyDocumentImage.setBindaryData(organizationClient.getClientInformationList().get(0)
          .getYourCompanyDocumentImage().getBindaryData());
      yourCompanyDocumentImage.setName(organizationClient.getClientInformationList().get(0)
          .getYourCompanyDocumentImage().getName());
      newOrganization.getOrganizationInformationList().get(0).setYourCompanyDocumentImage(
          yourCompanyDocumentImage);
      yourCompanyDocumentImage.setOrganization(newOrganization);
      OBDal.getInstance().save(yourCompanyDocumentImage);
    }
    OBDal.getInstance().save(newOrganization);
    OBDal.getInstance().flush();
    return true;
View Full Code Here

          int numRead = 0;
          while (offset < bytes.length
              && (numRead = is.read(bytes, offset, bytes.length - offset)) >= 0) {
            offset += numRead;
          }
          Image image = OBProvider.getInstance().get(Image.class);
          image.setBindaryData(bytes);
          image.setName("Image");
          getLog().info("Inserting image with property: " + properties[i]);
          OBDal.getInstance().save(image);
          OBDal.getInstance().get(SystemInformation.class, "0").set(properties[i], image);
          OBDal.getInstance().flush();
        } else {
View Full Code Here

TOP

Related Classes of org.openbravo.model.ad.utility.Image

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.