Skip to content

Commit

Permalink
Merge pull request #784 from eclipse-passage/572560-8
Browse files Browse the repository at this point in the history
Bug 572650 - [Passage] upgrade `licenses` domain model
  • Loading branch information
eparovyshnaya authored May 23, 2021
2 parents 4ec6a1b + fb33f49 commit 5dabdbb
Show file tree
Hide file tree
Showing 70 changed files with 1,060 additions and 1,043 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ private boolean matches(GrantAcqisition actual, GrantAcqisition expected) {
private GrantAcqisition acquistion(FeatureGrant grant, String user) {
GrantAcqisition acquisition = LicensesFactory.eINSTANCE.createGrantAcqisition();
acquisition.setCreated(new Date());
acquisition.setFeature(grant.getFeature());
acquisition.setFeature(grant.getFeature().getIdentifier());
acquisition.setGrant(grant.getIdentifier());
acquisition.setIdentifier(UUID.randomUUID().toString());
acquisition.setUser(user);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ private Collection<FeatureGrant> get(FlsGear gear) {
*/
private Optional<FeatureGrant> grantForFeature(FloatingLicensePack license) {
return license.getFeatures().stream()//
.filter(grant -> feature.equals(grant.getFeature()))//
.filter(grant -> feature.equals(grant.getFeature().getIdentifier()))//
.findAny();//
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@
import org.eclipse.passage.lic.internal.base.conditions.BaseCondition;
import org.eclipse.passage.lic.internal.base.conditions.BaseEvaluationInstructions;
import org.eclipse.passage.lic.internal.base.conditions.BaseValidityPeriodClosed;
import org.eclipse.passage.lic.internal.base.conditions.BaseVersionMatch;
import org.eclipse.passage.lic.internal.base.conditions.MatchingRuleForIdentifier;
import org.eclipse.passage.lic.internal.licenses.convert.PVersionMatch;
import org.eclipse.passage.lic.licenses.model.api.FeatureGrant;
import org.eclipse.passage.lic.licenses.model.api.FloatingLicensePack;
import org.eclipse.passage.lic.licenses.model.api.UserGrant;
import org.eclipse.passage.lic.licenses.model.api.ValidityPeriodClosed;

@SuppressWarnings("restriction")
final class AssembledConditions {

private final FloatingLicensePack license;
Expand Down Expand Up @@ -66,7 +66,7 @@ private Collection<Condition> forFeatures(UserGrant user) throws LicensingExcept
private Condition condition(UserGrant user, FeatureGrant feature) throws LicensingException {
return new BaseCondition(//
feature.getIdentifier(), //
feature.getFeature(), //
feature.getFeature().getIdentifier(), //
version(feature), //
period(feature), //
evaluation(user));
Expand Down Expand Up @@ -101,9 +101,7 @@ private ZonedDateTime min(ZonedDateTime first, ZonedDateTime second) {
}

private VersionMatch version(FeatureGrant feature) {
return new BaseVersionMatch(//
feature.getVersion().getVersion(), //
new MatchingRuleForIdentifier(feature.getVersion().getRule()).get());
return new PVersionMatch(feature.getFeature().getVersionMatch()).get();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ private LicenseGrant grant(Condition condition) {
LicenseGrant grant = licenseFactory.createLicenseGrant();
grant.setIdentifier(condition.identifier());
grant.getFeature().setIdentifier(condition.feature());
grant.getFeature().setVersion(condition.versionMatch().version());
grant.getFeature().setMatchingRule(condition.versionMatch().rule().identifier());
grant.getFeature().getVersionMatch().setVersion(condition.versionMatch().version());
grant.getFeature().getVersionMatch().setRule(condition.versionMatch().rule().identifier());
grant.setCapacity(1);
grant.getUserAuthentication().setExpression(condition.evaluationInstructions().expression());
grant.getUserAuthentication().setType(condition.evaluationInstructions().type().identifier());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,18 @@
*******************************************************************************/
package org.eclipse.passage.lic.emf.migration;

import java.util.Optional;
import java.util.List;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.emf.ecore.EAttribute;
import org.eclipse.emf.ecore.EReference;

/**
* @since 2.0
*/
public interface EFeatureRoutes {
public interface EAttributeRoute {

void define(String found, EStructuralFeature destination);
EAttribute destination();

Optional<EStructuralFeature> route(String found, EClass scope);
List<EReference> path();

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*******************************************************************************
* Copyright (c) 2021 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.lic.emf.migration;

import java.util.List;

import org.eclipse.emf.ecore.EReference;

/**
* @since 2.0
*/
public interface EReferenceRoute {

EReference destination();

List<EReference> path();

}
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,13 @@
*******************************************************************************/
package org.eclipse.passage.lic.emf.migration;

import java.util.List;
import java.util.function.Function;

import org.eclipse.emf.ecore.EObject;

/**
* Helps to ensure that inner data structures exists for the given EObject
*
* @since 2.0
*/
public interface EnsureStructure extends Function<EObject, List<EObject>> {
public interface MigrateFeatures {

void apply(EObject root) throws MigrationException;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*******************************************************************************
* Copyright (c) 2021 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.lic.emf.migration;

import org.eclipse.emf.ecore.util.FeatureMap.Entry;

/**
* Indicates failure to recognize and migrate the data entry
*
* @since 2.0
*/
public class MigrationException extends Exception {

private static final long serialVersionUID = 1L;

public MigrationException(Entry entry) {
super(entry.toString());
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*******************************************************************************
* Copyright (c) 2021 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.lic.emf.migration;

import java.util.Optional;

import org.eclipse.emf.ecore.EClass;

/**
* @since 2.0
*/
public interface MigrationRoutes {

void define(String found, EAttributeRoute path);

void define(String found, EReferenceRoute path);

void ignore(String found, EClass location);

Optional<EAttributeRoute> attribute(String found, EClass scope);

Optional<EReferenceRoute> reference(String found, EClass scope);

boolean ignored(String found, EClass location);

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/*******************************************************************************
* Copyright (c) 2021 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.lic.emf.migration;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Objects;

import org.eclipse.emf.ecore.EAttribute;
import org.eclipse.emf.ecore.EReference;

/**
*
* @since 2.0
*
*/
public final class SimpleAttributeRoute implements EAttributeRoute {

private final EAttribute destination;
private final List<EReference> path;

public SimpleAttributeRoute(EAttribute destination) {
this(destination, Collections.emptyList());
}

public SimpleAttributeRoute(EAttribute destination, EReference... path) {
this(destination, Arrays.asList(path));
}

public SimpleAttributeRoute(EAttribute destination, List<EReference> path) {
Objects.requireNonNull(destination, "SimpleAttributePath::destination"); //$NON-NLS-1$
Objects.requireNonNull(path, "SimpleAttributePath::path"); //$NON-NLS-1$
this.destination = destination;
this.path = new ArrayList<>(path);
}

@Override
public EAttribute destination() {
return destination;
}

@Override
public List<EReference> path() {
return new ArrayList<>(path);
}

}

This file was deleted.

Loading

0 comments on commit 5dabdbb

Please sign in to comment.