/**
   * 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 DDMTemplate toModel(DDMTemplateSoap soapModel) {
    if (soapModel == null) {
      return null;
    }

    DDMTemplate model = new DDMTemplateImpl();

    model.setUuid(soapModel.getUuid());
    model.setTemplateId(soapModel.getTemplateId());
    model.setGroupId(soapModel.getGroupId());
    model.setCompanyId(soapModel.getCompanyId());
    model.setUserId(soapModel.getUserId());
    model.setUserName(soapModel.getUserName());
    model.setCreateDate(soapModel.getCreateDate());
    model.setModifiedDate(soapModel.getModifiedDate());
    model.setClassNameId(soapModel.getClassNameId());
    model.setClassPK(soapModel.getClassPK());
    model.setTemplateKey(soapModel.getTemplateKey());
    model.setName(soapModel.getName());
    model.setDescription(soapModel.getDescription());
    model.setType(soapModel.getType());
    model.setMode(soapModel.getMode());
    model.setLanguage(soapModel.getLanguage());
    model.setScript(soapModel.getScript());

    return model;
  }
  protected DDMTemplate createTemplate(long templateId, String name, String mode, String script) {

    DDMTemplate template = new DDMTemplateImpl();

    template.setTemplateId(templateId);
    template.setName(name);
    template.setMode(mode);
    template.setScript(script);

    _templates.put(template.getTemplateId(), template);

    return template;
  }
Beispiel #3
0
  @Override
  protected void doExportStagedModel(PortletDataContext portletDataContext, DDMTemplate template)
      throws Exception {

    Element dlFileEntryTypesElement =
        portletDataContext.getExportDataGroupElement(DLFileEntryType.class);
    Element dlFoldersElement = portletDataContext.getExportDataGroupElement(DLFolder.class);
    Element dlFileEntriesElement = portletDataContext.getExportDataGroupElement(DLFileEntry.class);
    Element dlFileRanksElement = portletDataContext.getExportDataGroupElement(DLFileRank.class);
    Element dlRepositoriesElement = portletDataContext.getExportDataGroupElement(Repository.class);
    Element dlRepositoryEntriesElement =
        portletDataContext.getExportDataGroupElement(RepositoryEntry.class);

    Element templateElement = portletDataContext.getExportDataStagedModelElement(template);

    if (template.isSmallImage()) {
      Image smallImage = ImageUtil.fetchByPrimaryKey(template.getSmallImageId());

      if (Validator.isNotNull(template.getSmallImageURL())) {
        String smallImageURL =
            DDMPortletDataHandler.exportReferencedContent(
                portletDataContext,
                dlFileEntryTypesElement,
                dlFoldersElement,
                dlFileEntriesElement,
                dlFileRanksElement,
                dlRepositoriesElement,
                dlRepositoryEntriesElement,
                templateElement,
                template.getSmallImageURL().concat(StringPool.SPACE));

        template.setSmallImageURL(smallImageURL);
      } else if (smallImage != null) {
        String smallImagePath =
            StagedModelPathUtil.getPath(
                template,
                smallImage.getImageId() + StringPool.PERIOD + template.getSmallImageType());

        templateElement.addAttribute("small-image-path", smallImagePath);

        template.setSmallImageType(smallImage.getType());

        portletDataContext.addZipEntry(smallImagePath, smallImage.getTextObj());
      }
    }

    if (portletDataContext.getBooleanParameter(
        DDMPortletDataHandler.NAMESPACE, "embedded-assets")) {

      String content =
          DDMPortletDataHandler.exportReferencedContent(
              portletDataContext,
              dlFileEntryTypesElement,
              dlFoldersElement,
              dlFileEntriesElement,
              dlFileRanksElement,
              dlRepositoriesElement,
              dlRepositoryEntriesElement,
              templateElement,
              template.getScript());

      template.setScript(content);
    }

    portletDataContext.addClassedModel(
        templateElement,
        StagedModelPathUtil.getPath(template),
        template,
        DDMPortletDataHandler.NAMESPACE);
  }