Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,16 @@

</dependencies>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.22</version>
</dependency>
</dependencies>
</dependencyManagement>

<build>

<plugins>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#
# Auxiliary data for ReservationRequestAbstract
#
# @author Filip Karnis <karnis@cesnet.cz>
#
package Shongo::ClientCli::API::AuxiliaryData;
use base qw(Shongo::ClientCli::API::Object);

use strict;
use warnings;

use Shongo::Common;
use Shongo::Console;

#
# Create a new instance of auxiliary data
#
# @static
#
sub new()
{
my $class = shift;
my (%attributes) = @_;
my $self = Shongo::ClientCli::API::Object->new(@_);
bless $self, $class;

$self->set_object_class('AuxData');
$self->set_object_name('Auxiliary Data');
$self->add_attribute('tagName', {
'required' => 1,
'type' => 'string',
});
$self->add_attribute('enabled', {
'required' => 1,
'type' => 'bool',
});
$self->add_attribute('data', {
'required' => 0,
'type' => 'string',
});

return $self;
}

1;
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ use Shongo::Common;
use Shongo::Console;
use Shongo::ClientCli::API::ReservationRequest;
use Shongo::ClientCli::API::ReservationRequestSet;
use Shongo::ClientCli::API::AuxiliaryData;

# Enumeration of reservation request purpose
our $Purpose = ordered_hash(
Expand Down Expand Up @@ -89,6 +90,15 @@ sub new()
'OWNED' => 'Owned'
)
});
$self->add_attribute('auxData', {
'type' => 'collection',
'item' => {
'title' => 'Auxiliary Data',
'class' => 'Shongo::ClientCli::API::AuxiliaryData',
'short' => 1,
},
'optional' => 1,
});

return $self;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,8 @@ sub list_reservation_requests()
{'field' => 'technology', 'title' => 'Technology'},
{'field' => 'allocationState', 'title' => 'Allocation'},
{'field' => 'executableState', 'title' => 'Executable'},
{'field' => 'description', 'title' => 'Description'}
{'field' => 'description', 'title' => 'Description'},
{'field' => 'auxData', 'title' => 'Auxiliary Data'},
],
'data' => []
};
Expand Down Expand Up @@ -321,7 +322,8 @@ sub list_reservation_requests()
'technology' => $technologies,
'allocationState' => Shongo::ClientCli::API::ReservationRequest::format_state($reservation_request->{'allocationState'}),
'executableState' => Shongo::ClientCli::API::ReservationRequest::format_state($reservation_request->{'executableState'}),
'description' => $reservation_request->{'description'}
'description' => $reservation_request->{'description'},
'auxData' => $reservation_request->{'auxData'},
});
}
console_print_table($table);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,15 @@ use Shongo::ClientCli::API::Resource;
use Shongo::ClientCli::API::DeviceResource;
use Shongo::ClientCli::API::Alias;

#
# Tag types
#
our $TagType = ordered_hash(
'DEFAULT' => 'Default',
'NOTIFY_EMAIL' => 'Notify Email',
'RESERVATION_DATA' => 'Reservation Data',
);

#
# Populate shell by options for management of resources.
#
Expand Down Expand Up @@ -477,6 +486,19 @@ sub create_tag()
'title' => 'Tag name',
}
);
$tag->add_attribute(
'type', {
'required' => 1,
'title' => 'Tag type',
'type' => 'enum',
'enum' => $Shongo::ClientCli::ResourceService::TagType,
}
);
$tag->add_attribute(
'data', {
'title' => 'Tag data',
}
);

my $id = $tag->create($attributes, $options);
if ( defined($id) ) {
Expand Down Expand Up @@ -514,13 +536,17 @@ sub list_tags()
'columns' => [
{'field' => 'id', 'title' => 'Identifier'},
{'field' => 'name', 'title' => 'Name'},
{'field' => 'type', 'title' => 'Type'},
{'field' => 'data', 'title' => 'Data'},
],
'data' => []
};
foreach my $resource (@{$response}) {
foreach my $tag (@{$response}) {
push(@{$table->{'data'}}, {
'id' => $resource->{'id'},
'name' => $resource->{'name'},
'id' => $tag->{'id'},
'name' => $tag->{'name'},
'type' => $tag->{'type'},
'data' => $tag->{'data'},
});
}
console_print_table($table);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
import cz.cesnet.shongo.client.web.ClientWebConfiguration;
import cz.cesnet.shongo.client.web.support.MessageProvider;
import cz.cesnet.shongo.controller.api.ReservationRequestSummary;
import cz.cesnet.shongo.controller.api.Tag;

import java.util.List;
import java.util.stream.Collectors;

/**
* Type of specification for a reservation request.
Expand Down Expand Up @@ -102,15 +106,17 @@ public static SpecificationType fromReservationRequestSummary(ReservationRequest
case USED_ROOM:
return PERMANENT_ROOM_CAPACITY;
case RESOURCE:
String resourceTags = reservationRequestSummary.getResourceTags();
List<String> resourceTags = reservationRequestSummary.getResourceTags()
.stream()
.map(Tag::getName)
.collect(Collectors.toList());
String parkTagName = ClientWebConfiguration.getInstance().getParkingPlaceTagName();
String vehicleTagName = ClientWebConfiguration.getInstance().getVehicleTagName();
if (resourceTags != null) {
if (parkTagName != null && resourceTags.contains(parkTagName)) {
return PARKING_PLACE;
} else if (vehicleTagName != null && resourceTags.contains(vehicleTagName)) {
return VEHICLE;
}
if (parkTagName != null && resourceTags.contains(parkTagName)) {
return PARKING_PLACE;
}
else if (vehicleTagName != null && resourceTags.contains(vehicleTagName)) {
return VEHICLE;
}
return MEETING_ROOM;
default:
Expand Down
7 changes: 7 additions & 0 deletions shongo-common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,13 @@
</exclusion>
</exclusions>
</dependency>
<!-- Hibernate types. Depends on hibernate version. -->
<!-- https://github.com/vladmihalcea/hypersistence-utils -->
<dependency>
<groupId>io.hypersistence</groupId>
<artifactId>hypersistence-utils-hibernate-52</artifactId>
<version>3.2.0</version>
</dependency>

<!-- Used by Jade for serializing objects -->
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@
@TypeDef(name = PersistentLocalDate.NAME, typeClass = PersistentLocalDate.class),
@TypeDef(name = PersistentPeriod.NAME, typeClass = PersistentPeriod.class),
@TypeDef(name = PersistentInterval.NAME, typeClass = PersistentInterval.class),
@TypeDef(name = PersistentReadablePartial.NAME, typeClass = PersistentReadablePartial.class)
@TypeDef(name = PersistentReadablePartial.NAME, typeClass = PersistentReadablePartial.class),
@TypeDef(name = "jsonb", typeClass = JsonBinaryType.class),
}) package cz.cesnet.shongo.hibernate;

import io.hypersistence.utils.hibernate.type.json.JsonBinaryType;
import org.hibernate.annotations.TypeDef;
import org.hibernate.annotations.TypeDefs;

5 changes: 5 additions & 0 deletions shongo-controller-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@
<artifactId>jackson-core</artifactId>
<version>2.10.1</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>

</project>
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
import cz.cesnet.shongo.controller.api.rpc.ReservationService;
import org.joda.time.DateTime;

import java.util.ArrayList;
import java.util.List;

/**
* Request for reservation of resources.
*
Expand Down Expand Up @@ -75,6 +78,11 @@ public abstract class AbstractReservationRequest extends IdentifiedComplexType
*/
private boolean isSchedulerDeleted = false;

/**
* Auxiliary data. This data are specified by the {@link Tag}s of {@link Resource} which is requested for reservation.
*/
private List<AuxiliaryData> auxData = new ArrayList<>();

/**
* Constructor.
*/
Expand Down Expand Up @@ -291,6 +299,22 @@ public void setIsSchedulerDeleted(boolean isSchedulerDeleted)
this.isSchedulerDeleted = isSchedulerDeleted;
}

/**
* @return {@link #auxData}
*/
public List<AuxiliaryData> getAuxData()
{
return auxData;
}

/**
* @param auxData sets the {@link #auxData}
*/
public void setAuxData(List<AuxiliaryData> auxData)
{
this.auxData = auxData;
}

private static final String TYPE = "type";
private static final String DATETIME = "dateTime";
private static final String USER_ID = "userId";
Expand All @@ -303,6 +327,7 @@ public void setIsSchedulerDeleted(boolean isSchedulerDeleted)
private static final String REUSED_RESERVATION_REQUEST_MANDATORY = "reusedReservationRequestMandatory";
private static final String REUSEMENT = "reusement";
private static final String IS_SCHEDULER_DELETED = "isSchedulerDeleted";
public static final String AUX_DATA = "auxData";

@Override
public DataMap toData()
Expand All @@ -320,6 +345,7 @@ public DataMap toData()
dataMap.set(REUSED_RESERVATION_REQUEST_MANDATORY, reusedReservationRequestMandatory);
dataMap.set(REUSEMENT, reusement);
dataMap.set(IS_SCHEDULER_DELETED, isSchedulerDeleted);
dataMap.set(AUX_DATA, auxData);
return dataMap;
}

Expand All @@ -339,5 +365,6 @@ public void fromData(DataMap dataMap)
reusedReservationRequestMandatory = dataMap.getBool(REUSED_RESERVATION_REQUEST_MANDATORY);
reusement = dataMap.getEnum(REUSEMENT, ReservationRequestReusement.class);
isSchedulerDeleted = dataMap.getBool(IS_SCHEDULER_DELETED);
auxData = dataMap.getList(AUX_DATA, AuxiliaryData.class);
}
}
Loading