@Override
  protected List<DatabaseModel> getModelList(ServiceRequest<SimpleIdentifier<Long>> request)
      throws BusinessFunctionException {
    Long associatedPackageId = request.getData().getIdentifier();

    PackageModel packageRN = packageStore.findById(associatedPackageId);
    if (packageRN.getSystem() != null) {
      Long systemId = packageRN.getSystem().getId();
      return store.findAllByParentIdWithFilter(systemId, getFilter());
    }
    return null;
  }
  private void install(
      InputStream stream, PackageModel packageRN, Map<String, DatabaseAction> associatedDatabases) {
    progress.status("Installation process is running...", 1, LogLevel.INFO);
    try {
      progress.status("... package archive has been downloaded", 1, LogLevel.INFO);
      progress.status("... unzipping package archive", 2, LogLevel.INFO);

      final File packageXmlUploadedFile =
          File.createTempFile(SecurityHelper.generateRandomSequence(16), null);
      final File upgradeXmlUploadedFile =
          File.createTempFile(SecurityHelper.generateRandomSequence(16), null);
      final File codeWarUploadedFile =
          File.createTempFile(SecurityHelper.generateRandomSequence(16), null);

      ArchiveUtils.unzip(
          stream,
          new ArchiveUtils.ArchiveCallback() {
            @Override
            public void callback(String dir, String name, InputStream stream) {
              try {
                if (PackageFileType.PACKAGE_XML.getOfrFileName().equals(name)) {
                  FileOutputStream packageXmlUploadFileOutputStream =
                      new FileOutputStream(packageXmlUploadedFile);
                  IOUtils.copy(stream, packageXmlUploadFileOutputStream);
                  IOUtils.closeQuietly(packageXmlUploadFileOutputStream);
                  progress.status("... extracted package xml", 1, LogLevel.DEBUG);
                } else if (PackageFileType.PACKAGE_UPGRADE.getOfrFileName().equals(name)) {
                  FileOutputStream upgradeXmlUploadFileOutputStream =
                      new FileOutputStream(upgradeXmlUploadedFile);
                  IOUtils.copy(stream, upgradeXmlUploadFileOutputStream);
                  IOUtils.closeQuietly(upgradeXmlUploadFileOutputStream);
                  progress.status("... extracted upgrade xml", 1, LogLevel.DEBUG);
                } else if (PackageFileType.APP_WAR.getOfrFileName().equals(name)) {
                  FileOutputStream codeWarFileOutputStream =
                      new FileOutputStream(codeWarUploadedFile);
                  IOUtils.copy(stream, codeWarFileOutputStream);
                  IOUtils.closeQuietly(codeWarFileOutputStream);
                  progress.status("... extracted war", 1, LogLevel.DEBUG);
                }
              } catch (IOException e) {
                logger.error(e, e);
              }
            }
          });

      Map<String, DatabaseAction> installDatabaseActionMap = new HashMap<String, DatabaseAction>();
      Map<String, DatabaseAction> upgradeDatabaseActionMap = new HashMap<String, DatabaseAction>();
      for (Map.Entry<String, DatabaseAction> entry : associatedDatabases.entrySet()) {
        String lookup = entry.getKey();
        DatabaseAction databaseAction = entry.getValue();
        if (DatabaseActionType.CREATE.equals(databaseAction.getAction())) {
          installDatabaseActionMap.put(lookup, databaseAction);
        } else if (DatabaseActionType.UPGRADE.equals(databaseAction.getAction())) {
          upgradeDatabaseActionMap.put(lookup, databaseAction);
        }
      }

      if (!installDatabaseActionMap.isEmpty()
          && (!packageXmlUploadedFile.exists() || !codeWarUploadedFile.exists())) {
        progress.status("... not all necessary files has been extracted", 1, LogLevel.ERROR);
        throw new BusinessFunctionException("Package archive is broken.");
      }
      if (!upgradeDatabaseActionMap.isEmpty()
          && (!upgradeXmlUploadedFile.exists() || !codeWarUploadedFile.exists())) {
        progress.status("... not all necessary files has been extracted", 1, LogLevel.ERROR);
        throw new BusinessFunctionException("Package archive is broken.");
      }

      Map<String, DataSource> installDataSourceMap = new HashMap<String, DataSource>();
      for (Map.Entry<String, DatabaseAction> entry : installDatabaseActionMap.entrySet()) {
        String lookup = entry.getKey();
        DatabaseAction databaseAction = entry.getValue();
        Database database = databaseAction.getDatabase();
        DataSource dataSource = databaseManager.getDataSource(database);
        progress.status(
            "... creating the "
                + database.getRdbms().name()
                + " database: "
                + database.getUrlPath(),
            1,
            LogLevel.INFO);
        boolean hasCreated = databaseManager.createDatabase(database);
        if (hasCreated) {
          progress.status("... the database has been created", 2, LogLevel.INFO);
        } else {
          progress.status("... the database has not been created", 2, LogLevel.WARN);
        }
        installDataSourceMap.put(lookup, dataSource);
      }

      if (!installDataSourceMap.isEmpty()) {
        try {
          progress.status("... creating database tables", 2, LogLevel.INFO);
          packageInstallationService.install(packageXmlUploadedFile, installDataSourceMap, null);
          progress.status("... database tables have been created", 2, LogLevel.INFO);
        } catch (Exception e) {
          progress.status("Database creating: occurred error." + e.getMessage(), 2, LogLevel.ERROR);
          throw new BusinessFunctionException(e);
        }
      }

      for (Map.Entry<String, DatabaseAction> entry : upgradeDatabaseActionMap.entrySet()) {
        String domainLookup = entry.getKey();
        DatabaseAction databaseAction = entry.getValue();
        Database database = databaseAction.getDatabase();
        DataSource dataSource = databaseManager.getDataSource(database);
        try {
          progress.status(
              "... upgrading the "
                  + database.getRdbms().name()
                  + " database: "
                  + database.getUrlPath(),
              3,
              LogLevel.INFO);
          upgradeExecutor.upgrade(upgradeXmlUploadedFile, dataSource, domainLookup);
          progress.status("... database have been upgraded", 1, LogLevel.INFO);
        } catch (Exception e) {
          progress.status(
              "Database upgrade process: occurred error" + e.getMessage(), 1, LogLevel.ERROR);
          throw new BusinessFunctionException(e);
        }
        entityStore.resetReverseEngineerMark(entry.getKey());
        relationshipStore.resetReverseEngineerMark(entry.getKey());
      }

      if (!upgradeDatabaseActionMap.isEmpty()) {
        progress.status(
            "Change database version to: " + VersionUtils.convertToVersion(packageRN.getVersion()),
            2,
            LogLevel.INFO);
        packageStore.save(packageRN, null, packageRN.getVersion(), false);
      }
    } catch (IOException e) {
      logger.error(e.getMessage(), e);
      progress.status(
          "IOException: downloading package archive" + e.getMessage(), 1, LogLevel.ERROR);
      throw new BusinessFunctionException(e);
    }
  }