當前位置: 首頁>>代碼示例>>Java>>正文


Java ObjectWithSchema類代碼示例

本文整理匯總了Java中com.mercateo.common.rest.schemagen.types.ObjectWithSchema的典型用法代碼示例。如果您正苦於以下問題:Java ObjectWithSchema類的具體用法?Java ObjectWithSchema怎麽用?Java ObjectWithSchema使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


ObjectWithSchema類屬於com.mercateo.common.rest.schemagen.types包,在下文中一共展示了ObjectWithSchema類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onNext

import com.mercateo.common.rest.schemagen.types.ObjectWithSchema; //導入依賴的package包/類
@Override
public void onNext(Fact f) {
    final OutboundEvent.Builder eventBuilder = new OutboundEvent.Builder();
    eventBuilder.name("new-fact");
    ObjectWithSchema<?> withSchema = createPayload(f, fullOutputMode);

    eventBuilder.data(withSchema);
    eventBuilder.mediaType(MediaType.APPLICATION_JSON_TYPE);
    eventBuilder.id(f.id().toString());
    final OutboundEvent event = eventBuilder.build();
    try {
        eventOutput.write(event);
    } catch (IOException e) {
        unsubscribe();
        log.debug("Error while writing into the pipe", e);
    }
}
 
開發者ID:uweschaefer,項目名稱:factcast,代碼行數:18,代碼來源:FactsObserver.java

示例2: forRoot

import com.mercateo.common.rest.schemagen.types.ObjectWithSchema; //導入依賴的package包/類
ObjectWithSchema<Void> forRoot() {
    val getFactsLink = factsResourceLinkFactory.forCall(FactsRel.FACT_IDS, r -> r
            .getServerSentEvents(null));

    val getFullFactsLink = factsResourceLinkFactory.forCall(FactsRel.FULL_FACTS, r -> r
            .getServerSentEventsFull(null));
    val createLink = transactionsLinkFactory.forCall(FactsRel.CREATE_TRANSACTIONAL, r -> r
            .newTransaction(null));

    return hyperSchemaCreator.create(null, collect(getFactsLink, getFullFactsLink, createLink));
}
 
開發者ID:uweschaefer,項目名稱:factcast,代碼行數:12,代碼來源:RootSchemaCreator.java

示例3: getForId

import com.mercateo.common.rest.schemagen.types.ObjectWithSchema; //導入依賴的package包/類
@GET
@Produces(MediaType.APPLICATION_JSON)
@Path("{id}")
@Cacheable
public ObjectWithSchema<FactJson> getForId(@NotNull @PathParam("id") String id) {
    Optional<Fact> fact;
    try {
        fact = factStore.fetchById(UUID.fromString(id));
    } catch (IllegalArgumentException e) {
        throw new NotFoundException();
    }
    FactJson returnValue = fact.map(factTransformer::toJson).orElseThrow(
            NotFoundException::new);
    return schemaCreator.forFactWithId(returnValue);
}
 
開發者ID:uweschaefer,項目名稱:factcast,代碼行數:16,代碼來源:FactsResource.java

示例4: getRoot

import com.mercateo.common.rest.schemagen.types.ObjectWithSchema; //導入依賴的package包/類
@GET
@Produces(MediaType.APPLICATION_JSON)
@NoCache
public ObjectWithSchema<Void> getRoot() {
    return schemaCreator.forRoot();

}
 
開發者ID:uweschaefer,項目名稱:factcast,代碼行數:8,代碼來源:RootResource.java

示例5: testOnNext

import com.mercateo.common.rest.schemagen.types.ObjectWithSchema; //導入依賴的package包/類
@Test
public void testOnNext() throws Exception {
    uut.onNext(TestFacts.one);
    ArgumentCaptor<OutboundEvent> cap = ArgumentCaptor.forClass(OutboundEvent.class);
    verify(eventOutput).write(cap.capture());
    OutboundEvent ev = cap.getValue();
    @SuppressWarnings("unchecked")
    JsonHyperSchema jsonHyperSchema = ((ObjectWithSchema<Void>) ev.getData()).schema;
    assertTrue(jsonHyperSchema.getByRel(Rel.CANONICAL).isPresent());
    assertThat(ev.getId(), is(TestFacts.one.id().toString()));
}
 
開發者ID:uweschaefer,項目名稱:factcast,代碼行數:12,代碼來源:FactsObserver0Test.java

示例6: testCreationOfFulltype

import com.mercateo.common.rest.schemagen.types.ObjectWithSchema; //導入依賴的package包/類
@Test
public void testCreationOfFulltype() throws Exception {

    ObjectWithSchema<FactJson> object = (ObjectWithSchema<FactJson>) uut.createPayload(
            TestFacts.one, true);
    assertThat(object.object.header().id(), is(TestFacts.one.id()));
}
 
開發者ID:uweschaefer,項目名稱:factcast,代碼行數:8,代碼來源:FactsObserver0Test.java

示例7: testCreationOfIdType

import com.mercateo.common.rest.schemagen.types.ObjectWithSchema; //導入依賴的package包/類
@Test
public void testCreationOfIdType() throws Exception {

    ObjectWithSchema<FactIdJson> object = (ObjectWithSchema<FactIdJson>) uut.createPayload(
            TestFacts.one, false);
    assertThat(object.object.id(), is(TestFacts.one.id().toString()));
}
 
開發者ID:uweschaefer,項目名稱:factcast,代碼行數:8,代碼來源:FactsObserver0Test.java

示例8: testGetForId

import com.mercateo.common.rest.schemagen.types.ObjectWithSchema; //導入依賴的package包/類
@Test
public void testGetForId() throws Exception {
    when(factStore.fetchById(TestFacts.one.id())).thenReturn(Optional.of(TestFacts.one));
    ObjectWithSchema<FactJson> value = ObjectWithSchema.create(null, JsonHyperSchema.from(Lists
            .newArrayList()));
    when(schemaCreator.forFactWithId(any())).thenReturn(value);
    ObjectWithSchema<FactJson> result = uut.getForId(TestFacts.one.id().toString());
    assertThat(result, is(value));
}
 
開發者ID:uweschaefer,項目名稱:factcast,代碼行數:10,代碼來源:FactsResource0Test.java

示例9: testGetForIdNotFound

import com.mercateo.common.rest.schemagen.types.ObjectWithSchema; //導入依賴的package包/類
@SuppressWarnings("unchecked")
@Test(expected = NotFoundException.class)
public void testGetForIdNotFound() throws Exception {
    when(factStore.fetchById(TestFacts.one.id())).thenThrow(IllegalArgumentException.class);
    ObjectWithSchema<FactJson> value = ObjectWithSchema.create(null, JsonHyperSchema.from(Lists
            .newArrayList()));
    when(schemaCreator.forFactWithId(any())).thenReturn(value);
    uut.getForId(TestFacts.one.id().toString());

}
 
開發者ID:uweschaefer,項目名稱:factcast,代碼行數:11,代碼來源:FactsResource0Test.java

示例10: getListing

import com.mercateo.common.rest.schemagen.types.ObjectWithSchema; //導入依賴的package包/類
@SuppressWarnings("boxing")
@GET
@Produces(MediaType.APPLICATION_JSON)
public PaginatedResponse<SummaryJsonType> getListing(@BeanParam @NotNull @Valid SearchQueryBean searchQueryBean) {
	final ListingResult<SummaryJsonType> summaries = getSummaryListing(searchQueryBean);

	final LinkFactory<ImplementationType> lf = getImplementationLinkFactory();

	final List<ObjectWithSchema<SummaryJsonType>> listForResponse = summaries.getResultList().stream()
			.map(r -> getResponse(r, lf)).collect(Collectors.toList());

	List<Link> links = Lists.newArrayList();
	lf.forCall(REL_INSTANCE, r -> r.get(IdParameterBean.of(null))).ifPresent(links::add);
	int offset = searchQueryBean.getOffset();
	int limit = searchQueryBean.getLimit();
	PaginationLinkBuilder paginationLinkBuilder = PaginationLinkBuilder.of(summaries.getTotalNumberOfHits(),
			searchQueryBean.getOffset(), searchQueryBean.getLimit());
	links.addAll(paginationLinkBuilder.generateLinks((rel, off, lim) -> {
		searchQueryBean.setLimit(lim);
		searchQueryBean.setOffset(off);
		return lf.forCall(rel, r -> r.getListing(searchQueryBean));
	}));
	links.addAll(createAdditionalLinksForListing(searchQueryBean));

	return PaginatedResponse.create(listForResponse, summaries.getTotalNumberOfHits(), offset, limit,
			JsonHyperSchema.from(links));
}
 
開發者ID:Mercateo,項目名稱:rest-jersey-utils,代碼行數:28,代碼來源:AbstractListingResource.java

示例11: getSummary

import com.mercateo.common.rest.schemagen.types.ObjectWithSchema; //導入依賴的package包/類
@GET
@Path("{id}/summary")
@Produces(MediaType.APPLICATION_JSON)
public ObjectWithSchema<SummaryJsonType> getSummary(@NotNull @BeanParam @Valid IdParameterBean idParamBean) {
	String id = idParamBean.getId();
	final SummaryJsonType summaryJson = getSummaryForId(id);
	return getResponse(summaryJson, getImplementationLinkFactory());
}
 
開發者ID:Mercateo,項目名稱:rest-jersey-utils,代碼行數:9,代碼來源:AbstractListingResource.java

示例12: get

import com.mercateo.common.rest.schemagen.types.ObjectWithSchema; //導入依賴的package包/類
@GET
@Path("{id}")
@Produces(MediaType.APPLICATION_JSON)
public ObjectWithSchema<FullJsonType> get(@NotNull @Valid @BeanParam IdParameterBean idParameterBean) {
	String id = idParameterBean.getId();
	final FullJsonType json = getForId(id);
	return getResponse(json);
}
 
開發者ID:Mercateo,項目名稱:rest-jersey-utils,代碼行數:9,代碼來源:AbstractListingResource.java

示例13: getResponse

import com.mercateo.common.rest.schemagen.types.ObjectWithSchema; //導入依賴的package包/類
protected ObjectWithSchema<FullJsonType> getResponse(FullJsonType json) {
	final LinkFactory<ImplementationType> factoryForImplementation = getImplementationLinkFactory();
	final Optional<Link> selfLink = factoryForImplementation.forCall(Rel.SELF,
			r -> r.get(IdParameterBean.of(json.getId())));

	final ArrayList<Optional<Link>> result = Lists.newArrayList(selfLink);

	final List<Optional<Link>> additionalLinks = createAdditionalLinksForFullType(json, factoryForImplementation);

	result.addAll(additionalLinks);

	final JsonHyperSchema hyperSchema = JsonHyperSchema.fromOptional(result);
	return ObjectWithSchema.create(json, hyperSchema);
}
 
開發者ID:Mercateo,項目名稱:rest-jersey-utils,代碼行數:15,代碼來源:AbstractListingResource.java

示例14: getSomething

import com.mercateo.common.rest.schemagen.types.ObjectWithSchema; //導入依賴的package包/類
@Path("/method/{id}")
@GET
@RolesAllowed("test")
@Produces(MediaType.APPLICATION_JSON)
public ObjectWithSchema<Something> getSomething(@PathParam("id") String id) {
	Optional<Link> link = linkMetaFactory.createFactoryFor(ResourceClass.class).forCall(Rel.SELF,
			r -> r.getSomething(id));

	return ObjectWithSchema.create(new Something(), JsonHyperSchema.from(link));
}
 
開發者ID:Mercateo,項目名稱:rest-schemagen,代碼行數:11,代碼來源:ResourceClass.java

示例15: getWithQuery

import com.mercateo.common.rest.schemagen.types.ObjectWithSchema; //導入依賴的package包/類
@Path("/method/value")
@GET
@Produces(MediaType.APPLICATION_JSON)
public ObjectWithSchema<Void> getWithQuery(@QueryParam("test") String test) {

	return ObjectWithSchema.create(null, null);
}
 
開發者ID:Mercateo,項目名稱:rest-schemagen,代碼行數:8,代碼來源:ResourceClass.java


注:本文中的com.mercateo.common.rest.schemagen.types.ObjectWithSchema類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。