Re: Sling Type System: started a wiki page for concepts, ideas, motivation

2019-01-13 Thread Christanto Leonardo
Hi,

> Christanto's types know about "multiple" and "required" attributes

Those are for AttributeDefinition. I don't think we need complex validation
for Attribute.
But for Property, pluggable validation is already supported by its API [1].

Cheers,
Christanto

[1]
https://github.com/christanto/sling-whiteboard/blob/a2cf3643b0c94181200705b7a11c756dc8684bd3/modeling/org.apache.sling.types.api/src/main/java/org/apache/sling/types/data/Property.java#L92



On Thu, Jan 10, 2019 at 10:45 PM Bertrand Delacretaz 
wrote:

> On Thu, Jan 10, 2019 at 3:36 PM Carsten Ziegeler 
> wrote:
> > This seems to have a lot in common what we already tried with the
> > validator api/module.
> >
> > https://github.com/apache/sling-org-apache-sling-validation-api ...
>
> Indeed, thanks for pointing this out.
>
> I was planning to merge ideas once we progress - for now I think
> Christanto's types know about "multiple" and "required" attributes, we
> probably need to add a more opaque Validator interface that might use
> this existing module underneath.
>
> But that can happen once we have at least an embryo of the Types API
> which I think should start as small as possible.
>
> -Bertrand
>


Re: Sling Type System: started a wiki page for concepts, ideas, motivation

2019-01-13 Thread Christanto Leonardo
Hi,

I extract out the module into API bundle and implementation bundle.
I also provide an example based on SlingShot content to generate HAL
response.
See the details at
https://github.com/christanto/sling-whiteboard/tree/master/modeling

Cheers,
Christanto


On Thu, Jan 10, 2019 at 8:59 PM Bertrand Delacretaz 
wrote:

> On Thu, Jan 10, 2019 at 4:33 AM Christanto Leonardo
>  wrote:
> > ...BTW I rename things to use "type" instead of "model"...
>
> Great!
>
> Would it be ok for you to extract the key interfaces into a separate
> module?
>
> I'm thinking of Types, DataType, AttributeDefinition and maybe a few
> others - just a minimal core that can be used to use the types,
> without considering how they are actually defined and with ideally no
> implementation details.
>
> My angle is to try to reduce the amount of things on which we need to
> agree on at this point - I'd then be able to recreate my minimal
> resource-schemas example based on these APIs, to verify that they
> provide what I need there, and you could pursue explorations
> independently on your side.
>
> -Bertrand
>


Re: Sling Type System: started a wiki page for concepts, ideas, motivation

2019-01-09 Thread Christanto Leonardo
BTW I rename things to use "type" instead of "model".
See for example
https://github.com/christanto/sling-whiteboard/blob/c8d06a5520bd89ecf97243088e37f75bacf96d38/modeling/src/main/java/org/apache/sling/types/TypeSystem.java

Cheers,
Christanto


Re: Sling Type System: started a wiki page for concepts, ideas, motivation

2019-01-08 Thread Christanto Leonardo
Hi,

On Wed, Jan 9, 2019 at 9:57 AM Jason E Bailey 
wrote:

>
> On Tue, Jan 8, 2019, at 7:43 PM, Christanto Leonardo wrote:
> >
> > ```
> > + /mycontent2
> >   - jcr:primaryNodeType = "nt:unstructured"
> >   - sling:resourceType = "my/page"
> >   - my:created = "2019-01-01T00:00:00Z"
> >   - my:title = "Title 1"
> > ```
> >
> > Here, you simply define a DataModel for `/apps/my/page` having my:created
> > and my:title properties.
> > So when other code inspect the resource (/mycontent2) using DataModel, it
> > will get Property instances for my:created and my:title.
> >
>
> Okay, I think I'm getting there, it's just that we have a difference in
> terminology.  Your idea is along the lines of being able to define a set of
> values that is exposed for a given resource.
>
> When I talk of a Type, it's not just a definition of what is there, it's
> the enforcement of those values. So in defining a "sling:type" of  "folder"
> I expect to be able to define what values must be provided in order to
> create a resource of that type and that is respected without regard to the
> ResourceProvider that is responsible for that location.
>

Yes it can be done. We just need to define the model itself to support it.
So far my example is about reading, the Property.class itself can be used
during writing.

Cheers,
Christanto


Re: Sling Type System: started a wiki page for concepts, ideas, motivation

2019-01-08 Thread Christanto Leonardo
Hi,

On Tue, Jan 8, 2019 at 9:54 PM Bertrand Delacretaz 
wrote:

> Hi,
>
> On Tue, Jan 8, 2019 at 2:15 PM Bertrand Delacretaz
>  wrote:
> > ...That common ground might be a Java API used to access the underlying
> > models, exposing their semantics in a way that clearly defines how
> > they are used in Sling and possibly other applications
>
> I have had a closer look at
> https://github.com/christanto/sling-whiteboard/tree/master/modeling
> and I think the above is contained in that, but I think we might
> reduce that "common ground" to a smaller core API to start with.
>

The core is basically just [Models.class](
https://github.com/christanto/sling-whiteboard/blob/08fd3637c4045470e2b2ba8f8d9bbf4fcf82c211/modeling/src/main/java/org/apache/sling/modeling/Models.java
)

BTW, I think Sling should really consider enhancing the Adaptable interface
for this instead as I explained at
https://github.com/christanto/sling-whiteboard/blob/master/modeling/docs/explainer.md#alternative-way-getting-the-models
This way we can inspect any adaptable on what adaptations are available.


>
> I'm using the "Content Types" name for now to avoid both the Models
> and Sling terms.
>
> How about this, roughly?
>
> -A ContentType can be retrieved by name from the TypeSystem service
> -A ContentType contains a list of Properties (name, data type,
> validation etc..) and nested ContentTypes
> -A ContentType can include a list of Links
> -A Link has a Relation, Description and Target
> -Link Relations are namespaced and the TypeSystem can reserve some
> namespace prefixes
>

> I think this would be enough for my use case of implementing a
> self-describing HTTP API - there's probably a number of details
> missing but that would be the essence of the Type System API.
>
> Christanto, would that work for you assuming we move the above into a
> "type system core" module to allow us to work in parallel on the
> "details" in other modules?
>

Certainly Sling can decide to have
`org.apache.sling.types.rest.ContentType` interface, such that one can do
something like this:

```
Resource content = slingRequest.getResource();
ContentType contentType = content.adaptTo(ContentType.class);

// Use the contentType
contentType.getProperties();
contentType.getLinks();
```

Other modules can decide to define their own modules for their own purposes.

Cheers,
Christanto



>
> -Bertrand
>


Re: Sling Type System: started a wiki page for concepts, ideas, motivation

2019-01-08 Thread Christanto Leonardo
Hi,

> One of the core tenants of Sling is that everything is a Resource. One of
my expectations of a Type system is that I can create a type by POST and
retrieve the structure of the type via a GET.  That the  definitions of a
Type are themselves resources.
>
> I may be missing this from your whitepaper, is that doable?

Only if you decide to store the definition in JCR itself, and then create
the appropriate implementation of PropertyProvider interface, which reads
from JCR.

Cheers,
Christanto


On Tue, Jan 8, 2019 at 11:08 PM Jason E Bailey 
wrote:

> I really appreciate the thought that you put into this.
>
> If you are utilizing the JCR Resource Provider to store a resource you
> have to declare a jcr:primaryType, and you are then bound by the definition
> of the node as to what you can add as an attribute or a child type.  So
> there is such thing as "creating a  resource without a JCR node type" if
> that resource is to be persisted in the JCR.
>
> One of the core tenants of Sling is that everything is a Resource. One of
> my expectations of a Type system is that I can create a type by POST and
> retrieve the structure of the type via a GET.  That the  definitions of a
> Type are themselves resources.
>
> I may be missing this from your whitepaper, is that doable?
>
> --
> Jason
>
> On Tue, Jan 8, 2019, at 9:11 AM, Christanto Leonardo wrote:
> > Hi,
> >
> > > 5. you describe it should be possible to derive data models from JCR
> CND
> > definitions. do you think this should be the major use case? JCR CND
> > definitions are quite out-of-fashion nowadays, and used more for
> historical
> > reasons (or for performance optimizations because oak indexes are based
> on
> > them). the tooling around them is not good (e.g. difficult to
> > update/replace them in a running system).
> >
> > The purpose of the Sling Modeling Framework is to model your
> applications,
> > possibly the existing ones.
> > So if you have an existing resource defined in JCR with all the node
> types
> > (e.g. cq:PageContent resource), the modeling framework must be able to
> > model that.
> > If you create a new resource without JCR node type, then when defining
> that
> > resource type you don't need to use CND.
> >
> > I think it is already explained at:
> >
> >1.
> >
> >
> https://github.com/christanto/sling-whiteboard/blob/master/modeling/docs/explainer.md#data-modeling-using-jcr-node-types
> >2.
> >
> >
> https://github.com/christanto/sling-whiteboard/blob/master/modeling/docs/explainer.md#modeling-the-underlying-platforms-typing-system
> >
> > Cheers,
> > Christanto
> >
> >
> > On Tue, Jan 8, 2019 at 6:44 PM Stefan Seifert 
> > wrote:
> >
> > > hello christanto.
> > >
> > > thanks for bringing this up! some first questions after a first read:
> > >
> > > 1. why defining a new "DSL" to describe the model metadata? what's with
> > > existing things like json schema. defining a completely new DSL often
> has
> > > the risk of not getting it "right" in the first place.
> > >
> > > 2. do you plan to support only a single resource/node and it's
> properties.
> > > what's with sub tree structures, that are supported by JCR CND
> definitions?
> > > more complex data models like forms are unlikely to be represented by a
> > > single resource. or maybe that is already covered with the property
> > > handlers although the name does not indicate it.
> > >
> > > 3. one of the reasons why sling is why it is (without an explicit
> modeling
> > > capability) is the rule #1 of david's model "Data First, Structure
> Later.
> > > Maybe." [1]. this was stated a very long time ago. would be nice if
> you can
> > > add a reference to your explainer page to it as well and explain why
> you
> > > think different nowadays (i think there are good reasons for it, but it
> > > always depends on the use cases).
> > >
> > > 4. the name "Models" can be mixed up with "Sling Models" [2] which
> points
> > > somewhat into the same direction but is currently based on different
> > > concepts and is already used much. but i suppose this can be sorted out
> > > later to decide if this new approach can be "Sling Models 2.0" or the
> new
> > > things should get a different name (like Type System). still it would
> make
> > > sense to also add a reference to sling models to the explainer.
> > >
> > > 5. you des

Re: Sling Type System: started a wiki page for concepts, ideas, motivation

2019-01-08 Thread Christanto Leonardo
Hi,

On Tue, Jan 8, 2019 at 11:08 PM Jason E Bailey 
wrote:

> I really appreciate the thought that you put into this.
>
> If you are utilizing the JCR Resource Provider to store a resource you
> have to declare a jcr:primaryType, and you are then bound by the definition
> of the node as to what you can add as an attribute or a child type.  So
> there is such thing as "creating a  resource without a JCR node type" if
> that resource is to be persisted in the JCR.
>

You can simply use nt:unstructured or any other node type, but what I meant
was that you don't drive your type using JCR node type. Maybe you want to
use sling:resourceType exclusively.

For example if you have an existing content like this:

```
+ /mycontent
  - jcr:primaryNodeType = "nt:folder"
  - jcr:created = "2019-01-01T00:00:00Z"
```

Here, since it is using [nt:folder], you may decide to define a DataModel
for nt:folder by defining jcr:created property for it (Note the property is
actually from the supertype [nt:hierarchyNode]).
So when other code inspect the resource (/mycontent) using DataModel, it
will get Property instance for jcr:created.

But you don't have to strictly model your content using JCR like this. Like
I said, you can simply decide to drive the typing using resource type only:

```
+ /mycontent2
  - jcr:primaryNodeType = "nt:unstructured"
  - sling:resourceType = "my/page"
  - my:created = "2019-01-01T00:00:00Z"
  - my:title = "Title 1"
```

Here, you simply define a DataModel for `/apps/my/page` having my:created
and my:title properties.
So when other code inspect the resource (/mycontent2) using DataModel, it
will get Property instances for my:created and my:title.

Cheers,
Christanto

[nt:folder] https://wiki.apache.org/jackrabbit/nt%3Afolder
[nt:hierarchyNode] https://wiki.apache.org/jackrabbit/nt%3AhierarchyNode



>
> One of the core tenants of Sling is that everything is a Resource. One of
> my expectations of a Type system is that I can create a type by POST and
> retrieve the structure of the type via a GET.  That the  definitions of a
> Type are themselves resources.
>
> I may be missing this from your whitepaper, is that doable?
>
> --
> Jason
>
> On Tue, Jan 8, 2019, at 9:11 AM, Christanto Leonardo wrote:
> > Hi,
> >
> > > 5. you describe it should be possible to derive data models from JCR
> CND
> > definitions. do you think this should be the major use case? JCR CND
> > definitions are quite out-of-fashion nowadays, and used more for
> historical
> > reasons (or for performance optimizations because oak indexes are based
> on
> > them). the tooling around them is not good (e.g. difficult to
> > update/replace them in a running system).
> >
> > The purpose of the Sling Modeling Framework is to model your
> applications,
> > possibly the existing ones.
> > So if you have an existing resource defined in JCR with all the node
> types
> > (e.g. cq:PageContent resource), the modeling framework must be able to
> > model that.
> > If you create a new resource without JCR node type, then when defining
> that
> > resource type you don't need to use CND.
> >
> > I think it is already explained at:
> >
> >1.
> >
> >
> https://github.com/christanto/sling-whiteboard/blob/master/modeling/docs/explainer.md#data-modeling-using-jcr-node-types
> >2.
> >
> >
> https://github.com/christanto/sling-whiteboard/blob/master/modeling/docs/explainer.md#modeling-the-underlying-platforms-typing-system
> >
> > Cheers,
> > Christanto
> >
> >
> > On Tue, Jan 8, 2019 at 6:44 PM Stefan Seifert 
> > wrote:
> >
> > > hello christanto.
> > >
> > > thanks for bringing this up! some first questions after a first read:
> > >
> > > 1. why defining a new "DSL" to describe the model metadata? what's with
> > > existing things like json schema. defining a completely new DSL often
> has
> > > the risk of not getting it "right" in the first place.
> > >
> > > 2. do you plan to support only a single resource/node and it's
> properties.
> > > what's with sub tree structures, that are supported by JCR CND
> definitions?
> > > more complex data models like forms are unlikely to be represented by a
> > > single resource. or maybe that is already covered with the property
> > > handlers although the name does not indicate it.
> > >
> > > 3. one of the reasons why sling is why it is (without an explicit
> modeling
> > > capability) is the rule #1 of david's model "Data First, Structure
> Later.
> > > Maybe."

Re: Sling Type System: started a wiki page for concepts, ideas, motivation

2019-01-08 Thread Christanto Leonardo
Hi,

> 5. you describe it should be possible to derive data models from JCR CND
definitions. do you think this should be the major use case? JCR CND
definitions are quite out-of-fashion nowadays, and used more for historical
reasons (or for performance optimizations because oak indexes are based on
them). the tooling around them is not good (e.g. difficult to
update/replace them in a running system).

The purpose of the Sling Modeling Framework is to model your applications,
possibly the existing ones.
So if you have an existing resource defined in JCR with all the node types
(e.g. cq:PageContent resource), the modeling framework must be able to
model that.
If you create a new resource without JCR node type, then when defining that
resource type you don't need to use CND.

I think it is already explained at:

   1.
   
https://github.com/christanto/sling-whiteboard/blob/master/modeling/docs/explainer.md#data-modeling-using-jcr-node-types
   2.
   
https://github.com/christanto/sling-whiteboard/blob/master/modeling/docs/explainer.md#modeling-the-underlying-platforms-typing-system

Cheers,
Christanto


On Tue, Jan 8, 2019 at 6:44 PM Stefan Seifert 
wrote:

> hello christanto.
>
> thanks for bringing this up! some first questions after a first read:
>
> 1. why defining a new "DSL" to describe the model metadata? what's with
> existing things like json schema. defining a completely new DSL often has
> the risk of not getting it "right" in the first place.
>
> 2. do you plan to support only a single resource/node and it's properties.
> what's with sub tree structures, that are supported by JCR CND definitions?
> more complex data models like forms are unlikely to be represented by a
> single resource. or maybe that is already covered with the property
> handlers although the name does not indicate it.
>
> 3. one of the reasons why sling is why it is (without an explicit modeling
> capability) is the rule #1 of david's model "Data First, Structure Later.
> Maybe." [1]. this was stated a very long time ago. would be nice if you can
> add a reference to your explainer page to it as well and explain why you
> think different nowadays (i think there are good reasons for it, but it
> always depends on the use cases).
>
> 4. the name "Models" can be mixed up with "Sling Models" [2] which points
> somewhat into the same direction but is currently based on different
> concepts and is already used much. but i suppose this can be sorted out
> later to decide if this new approach can be "Sling Models 2.0" or the new
> things should get a different name (like Type System). still it would make
> sense to also add a reference to sling models to the explainer.
>
> 5. you describe it should be possible to derive data models from JCR CND
> definitions. do you think this should be the major use case? JCR CND
> definitions are quite out-of-fashion nowadays, and used more for historical
> reasons (or for performance optimizations because oak indexes are based on
> them). the tooling around them is not good (e.g. difficult to
> update/replace them in a running system).
>
> 6. you describe some "other models" like FormModel, ActionsModel which
> sound like hypermedia support. i do not fully understand how hypermedia
> support fits into the other parts you describe which primarily describe the
> data model and not the actions for them. where does this hypermedia
> metadata come from?
>
> stefan
>
> [1] https://wiki.apache.org/jackrabbit/DavidsModel
> [2] https://sling.apache.org/documentation/bundles/models.html
>
>
>
> >-Original Message-
> >From: Christanto Leonardo [mailto:christanto.leona...@gmail.com]
> >Sent: Tuesday, January 8, 2019 4:03 AM
> >To: dev@sling.apache.org
> >Subject: Re: Sling Type System: started a wiki page for concepts, ideas,
> >motivation
> >
> >Hello,
> >
> >I am currently working on the proposal to introduce the concept of
> modeling
> >in Sling. See it at <
> >https://github.com/christanto/sling-whiteboard/tree/master/modeling>.
> >One is especially encouraged to read the explainer at <
> >https://github.com/christanto/sling-
> >whiteboard/blob/master/modeling/docs/explainer.md
> >>.
> >
> >My hope is that the Sling Modeling Framework can provide the ability to
> >model many concepts in the application, starting with the typing system of
> >the resource (i.e. the resource type definition) as the lowest layer.
> >
> >Please let me know what you think. I plan to continue developing this
> >proposal.
> >
> >Cheers,
> >Christanto
> >
> >On 2018/10/02 11:59:08, Bertrand Delacretaz  wrote:
> >> Hi,&

Re: Sling Type System: started a wiki page for concepts, ideas, motivation

2019-01-08 Thread Christanto Leonardo
Hi,

> 3. one of the reasons why sling is why it is (without an explicit
modeling capability) is the rule #1 of david's model "Data First, Structure
Later. Maybe." [1]. this was stated a very long time ago. would be nice if
you can add a reference to your explainer page to it as well and explain
why you think different nowadays (i think there are good reasons for it,
but it always depends on the use cases).

David's Model clearly made a mistake about the idea of typing. Even if
there is data, it is still have structure and type. Otherwise, how can I
read the data? The argument brought by David's Model is really about strong
typing vs weak typing, which I think simply a counter argument against
RDBMS at that time, which adopts strong typing.

What I am trying to address is the lack of reflection system in Sling. And
the lack of it makes Sling betrays the idea of REST itself, which leverages
the uniform interface as a core concept. Just imagine that in REST, you can
have a generic client (e.g. Firefox) to handle HTML by simply following
HTML spec, without knowing the application specific semantics.

Cheers,
Christanto


On Tue, Jan 8, 2019 at 6:44 PM Stefan Seifert 
wrote:

> hello christanto.
>
> thanks for bringing this up! some first questions after a first read:
>
> 1. why defining a new "DSL" to describe the model metadata? what's with
> existing things like json schema. defining a completely new DSL often has
> the risk of not getting it "right" in the first place.
>
> 2. do you plan to support only a single resource/node and it's properties.
> what's with sub tree structures, that are supported by JCR CND definitions?
> more complex data models like forms are unlikely to be represented by a
> single resource. or maybe that is already covered with the property
> handlers although the name does not indicate it.
>
> 3. one of the reasons why sling is why it is (without an explicit modeling
> capability) is the rule #1 of david's model "Data First, Structure Later.
> Maybe." [1]. this was stated a very long time ago. would be nice if you can
> add a reference to your explainer page to it as well and explain why you
> think different nowadays (i think there are good reasons for it, but it
> always depends on the use cases).
>
> 4. the name "Models" can be mixed up with "Sling Models" [2] which points
> somewhat into the same direction but is currently based on different
> concepts and is already used much. but i suppose this can be sorted out
> later to decide if this new approach can be "Sling Models 2.0" or the new
> things should get a different name (like Type System). still it would make
> sense to also add a reference to sling models to the explainer.
>
> 5. you describe it should be possible to derive data models from JCR CND
> definitions. do you think this should be the major use case? JCR CND
> definitions are quite out-of-fashion nowadays, and used more for historical
> reasons (or for performance optimizations because oak indexes are based on
> them). the tooling around them is not good (e.g. difficult to
> update/replace them in a running system).
>
> 6. you describe some "other models" like FormModel, ActionsModel which
> sound like hypermedia support. i do not fully understand how hypermedia
> support fits into the other parts you describe which primarily describe the
> data model and not the actions for them. where does this hypermedia
> metadata come from?
>
> stefan
>
> [1] https://wiki.apache.org/jackrabbit/DavidsModel
> [2] https://sling.apache.org/documentation/bundles/models.html
>
>
>
> >-Original Message-
> >From: Christanto Leonardo [mailto:christanto.leona...@gmail.com]
> >Sent: Tuesday, January 8, 2019 4:03 AM
> >To: dev@sling.apache.org
> >Subject: Re: Sling Type System: started a wiki page for concepts, ideas,
> >motivation
> >
> >Hello,
> >
> >I am currently working on the proposal to introduce the concept of
> modeling
> >in Sling. See it at <
> >https://github.com/christanto/sling-whiteboard/tree/master/modeling>.
> >One is especially encouraged to read the explainer at <
> >https://github.com/christanto/sling-
> >whiteboard/blob/master/modeling/docs/explainer.md
> >>.
> >
> >My hope is that the Sling Modeling Framework can provide the ability to
> >model many concepts in the application, starting with the typing system of
> >the resource (i.e. the resource type definition) as the lowest layer.
> >
> >Please let me know what you think. I plan to continue developing this
> >proposal.
> >
> >Cheers,
> >Christanto
> >
> >On 2018/10/02 11:59:08, Bertrand Delacre

Re: Sling Type System: started a wiki page for concepts, ideas, motivation

2019-01-08 Thread Christanto Leonardo
Hello,

> 2. do you plan to support only a single resource/node and it's
properties. what's with sub tree structures, that are supported by JCR CND
definitions? more complex data models like forms are unlikely to be
represented by a single resource. or maybe that is already covered with the
property handlers although the name does not indicate it.

So far I just don't see a need to define the sub tree explicitly. In the
end the PropertyHandler will handle the retrieval/persistent to the
persistence later. See [TextPropertyImpl] for example. I think this is good
because the underlying persistence can be changed by swapping the
PropertyHandler implementations.

Cheers,
Christanto

[TextPropertyImpl]
https://github.com/christanto/sling-whiteboard/blob/08fd3637c4045470e2b2ba8f8d9bbf4fcf82c211/modeling/src/main/java/org/apache/sling/modeling/data/commons/impl/TextPropertyImpl.java#L51



On Tue, Jan 8, 2019 at 6:44 PM Stefan Seifert 
wrote:

> hello christanto.
>
> thanks for bringing this up! some first questions after a first read:
>
> 1. why defining a new "DSL" to describe the model metadata? what's with
> existing things like json schema. defining a completely new DSL often has
> the risk of not getting it "right" in the first place.
>
> 2. do you plan to support only a single resource/node and it's properties.
> what's with sub tree structures, that are supported by JCR CND definitions?
> more complex data models like forms are unlikely to be represented by a
> single resource. or maybe that is already covered with the property
> handlers although the name does not indicate it.
>
> 3. one of the reasons why sling is why it is (without an explicit modeling
> capability) is the rule #1 of david's model "Data First, Structure Later.
> Maybe." [1]. this was stated a very long time ago. would be nice if you can
> add a reference to your explainer page to it as well and explain why you
> think different nowadays (i think there are good reasons for it, but it
> always depends on the use cases).
>
> 4. the name "Models" can be mixed up with "Sling Models" [2] which points
> somewhat into the same direction but is currently based on different
> concepts and is already used much. but i suppose this can be sorted out
> later to decide if this new approach can be "Sling Models 2.0" or the new
> things should get a different name (like Type System). still it would make
> sense to also add a reference to sling models to the explainer.
>
> 5. you describe it should be possible to derive data models from JCR CND
> definitions. do you think this should be the major use case? JCR CND
> definitions are quite out-of-fashion nowadays, and used more for historical
> reasons (or for performance optimizations because oak indexes are based on
> them). the tooling around them is not good (e.g. difficult to
> update/replace them in a running system).
>
> 6. you describe some "other models" like FormModel, ActionsModel which
> sound like hypermedia support. i do not fully understand how hypermedia
> support fits into the other parts you describe which primarily describe the
> data model and not the actions for them. where does this hypermedia
> metadata come from?
>
> stefan
>
> [1] https://wiki.apache.org/jackrabbit/DavidsModel
> [2] https://sling.apache.org/documentation/bundles/models.html
>
>
>
> >-Original Message-
> >From: Christanto Leonardo [mailto:christanto.leona...@gmail.com]
> >Sent: Tuesday, January 8, 2019 4:03 AM
> >To: dev@sling.apache.org
> >Subject: Re: Sling Type System: started a wiki page for concepts, ideas,
> >motivation
> >
> >Hello,
> >
> >I am currently working on the proposal to introduce the concept of
> modeling
> >in Sling. See it at <
> >https://github.com/christanto/sling-whiteboard/tree/master/modeling>.
> >One is especially encouraged to read the explainer at <
> >https://github.com/christanto/sling-
> >whiteboard/blob/master/modeling/docs/explainer.md
> >>.
> >
> >My hope is that the Sling Modeling Framework can provide the ability to
> >model many concepts in the application, starting with the typing system of
> >the resource (i.e. the resource type definition) as the lowest layer.
> >
> >Please let me know what you think. I plan to continue developing this
> >proposal.
> >
> >Cheers,
> >Christanto
> >
> >On 2018/10/02 11:59:08, Bertrand Delacretaz  wrote:
> >> Hi,>
> >>
> >> Recent discussions with a number of people from the Sling community>
> >> [1] have helped clarify my thoughts about this, I have started a wiki>
> >> page at
> >

Re: Sling Type System: started a wiki page for concepts, ideas, motivation

2019-01-08 Thread Christanto Leonardo
Hello,

> 1. why defining a new "DSL" to describe the model metadata? what's with
existing things like json schema. defining a completely new DSL often has
the risk of not getting it "right" in the first place.

You still need the runtime API. In this case DataMode.class, Property.class
and other models. Even if you define things using JSON Schema, you don't
want to use JSON API (e.g. JSONObject.class) there.

So the model API itself is just another Java interface leveraging OSGi.
Take DataModel.class. One can define a data model definition by registering
a [PropertyProvider] component, and implement it by reading the information
from JSON. You can also imagine that implementing it using Java annotation
makes sense as well.

Cheers,
Christanto

[PropertyProvider]
https://github.com/christanto/sling-whiteboard/blob/08fd3637c4045470e2b2ba8f8d9bbf4fcf82c211/modeling/src/main/java/org/apache/sling/modeling/data/spi/PropertyProvider.java


On Tue, Jan 8, 2019 at 6:44 PM Stefan Seifert 
wrote:

> hello christanto.
>
> thanks for bringing this up! some first questions after a first read:
>
> 1. why defining a new "DSL" to describe the model metadata? what's with
> existing things like json schema. defining a completely new DSL often has
> the risk of not getting it "right" in the first place.
>
> 2. do you plan to support only a single resource/node and it's properties.
> what's with sub tree structures, that are supported by JCR CND definitions?
> more complex data models like forms are unlikely to be represented by a
> single resource. or maybe that is already covered with the property
> handlers although the name does not indicate it.
>
> 3. one of the reasons why sling is why it is (without an explicit modeling
> capability) is the rule #1 of david's model "Data First, Structure Later.
> Maybe." [1]. this was stated a very long time ago. would be nice if you can
> add a reference to your explainer page to it as well and explain why you
> think different nowadays (i think there are good reasons for it, but it
> always depends on the use cases).
>
> 4. the name "Models" can be mixed up with "Sling Models" [2] which points
> somewhat into the same direction but is currently based on different
> concepts and is already used much. but i suppose this can be sorted out
> later to decide if this new approach can be "Sling Models 2.0" or the new
> things should get a different name (like Type System). still it would make
> sense to also add a reference to sling models to the explainer.
>
> 5. you describe it should be possible to derive data models from JCR CND
> definitions. do you think this should be the major use case? JCR CND
> definitions are quite out-of-fashion nowadays, and used more for historical
> reasons (or for performance optimizations because oak indexes are based on
> them). the tooling around them is not good (e.g. difficult to
> update/replace them in a running system).
>
> 6. you describe some "other models" like FormModel, ActionsModel which
> sound like hypermedia support. i do not fully understand how hypermedia
> support fits into the other parts you describe which primarily describe the
> data model and not the actions for them. where does this hypermedia
> metadata come from?
>
> stefan
>
> [1] https://wiki.apache.org/jackrabbit/DavidsModel
> [2] https://sling.apache.org/documentation/bundles/models.html
>
>
>
> >-Original Message-
> >From: Christanto Leonardo [mailto:christanto.leona...@gmail.com]
> >Sent: Tuesday, January 8, 2019 4:03 AM
> >To: dev@sling.apache.org
> >Subject: Re: Sling Type System: started a wiki page for concepts, ideas,
> >motivation
> >
> >Hello,
> >
> >I am currently working on the proposal to introduce the concept of
> modeling
> >in Sling. See it at <
> >https://github.com/christanto/sling-whiteboard/tree/master/modeling>.
> >One is especially encouraged to read the explainer at <
> >https://github.com/christanto/sling-
> >whiteboard/blob/master/modeling/docs/explainer.md
> >>.
> >
> >My hope is that the Sling Modeling Framework can provide the ability to
> >model many concepts in the application, starting with the typing system of
> >the resource (i.e. the resource type definition) as the lowest layer.
> >
> >Please let me know what you think. I plan to continue developing this
> >proposal.
> >
> >Cheers,
> >Christanto
> >
> >On 2018/10/02 11:59:08, Bertrand Delacretaz  wrote:
> >> Hi,>
> >>
> >> Recent discussions with a number of people from the Sling community>
> >> [1] have helped clarify my th

Re: Sling Type System: started a wiki page for concepts, ideas, motivation

2019-01-08 Thread Christanto Leonardo
Hello,

> 6. you describe some "other models" like FormModel, ActionsModel which
sound like hypermedia support. i do not fully understand how hypermedia
support fits into the other parts you describe which primarily describe the
data model and not the actions for them. where does this hypermedia
metadata come from?

I think example is best to explain this. I will provide it.

In essence, a model can be anything. For example, I can define
ActionsModel, which is a set of HTTP operations applicable for a given
resource. Another one is FormModel, which is an edit form definition of a
given resource. Since the form deals with data the end of the day, the
FormModel may not need to repeat the data definition again (e.g. field1 is
required), by simply leveraging/binding to the DataModel. (Example will
make things clear later on.)
Obviously, you may also think that creating a CreateFormModel makes sense
as well.

Then you can have a servlet using those models to expose hypermedia API. So
instead of just dumping the resource data indiscriminately to the client
like the Sling Default Servlet is doing, the models will drive what actions
are available, what form structure/definition can be shown for the client
to edit the resource, etc.

And the models are not limited for REST API only. You can expose any API
that you may need. e.g. GraphQL, chatbot, as described in the diagram at <
https://github.com/christanto/sling-whiteboard/blob/master/modeling/docs/explainer.md#why-modeling
>.

Cheers,
Christanto



On Tue, Jan 8, 2019 at 6:44 PM Stefan Seifert 
wrote:

> hello christanto.
>
> thanks for bringing this up! some first questions after a first read:
>
> 1. why defining a new "DSL" to describe the model metadata? what's with
> existing things like json schema. defining a completely new DSL often has
> the risk of not getting it "right" in the first place.
>
> 2. do you plan to support only a single resource/node and it's properties.
> what's with sub tree structures, that are supported by JCR CND definitions?
> more complex data models like forms are unlikely to be represented by a
> single resource. or maybe that is already covered with the property
> handlers although the name does not indicate it.
>
> 3. one of the reasons why sling is why it is (without an explicit modeling
> capability) is the rule #1 of david's model "Data First, Structure Later.
> Maybe." [1]. this was stated a very long time ago. would be nice if you can
> add a reference to your explainer page to it as well and explain why you
> think different nowadays (i think there are good reasons for it, but it
> always depends on the use cases).
>
> 4. the name "Models" can be mixed up with "Sling Models" [2] which points
> somewhat into the same direction but is currently based on different
> concepts and is already used much. but i suppose this can be sorted out
> later to decide if this new approach can be "Sling Models 2.0" or the new
> things should get a different name (like Type System). still it would make
> sense to also add a reference to sling models to the explainer.
>
> 5. you describe it should be possible to derive data models from JCR CND
> definitions. do you think this should be the major use case? JCR CND
> definitions are quite out-of-fashion nowadays, and used more for historical
> reasons (or for performance optimizations because oak indexes are based on
> them). the tooling around them is not good (e.g. difficult to
> update/replace them in a running system).
>
> 6. you describe some "other models" like FormModel, ActionsModel which
> sound like hypermedia support. i do not fully understand how hypermedia
> support fits into the other parts you describe which primarily describe the
> data model and not the actions for them. where does this hypermedia
> metadata come from?
>
> stefan
>
> [1] https://wiki.apache.org/jackrabbit/DavidsModel
> [2] https://sling.apache.org/documentation/bundles/models.html
>
>
>
> >-Original Message-
> >From: Christanto Leonardo [mailto:christanto.leona...@gmail.com]
> >Sent: Tuesday, January 8, 2019 4:03 AM
> >To: dev@sling.apache.org
> >Subject: Re: Sling Type System: started a wiki page for concepts, ideas,
> >motivation
> >
> >Hello,
> >
> >I am currently working on the proposal to introduce the concept of
> modeling
> >in Sling. See it at <
> >https://github.com/christanto/sling-whiteboard/tree/master/modeling>.
> >One is especially encouraged to read the explainer at <
> >https://github.com/christanto/sling-
> >whiteboard/blob/master/modeling/docs/explainer.md
> >>.
> >
> >My hope is that the Sling Modeling Framework can pro

Re: Sling Type System: started a wiki page for concepts, ideas, motivation

2019-01-08 Thread Christanto Leonardo
Hello Stefan,

Let's tackle one by one.

> 4. the name "Models" can be mixed up with "Sling Models" [2] which points
somewhat into the same direction but is currently based on different
concepts and is already used much. but i suppose this can be sorted out
later to decide if this new approach can be "Sling Models 2.0" or the new
things should get a different name (like Type System). still it would make
sense to also add a reference to sling models to the explainer.

IMO, Sling Models should have been called "Sling POJO", as it is simply a
mechanic to convert from generic API, such as Resource.class into a
business-domain-friendly API. I just don't see the concept of modeling
there.

For "Type System", the Sling Modeling Framework is more generic than type
system. I assume that type system here refers to the data definition. e.g.
You define resource type `/apps/example/page` to have `title` property with
String property type. Sling Modeling Framework is really for general
purpose modelling, where you can model anything you like around resource
(at least for now, but ideally any Adaptable). And one of the model is
about data, which is defined as [DataModel] currently.

Granted that Sling Models is already here, I don't know what the best way
to call mine to differentiate.

Cheers,
Christanto

[DataModel]
https://github.com/christanto/sling-whiteboard/blob/08fd3637c4045470e2b2ba8f8d9bbf4fcf82c211/modeling/src/main/java/org/apache/sling/modeling/data/DataModel.java



On Tue, Jan 8, 2019 at 6:44 PM Stefan Seifert 
wrote:

> hello christanto.
>
> thanks for bringing this up! some first questions after a first read:
>
> 1. why defining a new "DSL" to describe the model metadata? what's with
> existing things like json schema. defining a completely new DSL often has
> the risk of not getting it "right" in the first place.
>
> 2. do you plan to support only a single resource/node and it's properties.
> what's with sub tree structures, that are supported by JCR CND definitions?
> more complex data models like forms are unlikely to be represented by a
> single resource. or maybe that is already covered with the property
> handlers although the name does not indicate it.
>
> 3. one of the reasons why sling is why it is (without an explicit modeling
> capability) is the rule #1 of david's model "Data First, Structure Later.
> Maybe." [1]. this was stated a very long time ago. would be nice if you can
> add a reference to your explainer page to it as well and explain why you
> think different nowadays (i think there are good reasons for it, but it
> always depends on the use cases).
>
> 4. the name "Models" can be mixed up with "Sling Models" [2] which points
> somewhat into the same direction but is currently based on different
> concepts and is already used much. but i suppose this can be sorted out
> later to decide if this new approach can be "Sling Models 2.0" or the new
> things should get a different name (like Type System). still it would make
> sense to also add a reference to sling models to the explainer.
>
> 5. you describe it should be possible to derive data models from JCR CND
> definitions. do you think this should be the major use case? JCR CND
> definitions are quite out-of-fashion nowadays, and used more for historical
> reasons (or for performance optimizations because oak indexes are based on
> them). the tooling around them is not good (e.g. difficult to
> update/replace them in a running system).
>
> 6. you describe some "other models" like FormModel, ActionsModel which
> sound like hypermedia support. i do not fully understand how hypermedia
> support fits into the other parts you describe which primarily describe the
> data model and not the actions for them. where does this hypermedia
> metadata come from?
>
> stefan
>
> [1] https://wiki.apache.org/jackrabbit/DavidsModel
> [2] https://sling.apache.org/documentation/bundles/models.html
>
>
>
> >-Original Message-
> >From: Christanto Leonardo [mailto:christanto.leona...@gmail.com]
> >Sent: Tuesday, January 8, 2019 4:03 AM
> >To: dev@sling.apache.org
> >Subject: Re: Sling Type System: started a wiki page for concepts, ideas,
> >motivation
> >
> >Hello,
> >
> >I am currently working on the proposal to introduce the concept of
> modeling
> >in Sling. See it at <
> >https://github.com/christanto/sling-whiteboard/tree/master/modeling>.
> >One is especially encouraged to read the explainer at <
> >https://github.com/christanto/sling-
> >whiteboard/blob/master/modeling/docs/explainer.md
> >>.
> >
> >My hope is that the Sling Modeling Framework can 

Re: Sling Type System: started a wiki page for concepts, ideas, motivation

2019-01-07 Thread Christanto Leonardo
Hello,

I am currently working on the proposal to introduce the concept of modeling
in Sling. See it at <
https://github.com/christanto/sling-whiteboard/tree/master/modeling>.
One is especially encouraged to read the explainer at <
https://github.com/christanto/sling-whiteboard/blob/master/modeling/docs/explainer.md
>.

My hope is that the Sling Modeling Framework can provide the ability to
model many concepts in the application, starting with the typing system of
the resource (i.e. the resource type definition) as the lowest layer.

Please let me know what you think. I plan to continue developing this
proposal.

Cheers,
Christanto

On 2018/10/02 11:59:08, Bertrand Delacretaz  wrote:
> Hi,>
>
> Recent discussions with a number of people from the Sling community>
> [1] have helped clarify my thoughts about this, I have started a wiki>
> page at
https://cwiki.apache.org/confluence/display/SLING/Sling+Type+System%3A+motivation+and+requirements>

> and feedback is welcome, on that page or here.>
>
> Roughly, the goal is to create a Sling Type System that defines much>
> more precisely what the various Resource Types can contain, how they>
> work together, etc. with the goal of generating self-describing>
> interfaces.>
>
> Let's see where this leads, it's just rough ideas so far but it feels>
> like a useful unifying concept for Sling.>
>
> -Bertrand>
>
> [1] along with reading "a conversation with Alan Kay, creator of>
> Smalltalk" - https://queue.acm.org/detail.cfm?id=1039523>
>