Commit 7cb53d84 authored by Romain Bioteau's avatar Romain Bioteau Committed by Adrien
Browse files

fix(labels) date type labels and description (#438)

Closes BS-16541
parent 7f662909
......@@ -161,7 +161,7 @@ modelValidationFailedMsg=Business data model validation has failed with followin
textDetails=Use TEXT if the possible string length may exceed the STRING max length in your database (e.g. for text areas).\nBeware this will prevent unique constraint or indexes.\nDatabase equivalent: Clob.
lengthIsNotAPositiveNumber=Length must be a positive integer
lengthIsNotANumber=Length must be an integer
dateDetails=DATE format stays in the list to support previous development, but for new developments, use the types DATE ONLY, DATE AND TIME (NO TZ), or DATE AND TIME (TZ) to handle date and time depending on your use-case.\nDATE is stored in the database using a LONG (number of milliseconds ellapsed since 01/01/1970 00:00:00 (UTC)). It uses java.util.Date as Java type.
dateDetails=DATE stores a date and a time in the database using a LONG (number of milliseconds ellapsed sine 01/01/1970 00:00:00: (UTC)) and uses java.util.Date as Java type.\nComplex operations in UI Designer, Groovy scripts, and REST API created some unconsistencies with the type DATE. \nTherefore, DATE stays in the list to support previous developments, but for new developments, use the types DATE ONLY, DATE-TIME (NO TIME ZONE), or DATE-TIME (TIME ZONE) to handle date or date/time depending on your use-case.
dateOnlyDetails=%s is used to hold a date with no time of the day. Use it for birth dates for example.\nIt is stored in the database as a String, using ISO-8601 "yyyy-mm-dd". It uses a java.time.LocalDate as Java type.
dateTimeDetails=%s is used to hold a date-time that displays the same whatever the user's time zone (NO Time Zone). Use it for stores opening hours for example.\nIt is stored in the database as a String using ISO 8601 "yyyyy-mm-ddThh:mm:ss:sss". It uses java.time.LocalDateTime as Java type.
dateTimeInTimezoneDetails=%s is used to hold a date-time that will take the user's computer time zone (TZ) into account when displayed. Use it for meetings date and time for example.\nIt is stored in the database as a String using ISO 8601 "yyyy-mm-ddThh:mm:ss.sssZ". It uses java.time.OffsetDateTime as Java type.
\ No newline at end of file
......@@ -17,8 +17,8 @@ package org.bonitasoft.studio.businessobject.ui;
public interface DateTypeLabels {
public static final String DATE_ONLY = "DATE ONLY";
public static final String DATE_AND_TIME = "DATE-TIME (NO TZ)";
public static final String DATE_TIME_WITH_TIMEZONE = "DATE-TIME (TZ)";
public static final String DATE_AND_TIME = "DATE-TIME (NO TIME ZONE)";
public static final String DATE_TIME_WITH_TIMEZONE = "DATE-TIME (TIME ZONE)";
public static final String DATE_DEPRECATED = "DATE (NOT RECOMMENDED)";
}
......@@ -15,11 +15,14 @@
package org.bonitasoft.studio.common.emf.tools;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import org.bonitasoft.studio.common.Activator;
import org.bonitasoft.studio.common.log.BonitaStudioLog;
import org.bonitasoft.studio.model.process.Connection;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EReference;
import org.eclipse.emf.ecore.EStructuralFeature;
......@@ -39,6 +42,20 @@ public class RemoveDanglingReferences {
public void execute() {
removeDanglingReferences(root);
removeSequenceFlowWithoutSourceAndTarget(root);
}
public void removeSequenceFlowWithoutSourceAndTarget(EObject element) {
if (element.eResource() != null && element.eResource().getResourceSet() != null) {
final List<EObject> toRemove = new ArrayList<>();
element.eAllContents().forEachRemaining(eObject -> {
if (eObject instanceof Connection &&
(((Connection) eObject).getTarget() == null || ((Connection) eObject).getSource() == null)) {
toRemove.add(eObject);
}
});
toRemove.forEach(EcoreUtil::remove);
}
}
/**
......@@ -70,8 +87,8 @@ public class RemoveDanglingReferences {
* the referencer
*/
private void removeDanglingReferences(CrossReferencer referencer) {
for (Map.Entry<EObject, Collection<Setting>> entry : referencer.entrySet()) {
for (EStructuralFeature.Setting value : entry.getValue()) {
for (final Map.Entry<EObject, Collection<Setting>> entry : referencer.entrySet()) {
for (final EStructuralFeature.Setting value : entry.getValue()) {
try {
EcoreUtil.remove(value, entry.getKey());
BonitaStudioLog.warning(
......
......@@ -109,7 +109,7 @@ public class CustomContractInputItemProviderTest {
.getLabelProvider(contractInput)
.getText(contractInput.getType());
assertThat(label).isEqualTo(String.format("DATE-TIME (NO TZ) - %s", LocalDateTime.class.getName()));
assertThat(label).isEqualTo(String.format("DATE-TIME (NO TIME ZONE) - %s", LocalDateTime.class.getName()));
}
@Test
......@@ -122,7 +122,7 @@ public class CustomContractInputItemProviderTest {
.getLabelProvider(contractInput)
.getText(contractInput.getType());
assertThat(label).isEqualTo(String.format("DATE-TIME (TZ) - %s", OffsetDateTime.class.getName()));
assertThat(label).isEqualTo(String.format("DATE-TIME (TIME ZONE) - %s", OffsetDateTime.class.getName()));
}
@Test
......
......@@ -86,9 +86,9 @@ public class CustomContractInputItemProvider
case LOCALDATE:
return "DATE ONLY";
case LOCALDATETIME:
return "DATE-TIME (NO TZ)";
return "DATE-TIME (NO TIME ZONE)";
case OFFSETDATETIME:
return "DATE-TIME (TZ)";
return "DATE-TIME (TIME ZONE)";
default:
return super.getText(type);
}
......
/**
* Copyright (C) 2010-2013 BonitaSoft S.A.
* BonitaSoft, 32 rue Gustave Eiffel - 38000 Grenoble
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2.0 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.bonitasoft.studio.validation.constraints.process;
......@@ -33,58 +30,56 @@ import org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditor;
import org.eclipse.gmf.runtime.notation.NotationPackage;
/**
*
* @author Baptiste Mesta
* @author Aurelien Pupier - constraint for assigned actors with Lane
*
*/
public class AssignableConstraint extends AbstractLiveValidationMarkerConstraint {
public static final String ID = "org.bonitasoft.studio.validation.constraints.assignable";
@Override
@Override
protected IStatus performLiveValidation(IValidationContext ctx) {
final EStructuralFeature featureTriggered = ctx.getFeature();
if(featureTriggered.equals(ProcessPackage.Literals.ASSIGNABLE__ACTOR)){
if (featureTriggered.equals(ProcessPackage.Literals.ASSIGNABLE__ACTOR)) {
final Assignable assignable = (Assignable) ctx.getTarget();
if(!hasActorsDefined(assignable)){
if (!hasActorsDefined(assignable)) {
return ctx.createFailureStatus(new Object[] { ((Element) assignable).getName() });
}
}else if(featureTriggered.equals(NotationPackage.Literals.VIEW__ELEMENT)){
EObject eobject = (EObject) ctx.getFeatureNewValue();
if(eobject instanceof Assignable){
if(!hasActorsDefined((Assignable) eobject)){
return ctx.createFailureStatus(new Object[] { ((Element) eobject).getName() });
} else if (featureTriggered.equals(NotationPackage.Literals.VIEW__ELEMENT)) {
final EObject eobject = (EObject) ctx.getFeatureNewValue();
if (eobject instanceof Assignable) {
if (!hasActorsDefined((Assignable) eobject)) {
return ctx.createFailureStatus(new Object[] { ((Element) eobject).getName() });
}
}
}else if(featureTriggered.equals(ProcessPackage.Literals.TASK__OVERRIDE_ACTORS_OF_THE_LANE)){
} else if (featureTriggered.equals(ProcessPackage.Literals.TASK__OVERRIDE_ACTORS_OF_THE_LANE)) {
final Task task = (Task) ctx.getTarget();
final Boolean overrideGroupsOfLane = (Boolean) ctx.getFeatureNewValue();
if(overrideGroupsOfLane){
if(!hasActorsDefined(task)){
if (overrideGroupsOfLane) {
if (!hasActorsDefined(task)) {
return ctx.createFailureStatus(new Object[] { task.getName() });
}
}
}
return ctx.createSuccessStatus();
}
private boolean hasActorsDefined(Assignable assignable){
if(assignable instanceof Task){
if(((Task) assignable).isOverrideActorsOfTheLane()){
return assignable.getActor() != null;
} else {
final Lane parentLane = getParentLane(assignable);
if(parentLane != null){
return hasActorsDefined(parentLane);
} else {
return false;
}
}
} else {
return assignable.getActor() != null;
}
private boolean hasActorsDefined(Assignable assignable) {
if (assignable instanceof Task) {
if (((Task) assignable).isOverrideActorsOfTheLane()) {
return assignable.getActor() != null;
} else {
final Lane parentLane = getParentLane(assignable);
if (parentLane != null) {
return hasActorsDefined(parentLane);
} else {
return false;
}
}
} else {
return assignable.getActor() != null;
}
}
@Override
......@@ -99,49 +94,49 @@ public class AssignableConstraint extends AbstractLiveValidationMarkerConstraint
@Override
protected IStatus performBatchValidation(IValidationContext ctx) {
EObject eObj = ctx.getTarget();
final EObject eObj = ctx.getTarget();
if (eObj instanceof Assignable) {
Assignable assignable = (Assignable) eObj;
if(!hasActorsDefined(assignable)){
if(assignable instanceof Lane){
if(hasTaskUsingLaneActor((Lane)assignable)){
return ctx.createFailureStatus(new Object[] { ((Element) assignable).getName() });
}
} else {
return ctx.createFailureStatus(new Object[] { ((Element) assignable).getName() });
}
final Assignable assignable = (Assignable) eObj;
if (!hasActorsDefined(assignable)) {
if (assignable instanceof Lane) {
if (hasTaskUsingLaneActor((Lane) assignable)) {
return ctx.createFailureStatus(new Object[] { ((Element) assignable).getName() });
}
} else {
return ctx.createFailureStatus(new Object[] { ((Element) assignable).getName() });
}
}
}
return ctx.createSuccessStatus();
}
private boolean hasTaskUsingLaneActor(Lane lane) {
for(Element element : lane.getElements()){
if(element instanceof Task){
if(!((Task) element).isOverrideActorsOfTheLane()){
return true;
}
} else if(element instanceof SubProcessEvent){
for (Element elementInSubProc : ((SubProcessEvent) element).getElements()) {
if(!((Task) elementInSubProc).isOverrideActorsOfTheLane()){
return true;
}
}
}
}
return false;
for (final Element element : lane.getElements()) {
if (element instanceof Task) {
if (!((Task) element).isOverrideActorsOfTheLane()) {
return true;
}
} else if (element instanceof SubProcessEvent) {
for (final Element elementInSubProc : ((SubProcessEvent) element).getElements()) {
if (elementInSubProc instanceof Task && !((Task) elementInSubProc).isOverrideActorsOfTheLane()) {
return true;
}
}
}
}
return false;
}
private Lane getParentLane(EObject eObject){
Lane res = null;
EObject current = eObject;
while(current != null && res == null){
if(current instanceof Lane){
res = (Lane) current;
} else {
current = current.eContainer();
}
}
return res;
}
private Lane getParentLane(EObject eObject) {
Lane res = null;
EObject current = eObject;
while (current != null && res == null) {
if (current instanceof Lane) {
res = (Lane) current;
} else {
current = current.eContainer();
}
}
return res;
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment