// Path: src/main/java/uk/co/caprica/bootlace/data/mongo/account/AccountRepository.java
// public interface AccountRepository extends MongoRepository<Account, String> {
// 
//     /**
//      * Find an account for a given username.
//      *
//      * @param username username to search for
//      * @return account; or <code>null</code> if no account found for the give username
//      */
//     Account findByUsername(String username);
// 
// }
// 
// Path: src/main/java/uk/co/caprica/bootlace/domain/account/Account.java
// @Document
// public class Account extends AbstractEntity {
// 
//     /**
//      * Username.
//      */
//     @NotNull
//     private String username;
// 
//     /**
//      * Encrypted password.
//      *
//      * Using {@link JsonIgnore} prevents the password being returned by a web-service.
//      */
//     @JsonIgnore
//     @NotNull
//     private String password;
// 
//     /**
//      * List of role authorisations.
//      */
//     private List<String> roles;
// 
//     public Account() {
//     }
// 
//     public String getUsername() {
//         return username;
//     }
// 
//     public void setUsername(String username) {
//         this.username = username;
//     }
// 
//     public String getPassword() {
//         return password;
//     }
// 
//     public void setPassword(String password) {
//         this.password = password;
//     }
// 
//     public List<String> getRoles() {
//         return roles;
//     }
// 
//     public void setRoles(List<String> roles) {
//         this.roles = roles;
//     }
// 
//     @Override
//     public String toString() {
//         return toStringHelper()
//             .add("username", username)
//             .add("roles", roles)
//             .toString();
//     }
// 
// }


import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.stereotype.Component;
import uk.co.caprica.bootlace.data.mongo.account.AccountRepository;
import uk.co.caprica.bootlace.domain.account.Account;
import java.util.ArrayList;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationListener;
import org.springframework.context.event.ContextRefreshedEvent;
import org.springframework.data.mongodb.core.MongoOperations;
import org.springframework.data.mongodb.core.index.TextIndexDefinition.TextIndexDefinitionBuilder;
/*
 * This file is part of Bootlace.
 *
 * Copyright (C) 2015
 * Caprica Software Limited (capricasoftware.co.uk)
 *
 * Licensed 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 uk.co.caprica.bootlace.startup;




/**
 * Component containing operations to execute on application startup.
 * <p>
 * This component initialises the configured database with seed data.
 * <p>
 * <em>This component only exists for purposes of this reference application and would not
 * ordinarily be used in a Production application.</em>
 */
@Component
public class ApplicationStartup implements ApplicationListener<ContextRefreshedEvent> {

    /**
     * Log.
     */
    private final Logger logger = LoggerFactory.getLogger(ApplicationStartup.class);

    /**
     * Lower-level interface to the database, used e.g. to create collections and indexes.
     */
    @Autowired
    private MongoOperations mongoOperations;

    /**
     * Repository for account entities.
     */
    @Autowired
// Path: src/main/java/uk/co/caprica/bootlace/data/mongo/account/AccountRepository.java
// public interface AccountRepository extends MongoRepository<Account, String> {
// 
//     /**
//      * Find an account for a given username.
//      *
//      * @param username username to search for
//      * @return account; or <code>null</code> if no account found for the give username
//      */
//     Account findByUsername(String username);
// 
// }
// 
// Path: src/main/java/uk/co/caprica/bootlace/domain/account/Account.java
// @Document
// public class Account extends AbstractEntity {
// 
//     /**
//      * Username.
//      */
//     @NotNull
//     private String username;
// 
//     /**
//      * Encrypted password.
//      *
//      * Using {@link JsonIgnore} prevents the password being returned by a web-service.
//      */
//     @JsonIgnore
//     @NotNull
//     private String password;
// 
//     /**
//      * List of role authorisations.
//      */
//     private List<String> roles;
// 
//     public Account() {
//     }
// 
//     public String getUsername() {
//         return username;
//     }
// 
//     public void setUsername(String username) {
//         this.username = username;
//     }
// 
//     public String getPassword() {
//         return password;
//     }
// 
//     public void setPassword(String password) {
//         this.password = password;
//     }
// 
//     public List<String> getRoles() {
//         return roles;
//     }
// 
//     public void setRoles(List<String> roles) {
//         this.roles = roles;
//     }
// 
//     @Override
//     public String toString() {
//         return toStringHelper()
//             .add("username", username)
//             .add("roles", roles)
//             .toString();
//     }
// 
// }


// Path: src/main/java/uk/co/caprica/bootlace/startup/ApplicationStartup.java
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.stereotype.Component;
import uk.co.caprica.bootlace.data.mongo.account.AccountRepository;
import uk.co.caprica.bootlace.domain.account.Account;
import java.util.ArrayList;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationListener;
import org.springframework.context.event.ContextRefreshedEvent;
import org.springframework.data.mongodb.core.MongoOperations;
import org.springframework.data.mongodb.core.index.TextIndexDefinition.TextIndexDefinitionBuilder;

/*
 * This file is part of Bootlace.
 *
 * Copyright (C) 2015
 * Caprica Software Limited (capricasoftware.co.uk)
 *
 * Licensed 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 uk.co.caprica.bootlace.startup;




/**
 * Component containing operations to execute on application startup.
 * <p>
 * This component initialises the configured database with seed data.
 * <p>
 * <em>This component only exists for purposes of this reference application and would not
 * ordinarily be used in a Production application.</em>
 */
@Component
public class ApplicationStartup implements ApplicationListener<ContextRefreshedEvent> {

    /**
     * Log.
     */
    private final Logger logger = LoggerFactory.getLogger(ApplicationStartup.class);

    /**
     * Lower-level interface to the database, used e.g. to create collections and indexes.
     */
    @Autowired
    private MongoOperations mongoOperations;

    /**
     * Repository for account entities.
     */
    @Autowired
    private AccountRepository accountRepository;