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


Java CDAEntry类代码示例

本文整理汇总了Java中com.contentful.java.cda.CDAEntry的典型用法代码示例。如果您正苦于以下问题:Java CDAEntry类的具体用法?Java CDAEntry怎么用?Java CDAEntry使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: processArray

import com.contentful.java.cda.CDAEntry; //导入依赖的package包/类
private void processArray(CDAEntry entry, AutoEscapeValues values, FieldMeta field) {
  if (field.isArrayOfSymbols()) {
    List<?> list = entry.getField(field.id());
    if (list == null) {
      list = Collections.emptyList();
    }
    saveBlob(entry, values, field, (Serializable) list);
  } else {
    List<?> links = extractRawFieldValue(entry, field.id());
    if (links != null) {
      for (int i = 0; i < links.size(); i++) {
        processLink(entry, field.id(), (Map<?, ?>) links.get(i), i);
      }
    }
  }
}
 
开发者ID:contentful,项目名称:vault,代码行数:17,代码来源:SyncRunnable.java

示例2: processLink

import com.contentful.java.cda.CDAEntry; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private void processLink(CDAEntry entry, String fieldId, Map<?, ?> value, int position) {
  String parentId = entry.id();

  if (value == null) {
    deleteResourceLinks(parentId, fieldId, entry.locale());
  } else {
    Map<String, ?> linkInfo = (Map<String, ?>) value.get("sys");
    if (linkInfo != null) {
      String linkType = (String) linkInfo.get("linkType");
      String targetId = (String) linkInfo.get("id");

      if (linkType != null && targetId != null) {
        saveLink(parentId, fieldId, linkType, targetId, position, entry.locale());
      }
    }
  }
}
 
开发者ID:contentful,项目名称:vault,代码行数:19,代码来源:SyncRunnable.java

示例3: loadData

import com.contentful.java.cda.CDAEntry; //导入依赖的package包/类
private void loadData() {
  emptyView.setVisibility(View.VISIBLE);

  callbacks.add(CFDiscoveryClient.getClient()
      .fetch(CDAEntry.class)
      .one(getString(R.string.discovery_space_entry_id), new CDACallback<CDAEntry>() {
        @Override
        @SuppressWarnings("unchecked")
        protected void onSuccess(CDAEntry entry) {
          insertTitle((String) entry.getField("title"));

          //noinspection unchecked
          for (CDAResource helpItem : (List<CDAResource>) entry.getField("helpItems")) {
            insertHelpItem((CDAEntry) helpItem);
          }

          emptyView.setVisibility(View.GONE);
          container.setVisibility(View.VISIBLE);
        }
      }));
}
 
开发者ID:contentful,项目名称:discovery-app-android,代码行数:22,代码来源:HelpActivity.java

示例4: insertHelpItem

import com.contentful.java.cda.CDAEntry; //导入依赖的package包/类
private void insertHelpItem(CDAEntry helpItemEntry) {
  HelpItemViewHolder vh =
      new HelpItemViewHolder(View.inflate(this, R.layout.view_help_item, null));

  // Text
  vh.tvText.setText((String) helpItemEntry.getField("text"));

  // Image
  CDAAsset asset = helpItemEntry.getField("image");

  Picasso.with(this).load("http:" + asset.url())
      .fit()
      .centerInside()
      .into(vh.ivPhoto);

  container.addView(vh.rootView);
}
 
开发者ID:contentful,项目名称:discovery-app-android,代码行数:18,代码来源:HelpActivity.java

示例5: performLoad

import com.contentful.java.cda.CDAEntry; //导入依赖的package包/类
@Override protected ResourceList performLoad(CDAClient client) {
  ResourceList resourceList = new ResourceList();

  FetchQuery<CDAEntry> query =
      client.fetch(CDAEntry.class).where("content_type", contentType.id());

  // Set the locale if non-default locale is currently configured
  String locale = CFClient.getLocale();
  if (locale != null) {
    query.where("locale", locale);
  }

  // Make the request
  CDAArray cdaArray = query.all();
  resourceList.resources = new ArrayList<>();

  // Prepare the result
  resourceList.resources.addAll(cdaArray.entries().values());
  return resourceList;
}
 
开发者ID:contentful,项目名称:discovery-app-android,代码行数:21,代码来源:EntriesByContentTypeLoader.java

示例6: onCreate

import com.contentful.java.cda.CDAEntry; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);

  // Extract arguments from Intent
  entry = (CDAEntry) getArguments().getSerializable(IntentConsts.EXTRA_ENTRY);

  contentTypesMap = (Map<String, CDAContentType>) getArguments().getSerializable(
      IntentConsts.EXTRA_CONTENT_TYPES_MAP);

  contentType = Utils.getContentTypeForEntry(contentTypesMap, entry);

  // Content Type fields
  contentTypesFields = new HashMap<>();

  for (CDAField f : contentType.fields()) {
    contentTypesFields.put(f.id(), f);
  }

  // Adapter
  adapter = new EntryListAdapter(getActivity(), entry, contentType);
}
 
开发者ID:contentful,项目名称:discovery-app-android,代码行数:24,代码来源:EntryListFragment.java

示例7: onLinkItemClicked

import com.contentful.java.cda.CDAEntry; //导入依赖的package包/类
/**
 * Click handler for a field of type {@code Link}.
 */
private void onLinkItemClicked(CDAField item, Object value) {
  CDAResource resource = (CDAResource) value;

  String linkType = item.linkType();

  if ("Asset".equals(linkType)) {
    startActivity(new Intent(getActivity(), AssetPreviewActivity.class)
        .putExtra(IntentConsts.EXTRA_TITLE, item.name())
        .putExtra(IntentConsts.EXTRA_ASSET, resource));
  } else if ("Entry".equals(linkType)) {
    CDAEntry linkedEntry = (CDAEntry) resource;

    startActivity(new Intent(getActivity(), EntryActivity.class)
        .putExtra(IntentConsts.EXTRA_ENTRY, linkedEntry)
        .putExtra(IntentConsts.EXTRA_CONTENT_TYPES_MAP, (Serializable) contentTypesMap));
  }
}
 
开发者ID:contentful,项目名称:discovery-app-android,代码行数:21,代码来源:EntryListFragment.java

示例8: fetchNyancatEntryAsync

import com.contentful.java.cda.CDAEntry; //导入依赖的package包/类
@Test
public void fetchNyancatEntryAsync() throws Exception {
  final CountDownLatch latch = new CountDownLatch(1);
  final CDAEntry[] result = {null};

  client.fetch(CDAEntry.class).one("nyancat", new CDACallback<CDAEntry>() {
    @Override protected void onSuccess(CDAEntry entry) {
      result[0] = entry;
      latch.countDown();
    }

    @Override protected void onFailure(Throwable error) {
      latch.countDown();
    }
  });

  latch.await(1, TimeUnit.SECONDS);
  assertThat(result[0]).isNotNull();
  assertNyanCat(result[0]);
}
 
开发者ID:contentful,项目名称:contentful.java,代码行数:21,代码来源:Integration.java

示例9: fetchAllEntries

import com.contentful.java.cda.CDAEntry; //导入依赖的package包/类
@Test
public void fetchAllEntries() throws Exception {
  CDAArray array = client.fetch(CDAEntry.class).all();
  assertThat(array.items()).hasSize(10);
  assertThat(array.assets()).hasSize(4);
  assertThat(array.entries()).hasSize(10);

  assertThat(array.total()).isEqualTo(10);
  assertThat(array.skip()).isEqualTo(0);
  assertThat(array.limit()).isEqualTo(100);

  for (CDAEntry entry : array.entries().values()) {
    assertThat(entry.contentType()).isNotNull();
  }

  CDAEntry nyanCat = array.entries().get("nyancat");
  assertThat(nyanCat).isNotNull();
  assertNyanCat(nyanCat);
}
 
开发者ID:contentful,项目名称:contentful.java,代码行数:20,代码来源:Integration.java

示例10: sync

import com.contentful.java.cda.CDAEntry; //导入依赖的package包/类
@Test
public void sync() throws Exception {
  SynchronizedSpace space = client.sync().observe().blockingFirst();
  assertInitial(space);

  space = client.sync(space).observe().blockingFirst();

  assertThat(space.nextSyncUrl()).isNotEmpty();
  assertThat(space.items()).hasSize(14);
  assertThat(space.deletedEntries()).hasSize(0);

  CDAEntry nyanCat = space.entries().get("nyancat");
  assertThat(nyanCat).isNotNull();
  assertThat(nyanCat.getField("name")).isEqualTo("Nyan vIghro'");
  assertThat(nyanCat.getField("color")).isEqualTo("rainbow");
  List<String> likes = nyanCat.getField("likes");
  assertThat(likes).containsExactly("rainbows", "fish");
}
 
开发者ID:contentful,项目名称:contentful.java,代码行数:19,代码来源:Integration.java

示例11: testRawFields

import com.contentful.java.cda.CDAEntry; //导入依赖的package包/类
@SuppressWarnings("unchecked") @Test
public void testRawFields() throws Exception {
  SynchronizedSpace space = client.sync().fetch();
  assertThat(space.items()).hasSize(14);
  assertThat(space.assets()).hasSize(4);
  assertThat(space.entries()).hasSize(10);

  CDAEntry happycat = space.entries().get("happycat");
  assertThat(happycat).isNotNull();
  assertThat(happycat.getField("image")).isNotNull();
  assertThat(happycat.getField("bestFriend")).isNotNull();

  // image
  Map<String, Map<?, ?>> rawImage = (Map<String, Map<?, ?>>) happycat.rawFields().get("image");
  assertThat(rawImage).isNotNull();
  assertThat(rawImage.get("en-US")).containsKey("sys");

  // array
  Map<String, List<String>> rawArray = (Map<String, List<String>>) happycat.rawFields().get("likes");
  assertThat(rawArray).isNotNull();
  assertThat(rawArray.get("en-US").get(0)).isEqualTo("cheezburger");
}
 
开发者ID:contentful,项目名称:contentful.java,代码行数:23,代码来源:Integration.java

示例12: assertNyanCat

import com.contentful.java.cda.CDAEntry; //导入依赖的package包/类
private void assertNyanCat(CDAEntry entry) {
  assertThat(entry.id()).isEqualTo("nyancat");
  assertThat(entry.getField("name")).isEqualTo("Nyan Cat");
  assertThat(entry.getField("color")).isEqualTo("rainbow");
  assertThat(entry.getField("birthday")).isEqualTo("2011-04-04T22:00:00+00:00");
  assertThat(entry.getField("lives")).isEqualTo(1337.0);

  List<String> likes = entry.getField("likes");
  assertThat(likes).containsExactly("rainbows", "fish");

  Object bestFriend = entry.getField("bestFriend");
  assertThat(bestFriend).isInstanceOf(CDAEntry.class);
  assertThat(entry).isSameAs(((CDAEntry) bestFriend).getField("bestFriend"));

  // Localization
  assertThat(entry.locale()).isEqualTo("en-US");
  entry.setLocale("tlh");
  assertThat(entry.getField("color")).isEqualTo("rainbow");
  assertThat(entry.getField("non-existing-does-not-throw")).isNull();
}
 
开发者ID:contentful,项目名称:contentful.java,代码行数:21,代码来源:Integration.java

示例13: processResources

import com.contentful.java.cda.CDAEntry; //导入依赖的package包/类
private void processResources(SynchronizedSpace syncedSpace) {
  for (CDAAsset asset : syncedSpace.assets().values()) {
    processResource(asset);
  }
  for (CDAEntry entry : syncedSpace.entries().values()) {
    processResource(entry);
  }
}
 
开发者ID:contentful,项目名称:vault,代码行数:9,代码来源:SyncRunnable.java

示例14: processResource

import com.contentful.java.cda.CDAEntry; //导入依赖的package包/类
private void processResource(CDAResource resource) {
  CDAType type = resource.type();
  LocalizedResource localized = (LocalizedResource) resource;
  if (type == ASSET) {
    saveAsset((CDAAsset) resource);
  } else if (type == ENTRY) {
    Class<?> modelClass = spaceHelper.getTypes().get(((CDAEntry) localized).contentType().id());
    if (modelClass == null) {
      return;
    }
    ModelHelper<?> modelHelper = spaceHelper.getModels().get(modelClass);
    saveEntry((CDAEntry) resource, modelHelper.getTableName(), modelHelper.getFields());
  }
}
 
开发者ID:contentful,项目名称:vault,代码行数:15,代码来源:SyncRunnable.java

示例15: extractRawFieldValue

import com.contentful.java.cda.CDAEntry; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private <T> T extractRawFieldValue(CDAEntry entry, String fieldId) {
  Map<?, ?> value = (Map<?, ?>) entry.rawFields().get(fieldId);
  if (value != null) {
    T result = (T) value.get(entry.locale());
    if (result == null) {
      result = (T) value.get(spaceHelper.getDefaultLocale());
    }
    return result;
  }
  return null;
}
 
开发者ID:contentful,项目名称:vault,代码行数:13,代码来源:SyncRunnable.java


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