private PublisherDataDefinition createPublisherDataDefinition( final DynamicDefinition xpublisherDefinition) { final String definitionName = xpublisherDefinition.getName(); final String publisherNodeRootName = xpublisherDefinition.getDefinitionName("root"); final PublisherNodeDefinition rootDefinition = getNodeDefinitionBuilder(publisherNodeRootName, "root", definitionName).build(); return new PublisherDataDefinition(definitionName, rootDefinition); }
/** {@inheritDoc} */ @Override public Option<Definition> createDefinition(final DynamicDefinition xdefinition) { final Entity entity = xdefinition.getEntity(); if (entity.equals(PublisherGrammar.publisherDefinition)) { final Definition definition = createPublisherDataDefinition(xdefinition); return Option.some(definition); } else if (entity.equals(PublisherGrammar.publisherNodeDefinition)) { createPublisherNodeDefinition(xdefinition); return Option.none(); } else { throw new IllegalArgumentException("Type de définition non gérée: " + xdefinition.getName()); } }
private void createPublisherNodeDefinition(final DynamicDefinition xpublisherNodeDefinition) { final PublisherNodeDefinitionBuilder publisherNodeDefinitionBuilder = new PublisherNodeDefinitionBuilder(); final String publisherNodeDefinitionName = xpublisherNodeDefinition.getName(); // Déclaration des champs string final List<DynamicDefinition> stringFields = xpublisherNodeDefinition.getChildDefinitions(PublisherGrammar.STRING_FIELD); for (final DynamicDefinition field : stringFields) { final String fieldName = field.getName(); publisherNodeDefinitionBuilder.addStringField(fieldName); } // Déclaration des champs boolean final List<DynamicDefinition> booleanFields = xpublisherNodeDefinition.getChildDefinitions(PublisherGrammar.BOOLEAN_FIELD); for (final DynamicDefinition field : booleanFields) { publisherNodeDefinitionBuilder.addBooleanField(field.getName()); } // Déclaration des champs images final List<DynamicDefinition> imageFields = xpublisherNodeDefinition.getChildDefinitions(PublisherGrammar.IMAGE_FIELD); for (final DynamicDefinition field : imageFields) { publisherNodeDefinitionBuilder.addImageField(field.getName()); } // Déclaration des champs data final List<DynamicDefinition> dataFields = xpublisherNodeDefinition.getChildDefinitions(PublisherGrammar.DATA_FIELD); for (final DynamicDefinition field : dataFields) { final String fieldName = field.getName(); final String refNodeName = field.getDefinitionName("type"); final PublisherNodeDefinition publisherNodeDefinition = getNodeDefinitionBuilder(refNodeName, fieldName, publisherNodeDefinitionName).build(); publisherNodeDefinitionBuilder.addNodeField(fieldName, publisherNodeDefinition); } // Déclaration des champs list final List<DynamicDefinition> listFields = xpublisherNodeDefinition.getChildDefinitions(PublisherGrammar.LIST_FIELD); for (final DynamicDefinition field : listFields) { final String fieldName = field.getName(); final String refNodeName = field.getDefinitionName("type"); final PublisherNodeDefinition publisherNodeDefinition = getNodeDefinitionBuilder(refNodeName, fieldName, publisherNodeDefinitionName).build(); publisherNodeDefinitionBuilder.addListField(fieldName, publisherNodeDefinition); } // System.out.println("Add " + publisherDataNodeName); publisherDefinitionMap.put(publisherNodeDefinitionName, publisherNodeDefinitionBuilder); unusedNodes.add(publisherNodeDefinitionName); }