Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
This file is part of Everit - Resource. Everit - Resource is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Everit - Resource 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 GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with Everit - Resource. If not, see <http://www.gnu.org/licenses/>.
package org.everit.osgi.resource.internal;
Implementation for ResourceService.
@Component(name = ., metatype = true, configurationFactory = true,
        policy = .)
public class ResourceComponent implements ResourceService {
    @Reference(bind = "bindQuerydslSupport")
    public void bindQuerydslSupport(QuerydslSupport querydslSupport) {
        this. = querydslSupport;
    }
    @Override
    public long createResource() {
        return .execute(new QuerydslCallable<Long>() {
            @Override
            public Long call(Connection connectionConfiguration configurationthrows SQLException {
                QResource qResource = new QResource("qResource");
                SQLInsertClause insertClause = new SQLInsertClause(connectionconfigurationqResource);
                return insertClause.executeWithKey(qResource.resourceId);
            }
        });
    }
    @Override
    public boolean deleteResource(final long resourceId) {
        return .execute(new QuerydslCallable<Boolean>() {
            @Override
            public Boolean call(Connection connectionConfiguration configurationthrows SQLException {
                QResource qResource = new QResource("qResource");
                SQLDeleteClause deleteClause = new SQLDeleteClause(connectionconfigurationqResource);
                long deletedRecordNum = deleteClause.where(qResource.resourceId.eq(resourceId)).execute();
                return deletedRecordNum > 0;
            }
        });
    }
New to GrepCode? Check out our FAQ X