Java tutorial
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package net.firejack.platform.service.registry.broker.system; import net.firejack.platform.api.registry.domain.System; import net.firejack.platform.core.broker.ReadAllBroker; import net.firejack.platform.core.domain.NamedValues; import net.firejack.platform.core.exception.BusinessFunctionException; import net.firejack.platform.core.model.registry.domain.SystemModel; import net.firejack.platform.core.request.ServiceRequest; import net.firejack.platform.core.store.lookup.ILookupStore; import net.firejack.platform.core.store.registry.ISystemStore; import net.firejack.platform.web.statistics.annotation.TrackDetails; import org.hibernate.criterion.Criterion; import org.hibernate.criterion.Restrictions; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import java.util.ArrayList; import java.util.List; @TrackDetails @Component("readSystemListBroker") public class ReadSystemListBroker extends ReadAllBroker<SystemModel, System> { @Autowired private ISystemStore store; @Override protected ILookupStore<SystemModel, Long> getStore() { return store; } protected List<SystemModel> getModelList(ServiceRequest<NamedValues> request) throws BusinessFunctionException { Boolean aliases = (Boolean) request.getData().get("aliases"); if (aliases != null) { List<Criterion> criterions = new ArrayList<Criterion>(); if (aliases) { criterions.add(Restrictions.isNotNull("main")); } else { criterions.add(Restrictions.isNull("main")); } return getStore().findAllWithFilter(criterions, getFilter()); } else { return getStore().findAllWithFilter(getFilter()); } } }