Example #1
0
 LogbookTableModel(Collection<LogbookVO> colllogbookvo, AttributeCVO attrcvoHeader) {
   super(new ArrayList<LogbookVO>(colllogbookvo));
   if (attrcvoHeader != null) {
     // Pre-sort logbook to ensure the interesting attribute comes first.
     // Since (further) sorting is stable, this relative attribute order will remain.
     Collections.sort(this.getRows(), new AttributeHeaderComparator(attrcvoHeader.getId()));
   }
 }
Example #2
0
  public ImportStructure(Integer iImportStructureId) {
    try {
      final MasterDataFacadeLocal mdfacade =
          ServerServiceLocator.getInstance().getFacade(MasterDataFacadeLocal.class);

      final MasterDataVO mdcvoStructure =
          mdfacade.get(NuclosEntity.IMPORT.getEntityName(), iImportStructureId);

      this.name = (String) mdcvoStructure.getField("name");
      this.sDelimiter = (String) mdcvoStructure.getField("delimiter");
      this.sEncoding = (String) mdcvoStructure.getField("encoding");
      this.iHeaderLineCount = (Integer) mdcvoStructure.getField("headerlines");
      this.bInsert = (Boolean) mdcvoStructure.getField("insert");
      this.bUpdate = (Boolean) mdcvoStructure.getField("update");
      this.bDelete = (Boolean) mdcvoStructure.getField("delete");

      this.iEntityId = (Integer) mdcvoStructure.getField("entityId");

      this.items = new HashMap<String, Item>();
      final Collection<MasterDataVO> collAttributes =
          mdfacade.getDependantMasterData(
              NuclosEntity.IMPORTATTRIBUTE.getEntityName(), "import", iImportStructureId);

      final String entityname =
          MetaDataServerProvider.getInstance()
              .getEntity(IdUtils.toLongId(this.iEntityId))
              .getEntity();
      this.entityname = entityname;
      final boolean isModule = Modules.getInstance().existModule(entityname);

      for (MasterDataVO mdcvo : collAttributes) {
        final Integer iIndex = (Integer) mdcvo.getField("fieldcolumn");
        final String attribute = (String) mdcvo.getField("attribute");
        final String format = (String) mdcvo.getField("parsestring");
        final boolean preserve = (Boolean) mdcvo.getField("preserve");
        final NuclosScript script = (NuclosScript) mdcvo.getField("script");
        final Class<?> clazz;

        String foreignentity = null;
        if (isModule) {
          AttributeCVO meta = AttributeCache.getInstance().getAttribute(entityname, attribute);
          clazz = meta.getJavaClass();
          foreignentity = meta.getExternalEntity();
        } else {
          MasterDataMetaFieldVO meta =
              MasterDataMetaCache.getInstance().getMetaData(entityname).getField(attribute);
          clazz = meta.getJavaClass();
          foreignentity = meta.getForeignEntity();
        }

        final Set<ForeignEntityIdentifier> foreignentityattributes =
            new HashSet<ImportStructure.ForeignEntityIdentifier>();

        if (foreignentity != null
            && !attribute.equals(NuclosEOField.PROCESS.getMetaData().getField())
            && !attribute.equals(NuclosEOField.STATE.getMetaData().getField())) {
          final boolean isFeModule = Modules.getInstance().existModule(foreignentity);

          final Collection<MasterDataVO> collForeignEntityIdentifiers =
              mdfacade.getDependantMasterData(
                  NuclosEntity.IMPORTFEIDENTIFIER.getEntityName(),
                  "importattribute",
                  mdcvo.getIntId());

          for (MasterDataVO mdvo : collForeignEntityIdentifiers) {
            final Integer iColumn = (Integer) mdvo.getField("fieldcolumn");
            final String feattribute = (String) mdvo.getField("attribute");
            final String feformat = (String) mdvo.getField("parsestring");
            final Class<?> feclazz;

            if (isFeModule) {
              AttributeCVO meta =
                  AttributeCache.getInstance().getAttribute(foreignentity, feattribute);
              feclazz = meta.getJavaClass();
            } else {
              MasterDataMetaFieldVO meta =
                  MasterDataMetaCache.getInstance()
                      .getMetaData(foreignentity)
                      .getField(feattribute);
              feclazz = meta.getJavaClass();
            }

            foreignentityattributes.add(
                new ForeignEntityIdentifier(
                    iColumn, foreignentity, feattribute, feclazz, feformat));
          }
        } else {
          foreignentity = null;
        }

        this.items.put(
            attribute,
            new ImportStructure.Item(
                iIndex,
                entityname,
                attribute,
                clazz,
                format,
                preserve,
                foreignentity,
                foreignentityattributes,
                script));
      }

      final Collection<MasterDataVO> collIdentifiers =
          mdfacade.getDependantMasterData(
              NuclosEntity.IMPORTIDENTIFIER.getEntityName(), "import", iImportStructureId);
      for (final MasterDataVO mdcvo : collIdentifiers) {
        this.stIdentifiers.add((String) mdcvo.getField("attribute"));
      }
    } catch (CommonPermissionException ex) {
      throw new NuclosFatalException(ex);
    } catch (CommonFinderException ex) {
      throw new NuclosFatalException(ex);
    }
  }