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

com.buschmais.xo.impl.proxy.relation.object.ToStringMethod Maven / Gradle / Ivy

The newest version!
package com.buschmais.xo.impl.proxy.relation.object;

import com.buschmais.xo.api.metadata.type.CompositeTypeMetadata;
import com.buschmais.xo.api.metadata.type.DatastoreEntityMetadata;
import com.buschmais.xo.api.metadata.type.DatastoreRelationMetadata;
import com.buschmais.xo.impl.SessionContext;
import com.buschmais.xo.impl.proxy.common.object.AbstractDatastoreTypeToStringMethod;
import com.buschmais.xo.spi.datastore.DatastoreEntityManager;
import com.buschmais.xo.spi.datastore.DatastorePropertyManager;
import com.buschmais.xo.spi.datastore.DatastoreRelationManager;

public class ToStringMethod, EntityDiscriminator, Relation, RelationMetadata extends DatastoreRelationMetadata, RelationDiscriminator>
    extends AbstractDatastoreTypeToStringMethod {

    private final SessionContext sessionContext;

    private final DatastoreEntityManager datastoreEntityManager;
    private final DatastoreRelationManager datastoreRelationManager;

    public ToStringMethod(
        SessionContext sessionContext) {
        this.sessionContext = sessionContext;
        this.datastoreEntityManager = sessionContext.getDatastoreSession()
            .getDatastoreEntityManager();
        this.datastoreRelationManager = sessionContext.getDatastoreSession()
            .getDatastoreRelationManager();
    }

    @Override
    protected String getId(Relation datastoreType) {
        return datastoreRelationManager.getRelationId(datastoreType)
            .toString();
    }

    @Override
    protected CompositeTypeMetadata getDynamicType(Relation datastoreType) {
        Entity from = datastoreRelationManager.getFrom(datastoreType);
        Entity to = datastoreRelationManager.getTo(datastoreType);
        return sessionContext.getMetadataProvider()
            .getRelationTypes(datastoreEntityManager.getEntityDiscriminators(from), datastoreRelationManager.getRelationDiscriminator(datastoreType),
                datastoreEntityManager.getEntityDiscriminators(to));
    }

    @Override
    protected DatastorePropertyManager getDatastorePropertyManager() {
        return datastoreRelationManager;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy