Alfresco nested collections - collections

Is it possible to have nested collections within Alfresco? I'm on Community Edition 3.4. I'd like to have a collection that contains other collections.
Is there something I need to do while defining the collection in the content model XML?

tl;dr: it's not supported out of the box
The data list model defines dl:dataListItem as a child type of cm:content, therefore you can't nest data lists the same way you nest documents into folders.
What you could do is to create a custom peer association between data lists, in order to create your own nesting logic. This would require refactoring the Share UI components that handle list to let them get knowledge of such a custom model, and show nested lists appropriately.

What you could do is define your own custom constraint.
Instead of using the predefined LIST constraint, you could refer to a Java class.
Here is a link to the Wiki
So you could define a nested collection. But to present this in either Explorer or Share, you'd have to write new renderers/generators(explorer) or new share template for that specific field.

Related

What is the Best Practice and Efficient way to organize Query, Mutation and Subscription classes in Hotchocolate GraphQL

which one is best and efficient way to organize query, mutation and subscription class?
Partial class
[ExtendObjectType(OperationTypeNames.Query)]
others?
And what is the difference, what is happening behind the scenes?
In this official docs
If we just want to organize the fields of one of our types in different files, we can use partial classes in the Annotation-based approach.
But in workshop ExtendObjectType is used
I have also asked the same question here
With partial classes nothing special is happening behind the scenes as it's just a regular C# feature.
Its downsides are that they can not be used across assemblies and you can't replace or remove fields that where defined in another partial class.
Type extensions on the other hand are being merged with the original type definition by Hot Chocolate. They work across assemblies and allow you to hide or replace members of the original type definition.
As you've quoted from the documentation, partial classes are easier to use if you just want to split your type definitions into different files within the same project. For a more Hot Chocolate integrated way of combining these multiple files (classes) Type Extensions should be used.

Is there an elegant solution for models that are very similair and do have a relation towards each other, but are not quite the same?

I've recently started developing in .NET core.
When developing I encountered the situation that I have to make very similair models that aren't quite the same. For example, let's talk about a booking model:
Frontend: Here I need a model that gets posted as a JSON to my backend and gets deserliazed to a sort of FrontendBooking model.
Backend: I need to add Customer data to the booking, therefore I need to add fields like: CustomerName and CustomerAddress, based on their CustomerId. The backend needs to provide this data, I do not want the frontend to determine these fields. I combine these models to prepare it for an API call. To a model called RequestBooking.
API: I sent RequestBooking to an API and get a response with a similair object that has for example a Status and BookingId added, this was added to the model by the API. So I need to deserialize this to an object called: ResponseBooking.
Database: Finally I wish to store the object to a database, not all properties of the model are relevant however, therefore I create another model called: DatabaseBooking and store this to the databse.
When a property is added, removed or changed. Then I'll have to change it for each of these models.
Is there a design pattern or some other solution, so this is more manageable?
Also, what is best practise for naming these models? Naming them all Booking doesn't feel quite right and adding what they're used for doesn't feel quite right either.
Thanks in advance.
Well, in general you will need different (although similar) models at least at these levels:
Server: here you can make use of Domain Driven Design. You will have an object Booking that is responsible for its logic and contain all properties and methods like e.g. MarkAsCancelled. You can use Entity Framework to use the same object in the database, which will correspond to a database table. EF allows you to mark some properties as not being saved in the DB. Also you can set up EF in the DbContext class and thus not use DB specific attributes in the class. So one object for DB and backend business logic.
API: obviously you cannot send your domain object to the API, e.g. REST. In the API you may want to combine properties of several domain objects or hide some properties. You will have to define a set of Data Transfer Objects (DTOs), e.g. BookingDto. How to convert your domain objects to DTOs? Solutions like AutoMapper may help. You just set up convertion rules once.
Now you can describe your API in e.g. Swagger. With Swagger Codegen you can than generate code for your server (.net) and client (e.g. JS).
In the end you will have to support the following:
API definition (e.g. Swagger). Code for server DTOs and client
objects is autogenerated. You modify API definition once, both sides
get new objects.
DDD Models that also are used for the Database. They
may be faily independent from your DTOs. Mapping is handled for you
semi-automatically by e.g. Automapper
All said is just a suggestion. All the layers and number of objects can and should be adapted to the specific needs of your project. E.g. you may want to use separate objects for the database if you are not using a relational mapper like EF or do not want to mix DB and logic.

How to delete a record from a dictionary?

I have an invalid dictionary in Alfresco database, I need to delete some records from that dictionary. How to do that programmatically? Manually?
Thank you!
(this was custom dictionary which was filled up from the file programmatically, now it is one of Alfresco's nodes )
I agree with Gagravarr that you can just delete the nodes you no longer want.
If you want to remove the content model from the data dictionary, you'll need to first delete all of the nodes that are instances of types that are in the model and remove any aspects defined in the model from existing nodes, then you can remove the content model from your system.
A good way to find nodes that are instances of a certain type is to use the node browser and the TYPE:"sc:someType" syntax. Similarly, you can use ASPECT:"sc:someAspect" to find nodes that have a certain aspect applied.
Hopefully, your custom content model was added and packaged in an AMP. If so, you just need to find the model XML file and delete it, then delete the reference from the model context file. Then, you can re-package the AMP and deploy it to your system.
In an Alfresco SDK project structure, the model is typically in a directory like some-project/some-project-platform-jar/src/main/resources/alfresco/module/some-project-platform-jar/model/content-model.xml.
The model context file is usually something like: some-project/some-project-platform-jar/src/main/resources/alfresco/module/some-project-platform-jar/context/bootstrap-context.xml.

IHierarchicalDataSource, Hierarchy structure, ASP.NET

I am building a hierarchy structure from scratch and I am trying to determine the best route to take. I found the following link below from another StackOverflow question:
Nested Set Model
I like the idea of nested sets and have begun to build my database, based on this pattern. I am now unsure how to query the data out in such a way that I will easily be able to bind to a control, such as the TreeView. I will need to be able to reorder and commit the data back as well. Any suggestions?
SQL 2005 added support for recursive queries. I'm using a recursive query to return a tree of data that populates a TreeView. For each record, I find the matching parent node from the TreeView and add its new child.
For updates you could serialize the tree to XML, then use the XML features in sql 2005 to run an "update" statement.

Creating Drupal CCK content programmatically/ via API

I am working with a Drupal 6.x system to create exercise / personal training programmes, and am using the CCK with content types of Exercise and Programme, where Programme contains a few header fields and a list of node references to the exercises it consists of. This works great and I can manually create programmes which work fine. I now wish to create a module which can generate these programs automatically based on a number of algorithms I have developed, the process will look like:
Load all exercises into array
Load users personal info (entered previously)
Establish best suited exercises
Create new programme content type
Save programme
An Exercise has a number of related attributes and although I could do all of the above using SQL directly into the tables it would be quite complex and doesn't feel right. I would like in step 1 to load the exercises as an array of Exercise objects (node_load?), and then create a programme object and save. Is this OO type approach possible or do I have to resort to manipulating the data directly?
The best way to tackle this problem would be to write your own module to do this.
Step 1 you can do node_load($nid) on all the excercies
Step 2 you can use user_load($uid)
Step 3 you'll need to iterate through the user object and match up to the appropriate excercies.
Step 4/5 I'd create a new $node = stdClass(); object and populate the attributes with the correct data then perfrom a node_save($node); this will assign it a $node->id etc.
If your unsure on what attributes are in your training program node, then do a print_r($node); on one you've created already.
Phil
Drupal doesn't provide any "cascading" save mechanism to save a hierarchy of nodes in one swoop. You'll need to build each node in code and call node_save() on it explicitly as described by Phil Carter.
The Node Export module can generate sample code for creating a node (complete with CCK fields) programatically.
There are a ton of modules that try to do the import thing right. Take a look at a comparison of them http://groups.drupal.org/node/21338
If you need strategies or examples of importing stuff into nodes, those are a great resource.
I don't think "creating" these programs is even necessary.
Why not just display a list of exercises that match your requirements and share 'characteristics' with the user.
I'd accomplish this by making the 'characteristics' be taxonomy. Then attached to users either with a profile, or taxonomy flag. Then display a list (perhaps even a view at first) and those with the same characteristic tags within exercises.
This would be dynamic and user specific and note require pre-loading a bunch of programmes.
A thought.

Resources