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 String BACKGROUND_TASK_ID = "backgroundTaskId";
026    
027            public static final int ISOLATION_LEVEL_CLASS = 1;
028    
029            public static final int ISOLATION_LEVEL_COMPANY = 2;
030    
031            public static final int ISOLATION_LEVEL_CUSTOM = 6;
032    
033            public static final int ISOLATION_LEVEL_GROUP = 3;
034    
035            public static final int ISOLATION_LEVEL_NOT_ISOLATED = 4;
036    
037            public static final int ISOLATION_LEVEL_TASK_NAME = 5;
038    
039            public static final String LABEL_CANCELLED = "cancelled";
040    
041            public static final String LABEL_FAILED = "failed";
042    
043            public static final String LABEL_IN_PROGRESS = "in-progress";
044    
045            public static final String LABEL_NEW = "new";
046    
047            public static final String LABEL_QUEUED = "queued";
048    
049            public static final String LABEL_SUCCESSFUL = "successful";
050    
051            public static final int STATUS_CANCELLED = 5;
052    
053            public static final int STATUS_FAILED = 2;
054    
055            public static final int STATUS_IN_PROGRESS = 1;
056    
057            public static final int STATUS_NEW = 0;
058    
059            public static final int STATUS_QUEUED = 4;
060    
061            public static final int STATUS_SUCCESSFUL = 3;
062    
063            public static String getStatusCssClass(int status) {
064                    if (status == STATUS_CANCELLED) {
065                            return "text-info";
066                    }
067                    else if (status == STATUS_FAILED) {
068                            return "text-danger";
069                    }
070                    else if (status == STATUS_IN_PROGRESS) {
071                            return "text-warning";
072                    }
073                    else if ((status == BackgroundTaskConstants.STATUS_NEW) ||
074                                     (status == BackgroundTaskConstants.STATUS_QUEUED)) {
075    
076                            return "text-info";
077                    }
078                    else if (status == STATUS_SUCCESSFUL) {
079                            return "text-success";
080                    }
081    
082                    return StringPool.BLANK;
083            }
084    
085            public static String getStatusLabel(int status) {
086                    if (status == STATUS_CANCELLED) {
087                            return LABEL_CANCELLED;
088                    }
089                    else if (status == STATUS_FAILED) {
090                            return LABEL_FAILED;
091                    }
092                    else if (status == STATUS_IN_PROGRESS) {
093                            return LABEL_IN_PROGRESS;
094                    }
095                    else if (status == STATUS_NEW) {
096                            return LABEL_NEW;
097                    }
098                    else if (status == STATUS_QUEUED) {
099                            return LABEL_QUEUED;
100                    }
101                    else if (status == STATUS_SUCCESSFUL) {
102                            return LABEL_SUCCESSFUL;
103                    }
104                    else {
105                            return StringPool.BLANK;
106                    }
107            }
108    
109    }