2015-10-01 36 views
2

一旦我的resource creation problem has been solved,我的demo.ckan.org存在另一個問題。未在demo.ckan.org上爲資源創建視圖

創建資源後,我創建了一個數據存儲和upserted一些數據:

POST http://demo.ckan.org:80/api/3/action/resource_create HTTP/1.1 
{"help": "http://demo.ckan.org/api/3/action/help_show?name=resource_create", "success": true, "result": {"cache_last_updated": null, "cache_url": null, "mimetype_inner": null, "hash": "", "description": "", "format": "", "url": "http://none", "created": "2015-10-01T06:18:25.471301", "state": "active", "webstore_last_updated": null, "webstore_url": null, "package_id": "51b379eb-a2a4-49d8-89b3-188dafdd0279", "last_modified": null, "mimetype": null, "url_type": null, "position": 0, "revision_id": "75c80743-66a8-49d2-a01f-ad67734386f5", "size": null, "id": "12eab044-7853-4907-9879-872550f1376b", "resource_type": null, "name": "room1_room"}} 

POST http://demo.ckan.org:80/api/3/action/datastore_create HTTP/1.1 
{"help": "http://demo.ckan.org/api/3/action/help_show?name=datastore_create", "success": true, "result": {"fields": [{"type": "int", "id": "recvTimeTs"}, {"type": "timestamp", "id": "recvTime"}, {"type": "text", "id": "entityId"}, {"type": "text", "id": "entityType"}, {"type": "text", "id": "attrName"}, {"type": "text", "id": "attrType"}, {"type": "json", "id": "attrValue"}, {"type": "json", "id": "attrMd"}], "method": "insert", "resource_id": "12eab044-7853-4907-9879-872550f1376b"}} 

POST http://demo.ckan.org:80/api/3/action/datastore_upsert HTTP/1.1 
{"help": "http://demo.ckan.org/api/3/action/help_show?name=datastore_upsert", "success": true, "result": {"records": [{"attrType": "centigrade", "recvTime": "2015-10-01T06:18:24.72Z", "recvTimeTs": "1443680304", "attrValue": "26.5", "entityType": "Room", "attrName": "temperature", "entityId": "Room1"}], "method": "insert", "resource_id": "12eab044-7853-4907-9879-872550f1376b"}} 

的數據是存在的,它可以通過datastore_search檢索:

curl -s -S -H "Authorization: b4f6cd71-b592-49a3-bb85-9cd5a0f2eb68" "http://demo.ckan.org/api/3/action/datastore_search?resource_id=12eab044-7853-4907-9879-872550f1376b" 
{"help": "http://demo.ckan.org/api/3/action/help_show?name=datastore_search", "success": true, "result": {"resource_id": "12eab044-7853-4907-9879-872550f1376b", "fields": [{"type": "int4", "id": "_id"}, {"type": "int4", "id": "recvTimeTs"}, {"type": "timestamp", "id": "recvTime"}, {"type": "text", "id": "entityId"}, {"type": "text", "id": "entityType"}, {"type": "text", "id": "attrName"}, {"type": "text", "id": "attrType"}, {"type": "json", "id": "attrValue"}, {"type": "json", "id": "attrMd"}], "records": [{"attrType": "centigrade", "recvTime": "2015-10-01T06:18:24.720000", "recvTimeTs": 1443680304, "attrMd": null, "attrValue": "26.5", "entityType": "Room", "attrName": "temperature", "entityId": "Room1", "_id": 1}], "_links": {"start": "/api/3/action/datastore_search?resource_id=12eab044-7853-4907-9879-872550f1376b", "next": "/api/3/action/datastore_search?offset=100&resource_id=12eab044-7853-4907-9879-872550f1376b"}, "total": 1}} 

Nevetheless中, demo.ckan.org說:

There are no views created for this resource yet.

Not seeing the views you were expecting? Click here for more information.

Here are some reasons you may not be seeing expected views:

  • No view has been created that is suitable for this resource
  • The site administrators may not have enabled the relevant view plugins
  • If a view requires the DataStore, the DataStore plugin may not be enabled, or the data may not have been pushed to the DataStore, or the DataStore hasn't finished processing the data yet

我一直在使用2.2 API ,並且不得創建視圖。現在,我似乎必須用2.4 API創建這樣的視圖。這是否正確,我必須使用http://docs.ckan.org/en/ckan-2.4.0/api/index.html#ckan.logic.action.create.resource_view_create方法?還是僅僅是門戶網站的問題?

回答

1

對於像這樣直接在數據存儲中創建的資源數據,不會自動創建視圖。創建是由資源創建觸發的,假設有一些數據,但您創建一個空資源並稍後向其添加數據。正如其他答案中所建議的那樣,最好的途徑是使用API​​。

+0

我不得不離開這個問題一段時間,現在我回來了。哪些是可用的視圖類型?我無法在文檔中找到它們。謝謝! – frb

+0

這是你在找什麼? http://docs.ckan.org/en/latest/maintaining/data-viewer.html#available-view-plugins 順便說一句,如果您嘗試使用數據存儲資源的用戶界面添加視圖,那麼您將需要'誘使'CKAN相信數據可以通過在資源編輯表單中添加一個格式來可視化,最好的選擇通常是CSV。 –

+0

感謝您的鏈接。我已經找到它了,但是,我不知道如何創建每種視圖類型所需的Json有效載荷。我的意思是,我測試了這個'curl -s -S -H「授權:my-api-key」「http://demo.ckan.org/api/3/action/resource_view_create?resource_id=eaf95b46-3a9f- 4cbc-87cf-a6364e9581b1&title = view_test&view_type = recline_view「'我得到了''錯誤的請求 - JSON錯誤:沒有請求正文數據」'。任何提示? – frb

2

這很可能是演示服務器設置的方式,我建議使用API​​調用來自己創建resource_view(除非您擁有對服務器的控制權並對其進行不同配置)是要走的路。

+0

我不得不離開這個問題一段時間,現在我回來了。哪些是可用的視圖類型?我無法在文檔中找到它們。謝謝! – frb