Add Aspect To Asset in MindSphere - mindsphere

I am using the MindSphere JAVA SDK (1.0.0). I have an asset and I created an Aspect.
How can I assign the existing aspect to the existing asset in java?

Workflow is always:
create the aspect
add the aspect to an assettype
create an instance asset of this assettype
If you want to update an asset, you just have to add the aspect to the related assettype.

Related

Defining default #GeneratedValue Strategy for Symfony MakerBundle

When using the MakerBundle in Symfony (4) to create new entity (make:entity EntityName), an id is generated by default with annotation (if annotations enabled) #GeneratedValue.
#GeneratedValue means #GeneratedValue(strategy="AUTO").
According to the Doctrine documentation, the AUTO strategy is supposed to use SERIAL type for the id in PostgreSQL. But, I do not know why in my case, the AUTO strategy use SEQUENCE for the id.
Then, I can force it to use SERIAL by changing by hand into #GeneratedValue(strategy="IDENTITY") which means using SERIAL type in PostgreSQL.
Is there any way to change the default #GeneratedValue annotation created by the MakerBundle for the new entities to be created with the #GeneratedValue(strategy="IDENTITY") annotation ?
What you could possibly do is decorate \Symfony\Bundle\MakerBundle\Doctrine\EntityClassGenerator which is registered as a service named maker.entity_class_generator in vendor/symfony/maker-bundle/src/Resources/config/services.xml and override its generateEntityClass method to make a different call on the Generator's generateClass method, specifically the file path could be changed there.
Seems like the file path there could be relative or absolute, so with some trial and error you could get it to output the annotation you want. The template that the maker bundle uses now is at vendor/symfony/maker-bundle/src/Resources/skeleton/doctrine/Entity.tpl.php, and it's pretty straightforward to modify.

symfony dynamically add translation based on condition

I'm searching for a way to add a translation to an existing translation catalogue during runtime.
I have a working symfony 2.3 application which uses translations in de/en/fr/it and fetches all available translation keys from /Resources/translations/messages..yml.
Now if a user logs in I want to have the possibility to override some of the already loaded labels based on setting for that user (e.g. textfield in DB which holds key-value-pairs).
E.g.
messages.en.yml
company.name.short: Company profile
Usersetting:
company.name.short: Profile for company
I found no way to add/override keys to the existing catalogue or to make them available in twig. Is there a Bundle or a setting or some Symfony magic to get this to work?
You'll probably want to extend Symfony's own translation class for this. This article explains how to do that:
http://www.webtipblog.com/extend-symfony-2-translator-to-log-untranslated-messages-to-a-database/
The key point is to override the "translator.class" parameter in your config, and then point it to your own class that first checks for database overrules and will defer to the symfony default implementation if it cannot find one.

Exclude asset_version for image

How to exclude apply asset_version for images when we use assetic?
I know two options:
Don't use asset helper, which won't make full URL and won't add undesired asset_version.
Override helper method getUrl() in service named templating.helper.assets which is instance of Symfony\Component\Templating\Helper\CoreAssetsHelper by creating a new service extending it (for example) where you write your own logic for such rules.
If you do it second way then please share the code, in case somebody else will want to implement it later.

Modifying existing Alfresco Content Model

We would like to insert a class between two Alfresco class sys:base and cm:person. What are the options? Like type Party has 2 children, Person(individual) and Organisation, So how to model it as Type Party comes between sys:base and cm:person.
That's bad practice! You should not modify Alfresco's default content model.
Take a look at Aspects - you should be able to create a new aspect & add your aspect to your cm:person nodes

Symfony2/Doctrine: How to persist an entity from the entity class?

Short Description of the problem:
I generate a file inside the entity class and would like to save the filename to the database. The controller doesn't know about this (wheter or not the filename has changed, so it's not practical to persist from the controller.
Is there a way for an Entity to persist itself?
Example of my use:
The entity class is for an image in a gallery. I always keep the original file and work with a cached version of the file. When the image is changed (rotated for example), the cached version is deleted. The cached version also be deleted in other cases. When the file is needed, I check if the cached file exists, otherwise it is regenerated with a new filename from the archived image. I need a new filename because that resets the cache for various thumbnail sizes.
When I generate that new file, I have to save its filename to the database somehow. Because it is only decided in the Entity when to regenerate the image, it would be practical if the entity could persist itself to the database, but I haven't found a solution for that.
Is there a way to do this or is there a whole different concept I should be using to regenerate the image file?
Entities in Doctrine are not active records - they cannot perform persistance actions by themselves, so they rely on a Big Brother [the entity manager].
Even if the controller doesn't know wether any filename as changed or not, you do - just persist your picture every time: if nothing changed, Doctrine won't touch the entity.
Have a look at lifecycle events too, maybe you can find useful to fire a #PreUpdate method before persistance [e.g. generating thumbnails].

Resources