Search in sources :

Example 31 with IDataTypeParser

use of org.whole.lang.parsers.IDataTypeParser in project whole by wholeplatform.

the class DataTypesGrammarsDataTypeParser method install.

public static void install(ILanguageKit lk, Map<EntityDescriptor<?>, IDataTypeParser> strategies) {
    IDataTypeParser persistence = lk.getDataTypeParser(DataTypeParsers.PERSISTENCE);
    IDataTypeParser persistenceStrategy = persistence.getStrategy();
    IDataTypeParser presentation = lk.getDataTypeParser(DataTypeParsers.PRESENTATION);
    IDataTypeParser presentationStrategy = presentation.getStrategy();
    ForwardEntityDescriptorStrategyDataTypeParser persistenceForwardStrategy, presentationForwardStrategy;
    if (persistenceStrategy.equals(presentationStrategy)) {
        persistenceForwardStrategy = presentationForwardStrategy = new ForwardEntityDescriptorStrategyDataTypeParser(presentationStrategy);
        persistenceForwardStrategy.putParserStrategies(strategies);
    } else {
        persistenceForwardStrategy = new ForwardEntityDescriptorStrategyDataTypeParser(presentationStrategy);
        persistenceForwardStrategy.putParserStrategies(strategies);
        presentationForwardStrategy = new ForwardEntityDescriptorStrategyDataTypeParser(presentationStrategy);
        presentationForwardStrategy.putParserStrategies(strategies);
    }
    persistence.setStrategy(persistenceForwardStrategy);
    presentation.setStrategy(presentationForwardStrategy);
}
Also used : ForwardEntityDescriptorStrategyDataTypeParser(org.whole.lang.parsers.ForwardEntityDescriptorStrategyDataTypeParser) IDataTypeParser(org.whole.lang.parsers.IDataTypeParser)

Example 32 with IDataTypeParser

use of org.whole.lang.parsers.IDataTypeParser in project whole by wholeplatform.

the class DataTypesGrammarsDataTypeParser method deploy.

public static void deploy(String grammarURI) {
    Grammar grammar = GrammarsRegistry.instance().getGrammar(grammarURI);
    ILanguageKit lk = ReflectionFactory.getLanguageKit(GrammarsUtils.getLanguageURI(grammar), false, null);
    EntityDescriptor<?> ed = lk.getEntityDescriptorEnum().valueOf("DateLiteral");
    Map<EntityDescriptor<?>, IDataTypeParser> strategies = new HashMap<EntityDescriptor<?>, IDataTypeParser>();
    strategies.put(ed, new DataTypesGrammarsDataTypeParser());
    install(lk, strategies);
}
Also used : EntityDescriptor(org.whole.lang.reflect.EntityDescriptor) HashMap(java.util.HashMap) Grammar(org.whole.lang.grammars.model.Grammar) IDataTypeParser(org.whole.lang.parsers.IDataTypeParser) ILanguageKit(org.whole.lang.reflect.ILanguageKit)

Aggregations

IDataTypeParser (org.whole.lang.parsers.IDataTypeParser)32 Test (org.junit.Test)18 IEntity (org.whole.lang.model.IEntity)12 TestEntitiesEntityFactory (org.whole.lang.testentities.factories.TestEntitiesEntityFactory)10 DataKinds (org.whole.lang.reflect.DataKinds)3 ILanguageKit (org.whole.lang.reflect.ILanguageKit)3 SchemaDataTypeParsers.normalizedString (org.whole.lang.xsd.parsers.SchemaDataTypeParsers.normalizedString)3 ArrayList (java.util.ArrayList)1 Calendar (java.util.Calendar)1 Date (java.util.Date)1 HashMap (java.util.HashMap)1 DateTime (org.joda.time.DateTime)1 Grammar (org.whole.lang.grammars.model.Grammar)1 EnumValue (org.whole.lang.model.EnumValue)1 IOperation (org.whole.lang.operations.IOperation)1 ForwardEntityDescriptorStrategyDataTypeParser (org.whole.lang.parsers.ForwardEntityDescriptorStrategyDataTypeParser)1 AbstractLanguageExtensionDeployer (org.whole.lang.reflect.AbstractLanguageExtensionDeployer)1 DynamicLanguageKit (org.whole.lang.reflect.DynamicLanguageKit)1 EntityDescriptor (org.whole.lang.reflect.EntityDescriptor)1 EntityDescriptorEnum (org.whole.lang.reflect.EntityDescriptorEnum)1