yaccl 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -24,8 +24,11 @@ module YACCL
24
24
  end
25
25
 
26
26
  def children
27
- Services.get_children(repository_id, object_id, nil, nil, nil, nil, nil, nil, nil, nil)[:objects].map do |o|
28
- ObjectFactory.create(repository_id, o[:object])
27
+ children = Services.get_children(repository_id, object_id, nil, nil, nil, nil, nil, nil, nil, nil)
28
+ if children.has_key?(:objects)
29
+ children[:objects].map { |o| ObjectFactory.create(repository_id, o[:object]) }
30
+ else
31
+ []
29
32
  end
30
33
  end
31
34
 
@@ -72,7 +72,7 @@ module YACCL
72
72
  # type
73
73
 
74
74
  def type(type_id)
75
- Type.create(Services.get_type_definition(id, type_id))
75
+ Type.create(id, Services.get_type_definition(id, type_id))
76
76
  end
77
77
 
78
78
  def types
@@ -81,11 +81,11 @@ module YACCL
81
81
 
82
82
 
83
83
  def create_type(type)
84
- Type.create(Services.create_type(id, type.to_hash))
84
+ Type.create(id, Services.create_type(id, type.to_hash))
85
85
  end
86
86
 
87
87
  def update_type(type)
88
- Type.create(Services.update_type(id, type.to_hash))
88
+ Type.create(id, Services.update_type(id, type.to_hash))
89
89
  end
90
90
 
91
91
  def delete_type(type_id)
@@ -109,7 +109,7 @@ module YACCL
109
109
  def _types(arr)
110
110
  types = []
111
111
  arr.each do |t|
112
- types << Type.create(t[:type])
112
+ types << Type.create(id, t[:type])
113
113
  types << _types(t[:children]) if t.has_key?(:children)
114
114
  end
115
115
  types.flatten
@@ -1,6 +1,7 @@
1
1
  module YACCL
2
2
  module Model
3
3
  class Type
4
+ attr_reader :repository_id
4
5
  attr_accessor :id
5
6
  attr_accessor :local_name
6
7
  attr_accessor :local_namespace
@@ -24,11 +25,13 @@ module YACCL
24
25
  attr_accessor :allowed_source_types
25
26
  attr_accessor :allowed_target_types
26
27
 
27
- def self.create(raw)
28
- Type.new(raw)
28
+ def self.create(repository_id, raw)
29
+ Type.new(repository_id, raw)
29
30
  end
30
31
 
31
- def initialize(hash={})
32
+ def initialize(repository_id, hash={})
33
+ @repository_id = repository_id
34
+
32
35
  @id = hash[:id]
33
36
  @local_name = hash[:localName]
34
37
  @local_namespace = hash[:localNamespace]
@@ -57,6 +60,25 @@ module YACCL
57
60
  @property_definitions[property[:id]] = property
58
61
  end
59
62
 
63
+ def new_object
64
+ object = case base_id
65
+ when 'cmis:document'
66
+ Document.new(repository_id)
67
+ when 'cmis:folder'
68
+ Folder.new(repository_id)
69
+ when 'cmis:relationship'
70
+ Relationship.new(repository_id)
71
+ when 'cmis:policy'
72
+ Policy.new(repository_id)
73
+ when 'cmis:item'
74
+ Item.new(repository_id)
75
+ else
76
+ raise "Unsupported base type: #{base_id}"
77
+ end
78
+ object.object_type_id = id
79
+ object
80
+ end
81
+
60
82
  def to_hash
61
83
  hash = {}
62
84
  hash[:id] = id
data/lib/yaccl.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  module YACCL
2
- VERSION = '0.0.2'
2
+ VERSION = '0.0.3'
3
3
 
4
4
  def self.init(url)
5
5
  YACCL.const_set('SERVICE_URL', url)
data/spec/helper.rb CHANGED
@@ -5,16 +5,25 @@ YACCL.init('http://localhost:8080/upncmis/browser')
5
5
 
6
6
  def create_repository(id)
7
7
  meta = YACCL::Model::Server.repository('meta')
8
+
9
+ repo_type = meta.type('repository')
10
+ property_definitions = repo_type.property_definitions.keys
11
+
8
12
  f = meta.new_folder
9
13
  f.name = id
10
- f.object_type_id = 'repository'
11
- f.properties['supportsRelationships'] = true
12
- f.properties['supportsPolicies'] = true
13
- f.properties['supportsItem'] = true
14
+ f.object_type_id = repo_type.id
15
+ f.properties[:supportsRelationships] = true if property_definitions.include?(:supportsRelationships)
16
+ f.properties[:supportsPolicies] = true if property_definitions.include?(:supportsPolicies)
17
+ f.properties[:supportsItem] = true if property_definitions.include?(:supportsItems)
14
18
  meta.root.create(f)
19
+
15
20
  YACCL::Model::Server.repository(id)
16
21
  end
17
22
 
18
23
  def delete_repository(id)
19
24
  YACCL::Model::Server.repository('meta').object(id).delete
20
25
  end
26
+
27
+ repo = create_repository('lala')
28
+ puts repo.capabilities
29
+ delete_repository('lala')
@@ -55,13 +55,15 @@ describe YACCL::Model::Folder do
55
55
  end
56
56
 
57
57
  it 'create item' do
58
- new_object = @repo.new_item
59
- new_object.name = 'item1'
60
- new_object.object_type_id = 'cmis:item'
61
- object = @repo.root.create(new_object)
62
- object.should be_a_kind_of YACCL::Model::Item
63
- object.name.should eq 'item1'
64
- object.delete
58
+ begin
59
+ new_object = @repo.new_item
60
+ new_object.name = 'item1'
61
+ new_object.object_type_id = 'cmis:item'
62
+ object = @repo.root.create(new_object)
63
+ object.should be_a_kind_of YACCL::Model::Item
64
+ object.name.should eq 'item1'
65
+ object.delete
66
+ end unless @repo.cmis_version_supported < '1.1'
65
67
  end
66
68
 
67
69
  it 'create object' do
@@ -27,7 +27,7 @@ describe YACCL::Model::Object do
27
27
  it 'delete' do
28
28
  doc = create_document
29
29
  doc.delete
30
- #TODO check
30
+ # TODO check
31
31
  end
32
32
 
33
33
  it 'allowable actions' do
@@ -84,51 +84,55 @@ describe YACCL::Model::Repository do
84
84
  end
85
85
 
86
86
  it 'type - item' do
87
- item = @repo.type('cmis:item')
88
- item.should be_a_kind_of YACCL::Model::Type
89
- item.id.should eq 'cmis:item'
87
+ begin
88
+ item = @repo.type('cmis:item')
89
+ item.should be_a_kind_of YACCL::Model::Type
90
+ item.id.should eq 'cmis:item'
91
+ end unless @repo.cmis_version_supported < '1.1'
90
92
  end
91
93
 
92
94
  it 'create, get, delete type - document' do
93
- type_id = 'apple'
94
-
95
- type = YACCL::Model::Type.new
96
- type.id = type_id
97
- type.local_name = 'apple'
98
- type.query_name = 'apple'
99
- type.display_name = 'apple'
100
- type.parent_id = 'cmis:document'
101
- type.base_id = 'cmis:document'
102
- type.description = 'appel'
103
- type.creatable = true
104
- type.fileable = true
105
- type.queryable = true
106
- type.controllable_policy = true
107
- type.controllable_acl = true
108
- type.fulltext_indexed = true
109
- type.included_in_supertype_query = true
110
- type.content_stream_allowed = 'allowed'
111
- type.versionable = false
112
-
113
- type.add_property_definition(id: 'color',
114
- localName: 'color',
115
- queryName: 'color',
116
- displayName: 'color',
117
- description: 'color',
118
- propertyType: 'string',
119
- cardinality: 'single',
120
- updatability: 'readwrite',
121
- inherited: false,
122
- required: false,
123
- queryable: true,
124
- orderable: true)
125
-
126
- @repo.create_type(type)
127
- @repo.type(type_id).tap do |t|
128
- t.should be_a_kind_of YACCL::Model::Type
129
- t.id.should eq type_id
130
- end
131
- @repo.delete_type(type_id)
95
+ begin
96
+ type_id = 'apple'
97
+
98
+ type = YACCL::Model::Type.new
99
+ type.id = type_id
100
+ type.local_name = 'apple'
101
+ type.query_name = 'apple'
102
+ type.display_name = 'apple'
103
+ type.parent_id = 'cmis:document'
104
+ type.base_id = 'cmis:document'
105
+ type.description = 'appel'
106
+ type.creatable = true
107
+ type.fileable = true
108
+ type.queryable = true
109
+ type.controllable_policy = true
110
+ type.controllable_acl = true
111
+ type.fulltext_indexed = true
112
+ type.included_in_supertype_query = true
113
+ type.content_stream_allowed = 'allowed'
114
+ type.versionable = false
115
+
116
+ type.add_property_definition(id: 'color',
117
+ localName: 'color',
118
+ queryName: 'color',
119
+ displayName: 'color',
120
+ description: 'color',
121
+ propertyType: 'string',
122
+ cardinality: 'single',
123
+ updatability: 'readwrite',
124
+ inherited: false,
125
+ required: false,
126
+ queryable: true,
127
+ orderable: true)
128
+
129
+ @repo.create_type(type)
130
+ @repo.type(type_id).tap do |t|
131
+ t.should be_a_kind_of YACCL::Model::Type
132
+ t.id.should eq type_id
133
+ end
134
+ @repo.delete_type(type_id)
135
+ end unless @repo.cmis_version_supported < '1.1'
132
136
  end
133
137
  end
134
138
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yaccl
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: