当前位置: 首页>>代码示例>>Java>>正文


Java Representation.withLink方法代码示例

本文整理汇总了Java中com.theoryinpractise.halbuilder.api.Representation.withLink方法的典型用法代码示例。如果您正苦于以下问题:Java Representation.withLink方法的具体用法?Java Representation.withLink怎么用?Java Representation.withLink使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.theoryinpractise.halbuilder.api.Representation的用法示例。


在下文中一共展示了Representation.withLink方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: buildLink

import com.theoryinpractise.halbuilder.api.Representation; //导入方法依赖的package包/类
private void buildLink(Representation rep, Object targetObj, CanonicalObjectReader reader, ReferenceLink refLink) {

        CanonicalDataType cdt = refLink.getCDMProperty().getTargetDataType();
        ObjectResourceDefinition ord = ObjectResourceDefinitionRegistry.INSTANCE.getResourceDefinition(cdt);
        ObjectResource targetResource = ord.getResource(targetObj, reader);
        if (refLink.isDecorated()) {
            // Render decorated link in HAL as an embedded object.
            Representation refLinkRep = representationFactory.newRepresentation(targetResource.getURI());
            // add included properties
            for (RDMProperty prop : refLink.getIncludedProperties()) {
                refLinkRep.withProperty(prop.getName(), reader.getPropertyValue(targetObj, prop));
            }
            // embed the resource representation
            rep.withRepresentation(refLink.getName(), refLinkRep);
        } else {
            // Render naked link
            rep.withLink(refLink.getName(), targetResource.getURI());
        }
    }
 
开发者ID:ModelSolv,项目名称:Kaboom,代码行数:20,代码来源:HalSerializerImpl.java

示例2: representResource

import com.theoryinpractise.halbuilder.api.Representation; //导入方法依赖的package包/类
@Override
public void representResource(Representation resource) {
	for (Link link : navigationLinks) {
		resource.withLink(link.getRel(), link.getUri());
	}
	resource.withProperty("startIndex", startIndex);
	resource.withProperty("itemCount", itemCount);
	StandardRepresentationFactory representationFactory = new StandardRepresentationFactory();
	for (BookmarkRepresentation bookmark : bookmarks) {
		resource.withRepresentation("item", 
				representationFactory.newRepresentation(bookmark.getSelfUri())
									.withLink(bookmark.getUrlLink().getRel(), bookmark.getUrlLink().getUri())
									.withProperty("name", bookmark.getName()));
	}
}
 
开发者ID:spoonless,项目名称:rest-bookmarks,代码行数:16,代码来源:BookmarksRepresentation.java

示例3: representResource

import com.theoryinpractise.halbuilder.api.Representation; //导入方法依赖的package包/类
@Override
public void representResource(Representation resource) {
	resource.withNamespace("bk", "http://bookmarks.epsi.fr/rels/{rel}");
	resource.withLink(urlLink.getRel(), urlLink.getUri());
	resource.withLink("bk:qrcode", qrCodeLink.getUri());
	resource.withProperty("name", bookmark.getName());
	resource.withProperty("description", bookmark.getDescription());
	resource.withProperty("url", bookmark.getUrl());
}
 
开发者ID:spoonless,项目名称:rest-bookmarks,代码行数:10,代码来源:BookmarkRepresentation.java

示例4: addPrevLinkIfRequired

import com.theoryinpractise.halbuilder.api.Representation; //导入方法依赖的package包/类
private Representation addPrevLinkIfRequired(final Representation representation,
        final PaginatedResult<Hotel> hotels) {
    if (hotels.getActualPagination().getOffset() > 0) {
        final int prevOffset = Math.max(hotels.getActualPagination().getOffset() - Pagination.DEFAULT.getLimit(), 0);
        return representation.withLink(RELATIONSHIP_PREVIOUS, hrefWithOffset(prevOffset));
    }
    else {
        return representation;
    }
}
 
开发者ID:vtsukur,项目名称:take-a-REST,代码行数:11,代码来源:HalHotelsRepresentationAssembler.java

示例5: addNextLinkIfRequired

import com.theoryinpractise.halbuilder.api.Representation; //导入方法依赖的package包/类
private Representation addNextLinkIfRequired(final Representation representation,
        final PaginatedResult<Hotel> hotels) {
    final int nextOffset = hotels.getActualPagination().getOffset() + Pagination.DEFAULT.getLimit();
    if (nextOffset < hotels.getTotal()) {
        return representation.withLink(RELATIONSHIP_NEXT, hrefWithOffset(nextOffset));
    }
    else {
        return representation;
    }
}
 
开发者ID:vtsukur,项目名称:take-a-REST,代码行数:11,代码来源:HalHotelsRepresentationAssembler.java

示例6: newSlotsRepresentation

import com.theoryinpractise.halbuilder.api.Representation; //导入方法依赖的package包/类
public Representation newSlotsRepresentation(List<Slot> slots) {
UriBuilder slotsUriBuilder = newSlotsUriBuilder();

Representation rep = newRepresentation(slotsUriBuilder.build());
rep = rep.withBean(slots);

int numSlots = slots.size();
UriBuilder slotUriBuilder = newSlotUriBuilder();

for (int i = 0; i < numSlots; i++) {
    Optional<Slot> previousSlot = Optional.empty();
    Optional<Slot> nextSlot = Optional.empty();

    if (i - 1 >= 0) {
	previousSlot = Optional.of(slots.get(i - 1));
    }
    if (i + 1 < numSlots) {
	nextSlot = Optional.of(slots.get(i + 1));
    }

    rep.withRepresentation("slots",
	    newSlotRepresentation(slots.get(i), previousSlot, nextSlot));

    rep.withLink("item", slotUriBuilder.build(slots.get(i).getId())
	    .toString());
}

if (numSlots > 0) {
    rep.withLink("start", slotUriBuilder.build(slots.get(0).getId())
	    .toString());
}

return rep;
   }
 
开发者ID:asarkar,项目名称:java-ee,代码行数:35,代码来源:AvailabilityRepresentationFactory.java

示例7: newSlotRepresentation

import com.theoryinpractise.halbuilder.api.Representation; //导入方法依赖的package包/类
public Representation newSlotRepresentation(Slot slot,
    Optional<Slot> previousSlot, Optional<Slot> nextSlot) {
UriBuilder slotUriBuilder = newSlotUriBuilder();

Representation rep = newRepresentation(slotUriBuilder.build(
	slot.getId()).toString());

rep.withLink("edit", newSlotUriBuilder().queryParam("reserve", "true")
	.build(slot.getId()).toString(), "reserve", "reserve", null,
	null);
rep.withLink("edit", newSlotUriBuilder().queryParam("reserve", "false")
	.build(slot.getId()).toString(), "relinquish", "relinquish",
	null, null);
/*
 * I've yet to investigate deeper but looks like the
 * 'JsonRepresentationWriter' that the 'StandardRepresentationFactory'
 * is initialized with uses Bean introspection to read the properties
 * and then converts them to JSON one at a time. It doesn't look at the
 * annotations, if any, on these properties and hence ignores them
 * completely. We don't want the default serialization for
 * 'LcoalDateTime', so we write out each field separately. Of course,
 * this couples the representation with the 'Slot' class such that any
 * time the class changes, the representation will have to change to.
 */
rep.withProperty("id", slot.getId());
rep.withProperty("startDateTime",
	ISO_LOCAL_DATE_TIME.format(slot.getStartDateTime()));
rep.withProperty("endDateTime",
	ISO_LOCAL_DATE_TIME.format(slot.getEndDateTime()));
rep.withProperty("doctorId", slot.getDoctorId());

if (previousSlot.isPresent()) {
    rep.withLink("prev",
	    slotUriBuilder.build(previousSlot.get().getId()).toString());
}

if (nextSlot.isPresent()) {
    rep.withLink("next", slotUriBuilder.build(nextSlot.get().getId())
	    .toString());
}

return rep;
   }
 
开发者ID:asarkar,项目名称:java-ee,代码行数:44,代码来源:AvailabilityRepresentationFactory.java

示例8: buildNextLink

import com.theoryinpractise.halbuilder.api.Representation; //导入方法依赖的package包/类
private void buildNextLink(Representation representation,
		HttpServletRequest request) {
	Map<String, String[]> params = modifyPageNumber(request, 1);
	String link = buildLink(params);
	representation.withLink("next", link);
}
 
开发者ID:patrickvankann,项目名称:bjug-querydsl,代码行数:7,代码来源:HalPageResponseEntityBuilder.java

示例9: buildPreviousLink

import com.theoryinpractise.halbuilder.api.Representation; //导入方法依赖的package包/类
private void buildPreviousLink(Representation representation,
		HttpServletRequest request) {
	Map<String, String[]> params = modifyPageNumber(request, -1);
	String link = buildLink(params);
	representation.withLink("previous", link);
}
 
开发者ID:patrickvankann,项目名称:bjug-querydsl,代码行数:7,代码来源:HalPageResponseEntityBuilder.java

示例10: newAppointmentRepresentation

import com.theoryinpractise.halbuilder.api.Representation; //导入方法依赖的package包/类
public Representation newAppointmentRepresentation(Appointment appt) {
UriBuilder apptUriBuilder = newAppointmentUriBuilder();

Representation rep = newRepresentation(apptUriBuilder.build(
	appt.getId()).toString());

rep.withLink("edit", apptUriBuilder.build(appt.getId()).toString(),
	"cancel", "cancel", null, null);

rep.withBean(appt);

return rep;
   }
 
开发者ID:asarkar,项目名称:java-ee,代码行数:14,代码来源:AppointmentRepresentationFactory.java


注:本文中的com.theoryinpractise.halbuilder.api.Representation.withLink方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。