yaccl 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/yaccl/model/folder.rb +5 -2
- data/lib/yaccl/model/repository.rb +4 -4
- data/lib/yaccl/model/type.rb +25 -3
- data/lib/yaccl.rb +1 -1
- data/spec/helper.rb +13 -4
- data/spec/model/folder_spec.rb +9 -7
- data/spec/model/object_spec.rb +1 -1
- data/spec/model/repository_spec.rb +46 -42
- metadata +1 -1
data/lib/yaccl/model/folder.rb
CHANGED
@@ -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)
|
28
|
-
|
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
|
data/lib/yaccl/model/type.rb
CHANGED
@@ -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
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 =
|
11
|
-
f.properties[
|
12
|
-
f.properties[
|
13
|
-
f.properties[
|
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')
|
data/spec/model/folder_spec.rb
CHANGED
@@ -55,13 +55,15 @@ describe YACCL::Model::Folder do
|
|
55
55
|
end
|
56
56
|
|
57
57
|
it 'create item' do
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
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
|
data/spec/model/object_spec.rb
CHANGED
@@ -84,51 +84,55 @@ describe YACCL::Model::Repository do
|
|
84
84
|
end
|
85
85
|
|
86
86
|
it 'type - item' do
|
87
|
-
|
88
|
-
|
89
|
-
|
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
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
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
|