All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.enonic.xp.lib.schema.GetDynamicStylesHandler Maven / Gradle / Ivy

package com.enonic.xp.lib.schema;

import java.util.function.Supplier;

import com.enonic.xp.app.ApplicationKey;
import com.enonic.xp.lib.schema.mapper.StyleDescriptorMapper;
import com.enonic.xp.resource.DynamicSchemaResult;
import com.enonic.xp.resource.DynamicSchemaService;
import com.enonic.xp.script.bean.BeanContext;
import com.enonic.xp.script.bean.ScriptBean;
import com.enonic.xp.style.StyleDescriptor;

public final class GetDynamicStylesHandler
    implements ScriptBean
{
    private String application;

    private Supplier dynamicSchemaServiceSupplier;

    public void setApplication( final String application )
    {
        this.application = application;
    }

    public StyleDescriptorMapper execute()
    {
        final DynamicSchemaResult result =
            dynamicSchemaServiceSupplier.get().getStyles( ApplicationKey.from( this.application ) );
        return result != null ? new StyleDescriptorMapper( result.getSchema(), result.getResource() ) : null;
    }

    @Override
    public void initialize( final BeanContext context )
    {
        dynamicSchemaServiceSupplier = context.getService( DynamicSchemaService.class );
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy