Ejemplo n.º 1
0
  public static void createPackageJar(List<Member> members, PackageVersion version) {

    // These members should be collect before insert memberships, Right now
    // we don't need UploadedPackageMember
    InvocationContext context = InvocationContext.get();
    List<Instance> packageMembers = context.getDbChanges().getAdded();

    List<UploadedPackageMember> uploadMemberships =
        members
            .stream()
            // Prepare UploadedPackageMember from package's component
            .map(m -> createUploadedMembership(m.getClonedComponent(), m.getMembership(), version))
            // Collect to list
            .collect(Collectors.toList());

    List<UploadedPackageMember> createUploadPackageMembers =
        createUploadPackageMembers(UploadingPackage.getMembers(), version);

    uploadMemberships.addAll(createUploadPackageMembers);

    // Save Uploaded Package Membership
    context.getDatabase().upsert(uploadMemberships, DMLOperationType.THROW_ERRORS);

    List<Instance> allInstances =
        uploadMemberships.stream().map(m -> m.getComponent()).collect(Collectors.toList());
    prepareJAR(version, allInstances);

    prepatePackageData(version, packageMembers);
  }
Ejemplo n.º 2
0
  public static void updatePackageJar(PackageVersion version) {
    InvocationContext context = InvocationContext.get();
    DataStore store = context.getDataStore();
    int actualId = UploadingPackage.getActualId();

    // Getting all members of this package except UploadedPackageMember
    List<Instance> instances = store.getAllPackageMembers(actualId);

    // Load all UploadedPackageMembers
    Set<Long> existedMembers = store.getUploadedComponentIds(actualId, context.getOrganizationId());

    // Newly added members
    List<Instance> notExisted =
        instances
            .stream()
            .filter(i -> !existedMembers.contains(i.getId()))
            .collect(Collectors.toList());

    List<UploadedPackageMember> newMembers = createUploadPackageMembers(notExisted, version);

    context.getDatabase().upsert(newMembers, DMLOperationType.THROW_ERRORS);

    prepareJAR(version, instances);

    prepatePackageData(version, instances);

    store.updateInstalledPackageLastUpdate(version.getId());
  }
Ejemplo n.º 3
0
  public static void createCorePackageJar(List<Instance> coreMembers, PackageVersion version)
      throws Exception {

    List<Instance> members = new ArrayList<>(coreMembers);
    members.addAll(UploadingPackage.getMembers());

    List<UploadedPackageMember> objs = createUploadPackageMembers(members, version);

    Database database = InvocationContext.get().getDatabase();

    database.insert(objs, DMLOperationType.THROW_ERRORS);

    prepareJAR(version, members);

    prepatePackageData(version, members);
  }