org.jbpm.document.Document.getLink()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(13.6k)|赞(0)|评价(0)|浏览(90)

本文整理了Java中org.jbpm.document.Document.getLink()方法的一些代码示例,展示了Document.getLink()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Document.getLink()方法的具体详情如下:
包路径:org.jbpm.document.Document
类名称:Document
方法名:getLink

Document.getLink介绍

暂无

代码示例

代码示例来源:origin: kiegroup/jbpm

@Override
public byte[] marshal(Context context, ObjectOutputStream objectOutputStream, Object o) throws IOException {
  Document document = (Document) o;
  String updatedAttribute = document.getAttribute(Document.UPDATED_ATTRIBUTE);
  if (Boolean.parseBoolean(updatedAttribute)) {
    // store via service only when it was actually updated
    documentStorageService.saveDocument(document, document.getContent());
    document.addAttribute(Document.UPDATED_ATTRIBUTE, "false");
  } else {
    // make sure that when document does not exist it is created even if the flag was not marked to be stored
    if (document.getIdentifier() == null || documentStorageService.getDocument(document.getIdentifier()) == null) {
      documentStorageService.saveDocument(document, document.getContent());
      document.addAttribute(Document.UPDATED_ATTRIBUTE, "false");    
    }
  }
  ByteArrayOutputStream buff = new ByteArrayOutputStream();
  ObjectOutputStream oos = new ObjectOutputStream(buff);
  oos.writeUTF(document.getIdentifier());
  oos.writeUTF(document.getClass().getCanonicalName());
  oos.writeUTF(document.getLink());
  oos.close();
  return buff.toByteArray();
}

代码示例来源:origin: kiegroup/jbpm

@Test
public void testMarshallUnmarshall() throws IOException, ClassNotFoundException {
  
  List<Document> documents = getDocuments();
  Documents docs = new Documents(documents);
  
  byte[] marshalledDocs = docsMarshallingStrategy.marshal(null, null, docs);
  
  Documents unmarshalledDocs = (Documents) docsMarshallingStrategy.unmarshal(null, null, marshalledDocs, this.getClass().getClassLoader());
  
  assertEquals(docs.getDocuments().size(), unmarshalledDocs.getDocuments().size());
  
  List<Document> unmarshalledDocumentsList = unmarshalledDocs.getDocuments();
  
  assertEquals(documents.size(), unmarshalledDocumentsList.size());
  
  assertEquals(unmarshalledDocumentsList.get(0).getName(), docs.getDocuments().get(0).getName());
  assertEquals(unmarshalledDocumentsList.get(0).getLink(), docs.getDocuments().get(0).getLink());
  assertEquals(unmarshalledDocumentsList.get(1).getName(), docs.getDocuments().get(1).getName());
  assertEquals(unmarshalledDocumentsList.get(1).getLink(), docs.getDocuments().get(1).getLink());
}

代码示例来源:origin: kiegroup/jbpm

@Test
public void testFullConstructor() {
  Document document = new DocumentImpl(ID,
                     NAME,
                     SIZE,
                     LAST_MODIFIED,
                     LINK);
  Assertions.assertThat(document.getIdentifier()).isNotNull().isEqualTo(ID);
  Assertions.assertThat(document.getName()).isNotNull().isEqualTo(NAME);
  Assertions.assertThat(document.getSize()).isEqualTo(SIZE);
  Assertions.assertThat(document.getLastModified()).isEqualTo(LAST_MODIFIED);
  Assertions.assertThat(document.getLink()).isNotNull().isNotEmpty().isEqualTo(LINK);
}

代码示例来源:origin: kiegroup/jbpm

@Test
public void testSingleDocMarshallUnmarshall() throws IOException, ClassNotFoundException {
  DocumentMarshallingStrategy docMarshallingStrategy = createSingleDocMarshallingStrategy();
  Document document = getDocument("docOne");
  byte[] marshalledDocument = docMarshallingStrategy.marshal(null, null, document);
  Document unmarshalledDocument = (Document) docMarshallingStrategy.unmarshal(null, null, marshalledDocument, this.getClass().getClassLoader());

  assertEquals(document.getName(), unmarshalledDocument.getName());
  assertEquals(document.getLink(), unmarshalledDocument.getLink());
}

代码示例来源:origin: kiegroup/jbpm

@Test
public void testSingleDocMarshallUnmarshallNoAttribtues() throws IOException, ClassNotFoundException {
  DocumentMarshallingStrategy docMarshallingStrategy = createSingleDocMarshallingStrategy();
  Document document = getDocument("docOne-noattr");
  document.setAttributes(new HashMap<>());
  byte[] marshalledDocument = docMarshallingStrategy.marshal(null, null, document);
  Document unmarshalledDocument = (Document) docMarshallingStrategy.unmarshal(null, null, marshalledDocument, this.getClass().getClassLoader());

  assertEquals(document.getName(), unmarshalledDocument.getName());
  assertEquals(document.getLink(), unmarshalledDocument.getLink());
}

代码示例来源:origin: kiegroup/jbpm

@Test
public void testSingleDocMarshallUnmarshallTracking() throws IOException, ClassNotFoundException {
  final AtomicInteger counter = new AtomicInteger(0);
  DocumentMarshallingStrategy docMarshallingStrategy = new DocumentMarshallingStrategy(new CustomDocumentStorageServiceImpl(){
    @Override
    public Document saveDocument(Document document, byte[] content) {
      counter.incrementAndGet();
      return super.saveDocument(document, content);
    }
    
  });
  Document document = getDocument("docOne");
  byte[] marshalledDocument = docMarshallingStrategy.marshal(null, null, document);
  assertEquals(1, counter.get());
  Document unmarshalledDocument = (Document) docMarshallingStrategy.unmarshal(null, null, marshalledDocument, this.getClass().getClassLoader());

  assertEquals(document.getName(), unmarshalledDocument.getName());
  assertEquals(document.getLink(), unmarshalledDocument.getLink());
  
  // marhsall it again, it should not call the save on document service since document didn't change
  marshalledDocument = docMarshallingStrategy.marshal(null, null, unmarshalledDocument);
  assertEquals(1, counter.get());
  
  unmarshalledDocument.setContent("updated content".getBytes());
  marshalledDocument = docMarshallingStrategy.marshal(null, null, unmarshalledDocument);
  assertEquals(2, counter.get());
}

代码示例来源:origin: org.jbpm/jbpm-document

@Override
public byte[] marshal(Context context, ObjectOutputStream objectOutputStream, Object o) throws IOException {
  Document document = (Document) o;
  String updatedAttribute = document.getAttribute(Document.UPDATED_ATTRIBUTE);
  if (Boolean.parseBoolean(updatedAttribute)) {
    // store via service only when it was actually updated
    documentStorageService.saveDocument(document, document.getContent());
    document.addAttribute(Document.UPDATED_ATTRIBUTE, "false");
  } else {
    // make sure that when document does not exist it is created even if the flag was not marked to be stored
    if (document.getIdentifier() == null || documentStorageService.getDocument(document.getIdentifier()) == null) {
      documentStorageService.saveDocument(document, document.getContent());
      document.addAttribute(Document.UPDATED_ATTRIBUTE, "false");    
    }
  }
  ByteArrayOutputStream buff = new ByteArrayOutputStream();
  ObjectOutputStream oos = new ObjectOutputStream(buff);
  oos.writeUTF(document.getIdentifier());
  oos.writeUTF(document.getClass().getCanonicalName());
  oos.writeUTF(document.getLink());
  oos.close();
  return buff.toByteArray();
}

代码示例来源:origin: org.kie.workbench.forms/kie-wb-common-forms-jbpm-integration-backend

@Override
public DocumentData toFlatValue() {
  if (originalValue == null) {
    return null;
  }
  String templateId = (String) context.getAttributes().get(SERVER_TEMPLATE_ID);
  String link;
  if (!StringUtils.isEmpty(templateId) & !StringUtils.isEmpty(originalValue.getIdentifier())) {
    link = DocumentDownloadLinkGenerator.generateDownloadLink(templateId, originalValue.getIdentifier());
  } else {
    link = originalValue.getLink();
  }
  DocumentData data = new DocumentData(originalValue.getIdentifier(), originalValue.getName(), originalValue.getSize(), link);
  data.setStatus(DocumentStatus.STORED);
  return data;
}

代码示例来源:origin: org.kie.workbench.forms/kie-wb-common-forms-jbpm-integration-backend

@Test
public void testDocument2FlatValue() {
  Document doc = spy(new DocumentImpl(DOCUMENT_ID, "docName", 1024, new Date()));
  Map result = new HashMap();
  result.put(DocumentFieldValueMarshaller.SERVER_TEMPLATE_ID, SERVER_TEMPLATE_ID);
  when(context.getAttributes()).thenReturn(result);
  marshaller.init(doc, field, form, context);
  DocumentData documentData = marshaller.toFlatValue();
  verify(doc, never()).getLink();
  assertNotNull(documentData);
  assertEquals(doc.getName(), documentData.getFileName());
  assertEquals(doc.getSize(), documentData.getSize());
  assertEquals(EXPECTED_DOWNLOAD_LINK, documentData.getLink());
}

代码示例来源:origin: org.kie.workbench.forms/kie-wb-common-forms-jbpm-integration-backend

@Test
  public void testExistingFlatValue2Document() {
    Document doc = new DocumentImpl(DOCUMENT_ID, "docName", 1024, new Date(), "aLink");

    marshaller.init(doc, field, form, context);

    DocumentData data = new DocumentData(doc.getName(), doc.getSize(), doc.getLink());

    data.setStatus(DocumentStatus.STORED);

    Document rawDoc = marshaller.toRawValue(data);

    assertEquals("Documents must be equal!", doc, rawDoc);

    verify(uploadedDocumentManager, never()).getFile(anyString());

    verify(uploadedDocumentManager, never()).removeFile(anyString());
  }
}

代码示例来源:origin: org.jbpm/jbpm-document

@Test
public void testMarshallUnmarshall() throws IOException, ClassNotFoundException {
  
  List<Document> documents = getDocuments();
  Documents docs = new Documents(documents);
  
  byte[] marshalledDocs = docsMarshallingStrategy.marshal(null, null, docs);
  
  Documents unmarshalledDocs = (Documents) docsMarshallingStrategy.unmarshal(null, null, marshalledDocs, this.getClass().getClassLoader());
  
  assertEquals(docs.getDocuments().size(), unmarshalledDocs.getDocuments().size());
  
  List<Document> unmarshalledDocumentsList = unmarshalledDocs.getDocuments();
  
  assertEquals(documents.size(), unmarshalledDocumentsList.size());
  
  assertEquals(unmarshalledDocumentsList.get(0).getName(), docs.getDocuments().get(0).getName());
  assertEquals(unmarshalledDocumentsList.get(0).getLink(), docs.getDocuments().get(0).getLink());
  assertEquals(unmarshalledDocumentsList.get(1).getName(), docs.getDocuments().get(1).getName());
  assertEquals(unmarshalledDocumentsList.get(1).getLink(), docs.getDocuments().get(1).getLink());
}

代码示例来源:origin: org.jbpm/jbpm-document

@Test
public void testFullConstructor() {
  Document document = new DocumentImpl(ID,
                     NAME,
                     SIZE,
                     LAST_MODIFIED,
                     LINK);
  Assertions.assertThat(document.getIdentifier()).isNotNull().isEqualTo(ID);
  Assertions.assertThat(document.getName()).isNotNull().isEqualTo(NAME);
  Assertions.assertThat(document.getSize()).isEqualTo(SIZE);
  Assertions.assertThat(document.getLastModified()).isEqualTo(LAST_MODIFIED);
  Assertions.assertThat(document.getLink()).isNotNull().isNotEmpty().isEqualTo(LINK);
}

代码示例来源:origin: org.kie.workbench.forms/kie-wb-common-forms-jbpm-integration-backend

@Test
public void testDocument2FlatValueEmptyLinkPattern() {
  Document doc = spy(new DocumentImpl(DOCUMENT_ID, "docName", 1024, new Date()));
  marshaller.init(doc, field, form, context);
  DocumentData documentData = marshaller.toFlatValue();
  verify(doc).getLink();
  assertNotNull(documentData);
  assertEquals(doc.getName(), documentData.getFileName());
  assertEquals(doc.getSize(), documentData.getSize());
  assertEquals("", documentData.getLink());
}

代码示例来源:origin: org.jbpm/jbpm-document

@Test
public void testSingleDocMarshallUnmarshall() throws IOException, ClassNotFoundException {
  DocumentMarshallingStrategy docMarshallingStrategy = createSingleDocMarshallingStrategy();
  Document document = getDocument("docOne");
  byte[] marshalledDocument = docMarshallingStrategy.marshal(null, null, document);
  Document unmarshalledDocument = (Document) docMarshallingStrategy.unmarshal(null, null, marshalledDocument, this.getClass().getClassLoader());

  assertEquals(document.getName(), unmarshalledDocument.getName());
  assertEquals(document.getLink(), unmarshalledDocument.getLink());
}

代码示例来源:origin: org.jbpm/jbpm-document

@Test
public void testSingleDocMarshallUnmarshallNoAttribtues() throws IOException, ClassNotFoundException {
  DocumentMarshallingStrategy docMarshallingStrategy = createSingleDocMarshallingStrategy();
  Document document = getDocument("docOne-noattr");
  document.setAttributes(new HashMap<>());
  byte[] marshalledDocument = docMarshallingStrategy.marshal(null, null, document);
  Document unmarshalledDocument = (Document) docMarshallingStrategy.unmarshal(null, null, marshalledDocument, this.getClass().getClassLoader());

  assertEquals(document.getName(), unmarshalledDocument.getName());
  assertEquals(document.getLink(), unmarshalledDocument.getLink());
}

代码示例来源:origin: org.jbpm.contrib/google-drive-workitem

File fileMetadata = new File();
fileMetadata.setTitle(docToUpload.getName());
fileMetadata.setAlternateLink(docToUpload.getLink());
if (docToUpload.getLastModified() != null) {
  fileMetadata.setModifiedDate(new DateTime(docToUpload.getLastModified()));

代码示例来源:origin: org.jbpm/jbpm-document

@Test
public void testSingleDocMarshallUnmarshallTracking() throws IOException, ClassNotFoundException {
  final AtomicInteger counter = new AtomicInteger(0);
  DocumentMarshallingStrategy docMarshallingStrategy = new DocumentMarshallingStrategy(new CustomDocumentStorageServiceImpl(){
    @Override
    public Document saveDocument(Document document, byte[] content) {
      counter.incrementAndGet();
      return super.saveDocument(document, content);
    }
    
  });
  Document document = getDocument("docOne");
  byte[] marshalledDocument = docMarshallingStrategy.marshal(null, null, document);
  assertEquals(1, counter.get());
  Document unmarshalledDocument = (Document) docMarshallingStrategy.unmarshal(null, null, marshalledDocument, this.getClass().getClassLoader());

  assertEquals(document.getName(), unmarshalledDocument.getName());
  assertEquals(document.getLink(), unmarshalledDocument.getLink());
  
  // marhsall it again, it should not call the save on document service since document didn't change
  marshalledDocument = docMarshallingStrategy.marshal(null, null, unmarshalledDocument);
  assertEquals(1, counter.get());
  
  unmarshalledDocument.setContent("updated content".getBytes());
  marshalledDocument = docMarshallingStrategy.marshal(null, null, unmarshalledDocument);
  assertEquals(2, counter.get());
}

代码示例来源:origin: org.kie.server/kie-server-services-jbpm

protected DocumentInstance convertDocument(Document document, boolean withContent) {
    if (document == null) {
      return null;
    }
    Builder documentBuilder = DocumentInstance.builder();
    
     documentBuilder
        .id(document.getIdentifier())
        .name(document.getName())
        .link(document.getLink())
        .size(document.getSize())
        .lastModified(document.getLastModified());
    if (withContent) {
      documentBuilder.content(document.getContent());
    }
    DocumentInstance documentInstance = documentBuilder.build();
    return documentInstance;
  }
}

相关文章