Search in sources :

Example 6 with Image

use of me.zhanghai.android.douya.network.api.info.apiv2.Image in project openstack4j by ContainX.

the class ImageServiceImpl method update.

/**
     * {@inheritDoc}
     */
@Override
public Image update(Image image) {
    checkNotNull(image);
    ObjectMapper objectMapper = new ObjectMapper();
    Image origImage = get(image.getId());
    ObjectNode origJson;
    ObjectNode newJson;
    try {
        String oImg = objectMapper.writeValueAsString(origImage);
        origJson = (ObjectNode) objectMapper.readTree(oImg);
        String img = objectMapper.writeValueAsString(image);
        newJson = (ObjectNode) objectMapper.readTree(img);
        JsonNode jsonDiff = JsonDiff.asJson(origJson, newJson);
        GlanceImageUpdate giu = new GlanceImageUpdate(jsonDiff);
        return update(image.getId(), giu);
    } catch (IOException e) {
        e.printStackTrace();
        return null;
    }
}
Also used : ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) GlanceImageUpdate(org.openstack4j.openstack.image.v2.domain.GlanceImageUpdate) JsonNode(com.fasterxml.jackson.databind.JsonNode) IOException(java.io.IOException) GlanceImage(org.openstack4j.openstack.image.v2.domain.GlanceImage) Image(org.openstack4j.model.image.v2.Image) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Aggregations

Image (org.openstack4j.model.image.v2.Image)3 Context (android.content.Context)2 View (android.view.View)2 ImageView (android.widget.ImageView)2 TextView (android.widget.TextView)2 BindView (butterknife.BindView)2 Image (me.zhanghai.android.douya.network.api.info.apiv2.Image)2 TimeActionTextView (me.zhanghai.android.douya.ui.TimeActionTextView)2 RecyclerView (android.support.v7.widget.RecyclerView)1 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)1 ImageAnnotatorClient (com.google.cloud.vision.spi.v1.ImageAnnotatorClient)1 AnnotateImageRequest (com.google.cloud.vision.v1.AnnotateImageRequest)1 AnnotateImageResponse (com.google.cloud.vision.v1.AnnotateImageResponse)1 BatchAnnotateImagesResponse (com.google.cloud.vision.v1.BatchAnnotateImagesResponse)1 EntityAnnotation (com.google.cloud.vision.v1.EntityAnnotation)1 Feature (com.google.cloud.vision.v1.Feature)1 Image (com.google.cloud.vision.v1.Image)1 ByteString (com.google.protobuf.ByteString)1