001    /**
002     * Copyright (c) 2000-present Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portal.kernel.backgroundtask;
016    
017    import com.liferay.portal.kernel.util.StringPool;
018    
019    /**
020     * @author Daniel Kocsis
021     * @author Eduardo Garcia
022     */
023    public class BackgroundTaskConstants {
024    
025            public static final int ISOLATION_LEVEL_CLASS = 1;
026    
027            public static final int ISOLATION_LEVEL_COMPANY = 2;
028    
029            public static final int ISOLATION_LEVEL_GROUP = 3;
030    
031            public static final int ISOLATION_LEVEL_NOT_ISOLATED = 4;
032    
033            public static final String LABEL_CANCELLED = "cancelled";
034    
035            public static final String LABEL_FAILED = "failed";
036    
037            public static final String LABEL_IN_PROGRESS = "in-progress";
038    
039            public static final String LABEL_NEW = "new";
040    
041            public static final String LABEL_QUEUED = "queued";
042    
043            public static final String LABEL_SUCCESSFUL = "successful";
044    
045            public static final int STATUS_CANCELLED = 5;
046    
047            public static final int STATUS_FAILED = 2;
048    
049            public static final int STATUS_IN_PROGRESS = 1;
050    
051            public static final int STATUS_NEW = 0;
052    
053            public static final int STATUS_QUEUED = 4;
054    
055            public static final int STATUS_SUCCESSFUL = 3;
056    
057            public static String getStatusCssClass(int status) {
058                    if (status == STATUS_CANCELLED) {
059                            return "label-info";
060                    }
061                    else if (status == STATUS_FAILED) {
062                            return "label-danger";
063                    }
064                    else if (status == STATUS_IN_PROGRESS) {
065                            return "label-warning";
066                    }
067                    else if ((status == BackgroundTaskConstants.STATUS_NEW) ||
068                                     (status == BackgroundTaskConstants.STATUS_QUEUED)) {
069    
070                            return "label-info";
071                    }
072                    else if (status == STATUS_SUCCESSFUL) {
073                            return "label-success";
074                    }
075    
076                    return StringPool.BLANK;
077            }
078    
079            public static String getStatusLabel(int status) {
080                    if (status == STATUS_CANCELLED) {
081                            return LABEL_CANCELLED;
082                    }
083                    else if (status == STATUS_FAILED) {
084                            return LABEL_FAILED;
085                    }
086                    else if (status == STATUS_IN_PROGRESS) {
087                            return LABEL_IN_PROGRESS;
088                    }
089                    else if (status == STATUS_NEW) {
090                            return LABEL_NEW;
091                    }
092                    else if (status == STATUS_QUEUED) {
093                            return LABEL_QUEUED;
094                    }
095                    else if (status == STATUS_SUCCESSFUL) {
096                            return LABEL_SUCCESSFUL;
097                    }
098                    else {
099                            return StringPool.BLANK;
100                    }
101            }
102    
103    }