/**
   * Converts the soap model instance into a normal model instance.
   *
   * @param soapModel the soap model instance to convert
   * @return the normal model instance
   */
  public static Gadget toModel(GadgetSoap soapModel) {
    Gadget model = new GadgetImpl();

    model.setUuid(soapModel.getUuid());
    model.setGadgetId(soapModel.getGadgetId());
    model.setCompanyId(soapModel.getCompanyId());
    model.setCreateDate(soapModel.getCreateDate());
    model.setModifiedDate(soapModel.getModifiedDate());
    model.setName(soapModel.getName());
    model.setUrl(soapModel.getUrl());
    model.setPortletCategoryNames(soapModel.getPortletCategoryNames());

    return model;
  }
  @Override
  protected void doImportStagedModel(PortletDataContext portletDataContext, Gadget gadget)
      throws Exception {

    ServiceContext serviceContext = portletDataContext.createServiceContext(gadget);

    Gadget importedGadget = null;

    if (portletDataContext.isDataStrategyMirror()) {
      Gadget existingGadget =
          GadgetLocalServiceUtil.fetchGadgetByUuidAndCompanyId(
              gadget.getUuid(), portletDataContext.getCompanyId());

      if (existingGadget == null) {
        serviceContext.setUuid(gadget.getUuid());

        importedGadget =
            GadgetLocalServiceUtil.addGadget(
                portletDataContext.getCompanyId(),
                gadget.getUrl(),
                gadget.getPortletCategoryNames(),
                serviceContext);
      } else {
        existingGadget.setName(gadget.getName());
        existingGadget.setUrl(gadget.getUrl());
        existingGadget.setPortletCategoryNames(gadget.getPortletCategoryNames());

        importedGadget = GadgetLocalServiceUtil.updateGadget(existingGadget);
      }
    } else {
      importedGadget =
          GadgetLocalServiceUtil.addGadget(
              portletDataContext.getCompanyId(),
              gadget.getUrl(),
              gadget.getPortletCategoryNames(),
              serviceContext);
    }

    portletDataContext.importClassedModel(gadget, importedGadget);
  }