コード例 #1
0
  @Before
  public void initialData() throws Exception {
    initialTestDatabaseCreator.dropDatabaseForJunit().checkDatabase();
    // save fileState
    fileStateModel = new FileStateModel();
    fileStateModel.setClientName("emprofMediaHandleTest");
    fileStateModel.setCustomerFormat("emprof");
    fileStateModel.setFileName("502833__49963125_urlescaped_49963171.xml.xml");
    fileStateModel.setFileSize(1L);
    // new column
    fileStateModel.setFileType(FileType.XML);
    fileStateModel.setFilePath("/a/b/c/d");
    fileStateModel.setParentFileState(null);
    fileStateModel = fileStateManager.save(fileStateModel);
    // save adstate
    adStateModel = new AdStateModel();
    adStateModel.setFileStateModel(fileStateModel);
    adStateModel.setZadObjectId(1);
    adStateModel.setzClientId(21912);
    adStateModel.setAdExternalRef("2011068");
    adStateModel = adStateManager.save(adStateModel);

    // save mediaStateModel
    mediaStateModel = new MediaStateModel();
    mediaStateModel.setAdStateModel(adStateModel);
    mediaStateModel.setContentType(MediaStateContentType.IMAGE);
    mediaStateModel.setMd5hash("730A1E3FEE8ACA06F14A4D9B1D9C0241");
    mediaStateModel.setSequenceNum(1);
    mediaStateModel.setTitle("Front Moslingsvei 44");
    mediaStateModel.setMediaStatus(MediaStatus.PRODUCTION);
    mediaStateModel.setProdref("73/0A/730A1E3FEE8ACA06F14A4D9B1D9C0241");
    // Media is not used:
    mediaStateModel.setExtref(
        "http://att.emprof.no/images/Megler-Forum/Megler%20Forum/Pictures/1024/20110681.JPG");
    mediaStateModel = mediaStateManager.save(mediaStateModel);

    mediaStateModel = new MediaStateModel();
    mediaStateModel.setAdStateModel(adStateModel);
    mediaStateModel.setContentType(MediaStateContentType.IMAGE);
    mediaStateModel.setMd5hash("md5hash1");
    mediaStateModel.setSequenceNum(99);
    mediaStateModel.setTitle("title2");
    mediaStateModel.setMediaStatus(MediaStatus.MISSING);
    mediaStateModel.setProdref("prodef");
    mediaStateModel.setExtref("pic2.jpg");
    mediaStateModel = mediaStateManager.save(mediaStateModel);

    mediaStateModel = new MediaStateModel();
    mediaStateModel.setAdStateModel(adStateModel);
    mediaStateModel.setContentType(MediaStateContentType.IMAGE);
    mediaStateModel.setMd5hash("md5hash1");
    mediaStateModel.setSequenceNum(99);
    mediaStateModel.setTitle("title3");
    mediaStateModel.setMediaStatus(MediaStatus.MISSING);
    mediaStateModel.setProdref("prodef");
    mediaStateModel.setExtref("pic3.jpg");
    mediaStateModel = mediaStateManager.save(mediaStateModel);
  }
コード例 #2
0
  @Override
  public void retrieveMediaStateList() {
    log.debug("********************");

    AdStateModel adStateModel = getAdStateModel();
    if (adStateModel != null) {
      log.debug("************* " + adStateModel.getId());
    } else {
      log.debug("************* adstate model is null");
    }

    BildeDocument.Bilde[] bildeArray = eneiendom.getBilder().getBildeArray();
    for (BildeDocument.Bilde bilde : bildeArray) {
      MediaStateModel mediaStateModel = new MediaStateModel();
      mediaStateModel.setMediaStatus(MediaStatus.MISSING);
      mediaStateModel.setContentType(MediaStateContentType.IMAGE);
      mediaStateModel.setSequenceNum(bilde.getNr().intValue());
      mediaStateModel.setAdStateModel(adStateModel);

      FeltDocument.Felt externalRef =
          extractByNavnFromFields("urloriginalbilde", bilde.getFeltArray());
      if (externalRef != null) {
        log.debug("externalRef ###############" + externalRef.getStringValue().trim());
        mediaStateModel.setMediaFileName(
            externalRef
                .getStringValue()
                .trim()
                .substring(externalRef.getStringValue().trim().lastIndexOf('\\') + 1));
        mediaStateModel.setExtref(externalRef.getStringValue());
      } else {
        mediaStateModel.setExtref("Not Found");
      }
      getMediaStateModelList().add(mediaStateModel);
      log.debug("MediaStateModel Added :: " + mediaStateModel.toString());
    }

    DokumentDocument.Dokument[] dokumentArray = eneiendom.getDokumenter().getDokumentArray();
    for (DokumentDocument.Dokument dokument : dokumentArray) {
      MediaStateModel mediaStateModel = new MediaStateModel();
      mediaStateModel.setMediaStatus(MediaStatus.MISSING);
      mediaStateModel.setContentType(MediaStateContentType.PDF);
      mediaStateModel.setSequenceNum(dokument.getNr().intValue());
      mediaStateModel.setAdStateModel(adStateModel);

      FeltDocument.Felt pdfFileName = extractByNavnFromFields("navn", dokument.getFeltArray());
      FeltDocument.Felt pdfFileUrl =
          extractByNavnFromFields("urldokument", dokument.getFeltArray());
      if (pdfFileName != null && pdfFileUrl != null) {
        log.debug("PDF File Name ===== > " + pdfFileName.getStringValue());
        log.debug("PDF URL ====> " + pdfFileUrl.getStringValue());
        mediaStateModel.setMediaFileName(pdfFileName.getStringValue() + ".pdf");
        mediaStateModel.setExtref(pdfFileUrl.getStringValue());
      } else {
        mediaStateModel.setMediaFileName("NOT FOUND");
        mediaStateModel.setExtref("NOT FOUND");
      }

      getMediaStateModelList().add(mediaStateModel);
      log.debug("MediaStateModel Added :: " + mediaStateModel.toString());
    }

    if (getMediaStateModelList() != null && getMediaStateModelList().size() > 0) {
      log.debug("Found " + getMediaStateModelList().size() + " media in the ad");
    }
  }