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

org.randombits.confluence.metadata.impl.handler.EvaluatedNumberHandler Maven / Gradle / Ivy

There is a newer version: 7.4.1
Show newest version
package org.randombits.confluence.metadata.impl.handler;

import com.atlassian.confluence.core.ContentEntityManager;
import org.apache.log4j.Logger;
import org.randombits.confluence.metadata.AbstractTypeHandler;
import org.randombits.confluence.metadata.MetadataManager;
import org.randombits.confluence.metadata.type.EvaluatedNumber;
import org.randombits.confluence.metadata.reference.EvaluatedNumberReference;
import org.springframework.beans.factory.annotation.Qualifier;


/**
 * Converts an {@link org.randombits.confluence.metadata.reference.EvaluatedNumberReference} into a {@link Number}.
 */
public class EvaluatedNumberHandler extends AbstractTypeHandler {

    public static final String ALIAS = "ExpressionReference";

    private static final Logger LOG = Logger.getLogger(EvaluatedNumberHandler.class);

    private final ContentEntityManager contentEntityManager;

    private final MetadataManager metadataManager;

    public EvaluatedNumberHandler( @Qualifier("contentEntityManager") ContentEntityManager contentEntityManager, MetadataManager metadataManager) {
        super( EvaluatedNumber.class, EvaluatedNumberReference.class );
        this.contentEntityManager = contentEntityManager;
        this.metadataManager = metadataManager;
    }

    @Override
    protected EvaluatedNumber doGetOriginal( EvaluatedNumberReference stored ) {
        return new EvaluatedNumber(metadataManager, contentEntityManager.getById( stored.getContentId() ), stored.getDataPath(), stored.getExpression());
    }

    protected EvaluatedNumberReference doGetStored( EvaluatedNumber original ) {
        return new EvaluatedNumberReference( original.getContent().getId(), original.getDataPath(), original.getExpression() );
    }

    @Override
    protected String getAlias() {
        return ALIAS;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy