src/main/java/org/beigesoft/replicator/service/SrvEntityReaderXml.java
@Override
  public final Object read(final Map<String, Object> pAddParam,
    final Reader pReader) throws Exception {
    Map<String, String> attributesMap = readAttributes(pAddParam, pReader);
    if (attributesMap.get("class") == null) {
      throw new ExceptionWithCode(ExceptionWithCode
        .CONFIGURATION_MISTAKE, "There is no class attribute for entity!");
    }
    Class entityClass = Class.forName(attributesMap.get("class"));
    @SuppressWarnings("unchecked")
    Constructor constructor = entityClass.getDeclaredConstructor();
    Object entity = constructor.newInstance();
    Map<String, Map<String, String>> fieldsSettingsMap =
      getMngSettings().lazFldsSts(entityClass);
    for (Map.Entry<String, Map<String, String>> entry
      : fieldsSettingsMap.entrySet()) {
      if ("true".equals(entry.getValue().get("isEnabled"))
        && attributesMap.get(entry.getKey()) != null) {
        ISrvEntityFieldFiller srvEntityFieldFiller = getFieldsFillersMap()
          .get(entry.getValue().get("ISrvEntityFieldFiller"));
        if (srvEntityFieldFiller == null) {
          throw new ExceptionWithCode(ExceptionWithCode
            .CONFIGURATION_MISTAKE, "There is no ISrvEntityFieldFiller "
              + entry.getValue().get("ISrvEntityFieldFiller") + " for "
                + entityClass + " / " + entry.getKey());
        }
        srvEntityFieldFiller.fill(pAddParam, entity, entry.getKey(),
          attributesMap.get(entry.getKey()));
      }
    }
    return entity;
  }
@Override
  public final Object read(final Map<String, Object> pAddParam,
    final Reader pReader) throws Exception {
    Map<String, String> attributesMap = readAttributes(pAddParam, pReader);
    if (attributesMap.get("class") == null) {
      throw new ExceptionWithCode(ExceptionWithCode
        .CONFIGURATION_MISTAKE, "There is no class attribute for entity!");
    }
    Class entityClass = Class.forName(attributesMap.get("class"));
    @SuppressWarnings("unchecked")
    Constructor constructor = entityClass.getDeclaredConstructor();
    Object entity = constructor.newInstance();
    Map<String, Map<String, String>> fieldsSettingsMap =
      getMngSettings().lazFldsSts(entityClass);
    for (Map.Entry<String, Map<String, String>> entry
      : fieldsSettingsMap.entrySet()) {
      if ("true".equals(entry.getValue().get("isEnabled"))
        && attributesMap.get(entry.getKey()) != null) {
        ISrvEntityFieldFiller srvEntityFieldFiller = getFieldsFillersMap()
          .get(entry.getValue().get("ISrvEntityFieldFiller"));
        if (srvEntityFieldFiller == null) {
          throw new ExceptionWithCode(ExceptionWithCode
            .CONFIGURATION_MISTAKE, "There is no ISrvEntityFieldFiller "
              + entry.getValue().get("ISrvEntityFieldFiller") + " for "
                + entityClass + " / " + entry.getKey());
        }
        srvEntityFieldFiller.fill(pAddParam, entity, entry.getKey(),
          attributesMap.get(entry.getKey()));
      }
    }
    return entity;
  }
@ Override public final Object read ( final Map < String , Object > pAddParam , final Reader pReader ) throws Exception { Map < String , String > attributesMap = readAttributes ( pAddParam , pReader ) ; if ( attributesMap . get ( "class" ) == null ) { throw new ExceptionWithCode ( ExceptionWithCode . CONFIGURATION_MISTAKE , "There is no class attribute for entity!" ) ; } Class entityClass = Class . forName ( attributesMap . get ( "class" ) ) ; @ SuppressWarnings ( "unchecked" ) Constructor constructor = entityClass . getDeclaredConstructor ( ) ; Object entity = constructor . newInstance ( ) ; Map < String , Map < String , String > > fieldsSettingsMap = getMngSettings ( ) . lazFldsSts ( entityClass ) ; for ( Map . Entry < String , Map < String , String > > entry : fieldsSettingsMap . entrySet ( ) ) { if ( "true" . equals ( entry . getValue ( ) . get ( "isEnabled" ) ) && attributesMap . get ( entry . getKey ( ) ) != null ) { ISrvEntityFieldFiller srvEntityFieldFiller = getFieldsFillersMap ( ) . get ( entry . getValue ( ) . get ( "ISrvEntityFieldFiller" ) ) ; if ( srvEntityFieldFiller == null ) { throw new ExceptionWithCode ( ExceptionWithCode . CONFIGURATION_MISTAKE , "There is no ISrvEntityFieldFiller " + entry . getValue ( ) . get ( "ISrvEntityFieldFiller" ) + " for " + entityClass + " / " + entry . getKey ( ) ) ; } srvEntityFieldFiller . fill ( pAddParam , entity , entry . getKey ( ) , attributesMap . get ( entry . getKey ( ) ) ) ; } } return entity ; }
<p>
Read entity(fill fields) from a stream (reader - file or through network).
It is invoked when it's start of &lt;entity
</p>
@param pAddParam additional params
@param pReader reader.
@return entity filled/refreshed.
@throws Exception - an exception
<p > Read entity ( fill fields ) from a stream ( reader - file or through network ) . It is invoked when it s start of &lt ; entity < / p >