-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #472 from eclipse-passage/567032
567032 issue floating license configuration wizard
- Loading branch information
Showing
33 changed files
with
962 additions
and
372 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
bundles/org.eclipse.passage.loc.api/src/org/eclipse/passage/loc/internal/api/ZeroOrMany.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2019, 2020 ArSysOp | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License 2.0 which is available at | ||
* https://www.eclipse.org/legal/epl-2.0/. | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* ArSysOp - initial API and implementation | ||
*******************************************************************************/ | ||
package org.eclipse.passage.loc.internal.api; | ||
|
||
import java.util.Collection; | ||
import java.util.Collections; | ||
import java.util.Optional; | ||
import java.util.function.Function; | ||
import java.util.function.Supplier; | ||
|
||
/** | ||
* | ||
* Experimental API to select existing or create new instance of given type. | ||
* | ||
*/ | ||
public final class ZeroOrMany<C> { | ||
|
||
private final Supplier<Collection<C>> supplier; | ||
|
||
public ZeroOrMany(Supplier<Collection<C>> input) { | ||
this.supplier = input; | ||
} | ||
|
||
/** | ||
* | ||
* @param create the supplier of new instances. If no {@code input} elements are | ||
* supplies then a singleton collection of a newly created one is | ||
* returned. The supplier can potentially return nothing - then | ||
* the output collection is to be empty. | ||
* @param select the filtering selector callback which takes existing instances | ||
* ({@code input}) and does a filtering of any complexity, | ||
* possibly invoking UI. | ||
* @return collection of {@code select}-ed instances, a singleton | ||
* {@code new instance} collection or an empty collection. | ||
*/ | ||
public Collection<C> choose(Supplier<Optional<C>> create, Function<Collection<C>, Collection<C>> select) { | ||
Collection<C> input = supplier.get(); | ||
if (input.isEmpty()) { | ||
return create.get()// | ||
.map(Collections::singleton)// | ||
.orElse(Collections.emptySet()); | ||
} | ||
return select.apply(input); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
105 changes: 105 additions & 0 deletions
105
...hboard.ui/src/org/eclipse/passage/loc/dashboard/ui/wizards/CollectedLicensingRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2020 ArSysOp | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License 2.0 which is available at | ||
* https://www.eclipse.org/legal/epl-2.0/. | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* ArSysOp - initial API and implementation | ||
*******************************************************************************/ | ||
package org.eclipse.passage.loc.dashboard.ui.wizards; | ||
|
||
import java.time.LocalDate; | ||
import java.time.ZoneId; | ||
import java.util.Date; | ||
import java.util.List; | ||
import java.util.Optional; | ||
import java.util.UUID; | ||
import java.util.function.Supplier; | ||
|
||
import org.eclipse.passage.lic.licenses.LicensePlanDescriptor; | ||
import org.eclipse.passage.lic.products.ProductVersionDescriptor; | ||
import org.eclipse.passage.lic.users.UserDescriptor; | ||
import org.eclipse.passage.loc.internal.api.LicensingRequest; | ||
|
||
final class CollectedLicensingRequest implements LicensingRequest { | ||
|
||
private final ZoneId zone = ZoneId.systemDefault(); | ||
private final String uuid = UUID.randomUUID().toString(); | ||
private final Date stamp = new Date(); | ||
|
||
private final Supplier<Optional<LicensePlanDescriptor>> plan; | ||
private final Supplier<Optional<UserDescriptor>> user; | ||
private final Supplier<Optional<ProductVersionDescriptor>> product; | ||
private final Supplier<Optional<List<LocalDate>>> period; | ||
|
||
CollectedLicensingRequest(// | ||
Supplier<Optional<LicensePlanDescriptor>> plan, // | ||
Supplier<Optional<UserDescriptor>> user, // | ||
Supplier<Optional<ProductVersionDescriptor>> product, // | ||
Supplier<Optional<List<LocalDate>>> period) { | ||
this.plan = plan; | ||
this.user = user; | ||
this.product = product; | ||
this.period = period; | ||
} | ||
|
||
@Override | ||
public Date getValidUntil() { | ||
return Date.from(period.get().get().get(1).atStartOfDay(zone).toInstant()); | ||
} | ||
|
||
@Override | ||
public Date getValidFrom() { | ||
return Date.from(period.get().get().get(0).atStartOfDay(zone).toInstant()); | ||
} | ||
|
||
@Override | ||
public String getUserIdentifier() { | ||
return user.get().get().getEmail(); | ||
} | ||
|
||
@Override | ||
public String getUserFullName() { | ||
return user.get().get().getFullName(); | ||
} | ||
|
||
@Override | ||
public String getProductVersion() { | ||
return product.get().get().getVersion(); | ||
} | ||
|
||
@Override | ||
public String getProductIdentifier() { | ||
return product.get().get().getProduct().getIdentifier(); | ||
} | ||
|
||
@Override | ||
public String getPlanIdentifier() { | ||
return plan.get().get().getIdentifier(); | ||
} | ||
|
||
@Override | ||
public String getIdentifier() { | ||
return uuid; | ||
} | ||
|
||
@Override | ||
public Date getCreationDate() { | ||
return stamp; | ||
} | ||
|
||
@Override | ||
public String getConditionType() { | ||
return user.get().get().getPreferredConditionType(); | ||
} | ||
|
||
@Override | ||
public String getConditionExpression() { | ||
return user.get().get().getPreferredConditionExpression(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.